private static void DrawImage(Graphics g, bool isEnabled, Rectangle imageRect, ImageList imageList, int imageIndex, Image image)
 {
     if ((imageList != null && imageIndex >= 0 && imageIndex < imageList.Images.Count) || image != null)
     {
         if (imageList != null && imageIndex >= 0 && imageIndex < imageList.Images.Count)
         {
             if (isEnabled)
             {
                 imageList.Draw(g, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height, imageIndex);
             }
             else
             {
                 StiControlPaint.DrawImageDisabled(g, imageList.Images[imageIndex], imageRect.Left, imageRect.Top);
             }
         }
         else
         {
             if (isEnabled)
             {
                 g.DrawImage(image, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
             }
             else
             {
                 StiControlPaint.DrawImageDisabled(g, image, imageRect.Left, imageRect.Top);
             }
         }
     }
 }
 private void DrawImage(Graphics g, Rectangle imageRect)
 {
     if ((ImageList != null && ImageIndex >= 0 && ImageIndex < ImageList.Images.Count) || Image != null)
     {
         if (ImageList != null && ImageIndex >= 0 && ImageIndex < ImageList.Images.Count)
         {
             if (Enabled)
             {
                 ImageList.Draw(g, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height, ImageIndex);
             }
             else
             {
                 StiControlPaint.DrawImageDisabled(g, ImageList.Images[ImageIndex], imageRect.Left, imageRect.Top);
             }
         }
         else
         {
             if (Enabled)
             {
                 g.DrawImage(Image, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
             }
             else
             {
                 StiControlPaint.DrawImageDisabled(g, Image, imageRect.Left, imageRect.Top);
             }
         }
     }
 }
 protected void DrawDropDownArrow(Graphics g, Rectangle rect)
 {
     if (IsDrawDropDownArrow || DropDownMenu != null)
     {
         if (Enabled)
         {
             g.DrawImage(dropDownArrowBitmap, rect.X, rect.Y, rect.Width, rect.Height);
         }
         else
         {
             StiControlPaint.DrawImageDisabled(g, dropDownArrowBitmap, rect.Left, rect.Top);
         }
     }
 }
Beispiel #4
0
        private void DrawMenuItemImage(Graphics g, DrawItemEventArgs e, MenuItem item, bool rightToLeft)
        {
            Rectangle rect = e.Bounds;

            rect.Location = new Point(0, 0);
            Image image = null;

            var imageList  = GetImageList(item);
            int imageIndex = GetImageIndex(item);

            if (imageList != null && imageIndex != -1 && imageIndex < imageList.Images.Count)
            {
                image = imageList.Images[imageIndex];
            }

            if (image != null)
            {
                if (rightToLeft)
                {
                    rect = new Rectangle(
                        rect.Right - MenuBarWidth + (MenuBarWidth - imageList.Images[imageIndex].Width) / 2,
                        rect.Y + (ImageSize - imageList.Images[imageIndex].Height) / 2,
                        image.Width,
                        image.Height);
                }
                else
                {
                    rect = new Rectangle(
                        (MenuBarWidth - imageList.Images[imageIndex].Width) / 2,
                        rect.Y + (ImageSize - imageList.Images[imageIndex].Height) / 2,
                        image.Width,
                        image.Height);
                }
            }

            if (image != null)
            {
                if (item.Enabled)
                {
                    imageList.Draw(g, rect.X, rect.Y, rect.Width, rect.Height, imageIndex);
                }
                else
                {
                    StiControlPaint.DrawImageDisabled(g, image as Bitmap, rect.X, rect.Y);
                }
            }
        }