示例#1
0
        private void this_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index == -1)
            {
                return;
            }
            e.DrawBackground();
            if ((e.State & DrawItemState.Selected) != 0)
            {
                e.Graphics.FillRectangle(_highlightbrush, e.Bounds);
            }
            EXItem    item   = (EXItem)this.Items[e.Index];
            Rectangle bounds = e.Bounds;
            int       x      = bounds.X + 2;

            if (item.GetType() == typeof(EXImageItem))
            {
                EXImageItem imgitem = (EXImageItem)item;
                if (imgitem.MyImage != null)
                {
                    Image img = imgitem.MyImage;
                    int   y   = bounds.Y + ((int)(bounds.Height / 2)) - ((int)(img.Height / 2)) + 1;
                    e.Graphics.DrawImage(img, x, y, img.Width, img.Height);
                    x += img.Width + 2;
                }
            }
            else if (item.GetType() == typeof(EXMultipleImagesItem))
            {
                EXMultipleImagesItem imgitem = (EXMultipleImagesItem)item;
                if (imgitem.MyImages != null)
                {
                    for (int i = 0; i < imgitem.MyImages.Count; i++)
                    {
                        Image img = (Image)imgitem.MyImages[i];
                        int   y   = bounds.Y + ((int)(bounds.Height / 2)) - ((int)(img.Height / 2)) + 1;
                        e.Graphics.DrawImage(img, x, y, img.Width, img.Height);
                        x += img.Width + 2;
                    }
                }
            }
            int fonty = bounds.Y + ((int)(bounds.Height / 2)) - ((int)(e.Font.Height / 2));

            e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor), x, fonty);
            e.DrawFocusRectangle();
        }
示例#2
0
 private void EXComboBox_DrawItem(object sender, DrawItemEventArgs e)
 {
     if (e.Index != -1)
     {
         Image myImage;
         int   num2;
         e.DrawBackground();
         if ((e.State & DrawItemState.Selected) != DrawItemState.None)
         {
             e.Graphics.FillRectangle(this.brush_0, e.Bounds);
         }
         EXItem    item   = (EXItem)base.Items[e.Index];
         Rectangle bounds = e.Bounds;
         int       x      = bounds.X + 2;
         if (item.GetType() == typeof(EXImageItem))
         {
             EXImageItem item2 = (EXImageItem)item;
             if (item2.MyImage != null)
             {
                 myImage = item2.MyImage;
                 num2    = ((bounds.Y + (bounds.Height / 2)) - (myImage.Height / 2)) + 1;
                 e.Graphics.DrawImage(myImage, x, num2, myImage.Width, myImage.Height);
                 x += myImage.Width + 2;
             }
         }
         else if (item.GetType() == typeof(EXMultipleImagesItem))
         {
             EXMultipleImagesItem item3 = (EXMultipleImagesItem)item;
             if (item3.MyImages != null)
             {
                 for (int i = 0; i < item3.MyImages.Count; i++)
                 {
                     myImage = (Image)item3.MyImages[i];
                     num2    = ((bounds.Y + (bounds.Height / 2)) - (myImage.Height / 2)) + 1;
                     e.Graphics.DrawImage(myImage, x, num2, myImage.Width, myImage.Height);
                     x += myImage.Width + 2;
                 }
             }
         }
         int num4 = (bounds.Y + (bounds.Height / 2)) - (e.Font.Height / 2);
         e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor), (float)x, (float)num4);
         e.DrawFocusRectangle();
     }
 }