private void imagelist_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index == -1) { return; } String stg = ""; Graphics g = e.Graphics; ExamImage eximg = imagelist.Items[e.Index] as ExamImage; if (eximg != null) { Bitmap ic = null; Color bg = SystemColors.ActiveCaption; Color fc = SystemColors.WindowText; switch (eximg.StuNumber) { case -1: ic = global::shapes.Properties.Resources.red24; bg = Color.FromArgb(245, 164, 174); stg = "ورقة خاطئة"; break; case -2: ic = global::shapes.Properties.Resources.yellow24; bg = Color.FromArgb(252, 248, 177); stg = "رقم خاطئ"; break; case -3: ic = global::shapes.Properties.Resources.yellow24; bg = Color.FromArgb(252, 248, 177); stg = "خطأ مجهول"; break; default: ic = global::shapes.Properties.Resources.green24; bg = Color.FromArgb(210, 245, 164); stg = eximg.StuNumber.ToString(); break; } if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { bg = SystemColors.Highlight; fc = SystemColors.HighlightText; } g.FillRectangle(new SolidBrush(bg), e.Bounds); Pen p = new Pen(Color.DarkGray); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; p.Width = 1; g.DrawRectangle(p, e.Bounds); g.DrawImage(ic, e.Bounds.Width - 24 - 2, e.Bounds.Y + 2); StringFormat sf = new StringFormat(StringFormatFlags.DirectionRightToLeft); sf.Alignment = StringAlignment.Center; Rectangle rec = new Rectangle(new Point(e.Bounds.X - 30, e.Bounds.Y), e.Bounds.Size); g.DrawString(String.Format("الرقم:{0} العلامة:{1}", stg, eximg.Mark), imagelist.Font, new SolidBrush(fc), e.Bounds, sf); } }
private static bool isErrorImage(ExamImage im) { return(im.StuNumber <= 0); }