Esempio n. 1
0
        protected override void PaintButton(Graphics graphics, Rectangle bounds)
        {
            if (Application.RenderWithVisualStyles || DesktopWindowManager.IsCompositionEnabled())
            {
                try
                {
                    VisualStyleRenderer rnd = new VisualStyleRenderer(StyleClass, StylePart, (int)ButtonState);
                    if (this.IsDesignMode() || !DesktopWindowManager.IsCompositionEnabled())
                    {
                        rnd.DrawParentBackground(graphics, this.Bounds, this);
                        rnd.DrawBackground(graphics, this.Bounds, bounds);
                    }
                    else
                    {
                        rnd.DrawGlassBackground(graphics, this.Bounds, bounds);
                    }
                    return;
                }
                catch { }
            }

            //base.PaintButton(graphics, bounds);
            Rectangle sr = this.ClientRectangle;
            sr.Offset(0, sr.Height * ((int)ButtonState - 1));
            graphics.Clear(this.Parent.BackColor);
            if (imageStrip != null)
                graphics.DrawImage(imageStrip, this.Bounds, sr, GraphicsUnit.Pixel);
            else
                using (Brush br = new SolidBrush(this.BackColor))
                    graphics.FillRectangle(br, sr);
        }