Beispiel #1
0
 public override void Paint(Graphics graphics, bool focused,CustomButton.ButtonState state)
 {
     Rectangle r = new Rectangle(0, 0, _width, _height);
     switch (state)
     {
         case CustomButton.ButtonState.Normal:
             if (focused)
             {
                 ButtonRenderer.DrawButton(graphics, r, false, System.Windows.Forms.VisualStyles.PushButtonState.Default);
             }
             else
             {
                 ButtonRenderer.DrawButton(graphics, r, false, System.Windows.Forms.VisualStyles.PushButtonState.Normal);
             }
             break;
         case CustomButton.ButtonState.Hot:
             ButtonRenderer.DrawButton(graphics, r, focused, System.Windows.Forms.VisualStyles.PushButtonState.Hot);
             break;
         case CustomButton.ButtonState.Pressed:
             ButtonRenderer.DrawButton(graphics, r, false, System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
             break;
         case CustomButton.ButtonState.Disabled:
             ButtonRenderer.DrawButton(graphics, r, false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
             break;
     }
 }
Beispiel #2
0
        public virtual void Paint(Graphics graphics, bool focused, CustomButton.ButtonState state)
        {
            switch (state)
            {
                case CustomButton.ButtonState.Disabled:
                    _shape.Brush = _fillBrushDisabled;
                    _shape.Pen = _borderPenDisabled;
                    break;
                case CustomButton.ButtonState.Normal:
                    _shape.Brush = _fillBrushNormal;
                    _shape.Pen = _borderPenNormal;
                    break;
                case CustomButton.ButtonState.Hot:
                    _shape.Brush = _fillBrushHot;
                    _shape.Pen = _borderPenHot;
                    break;
                case CustomButton.ButtonState.Pressed:
                    _shape.Brush = _fillBrushPressed;
                    _shape.Pen = _borderPenPressed;
                    break;
            }

            _shape.Fill(graphics);

            Rectangle light = new Rectangle(0, 0, this.Width, this.Height);
            graphics.FillEllipse(
                new LinearGradientBrush(
                    light,
                    Color.FromArgb(80, Color.White),
                    Color.FromArgb(0, Color.White),
                    LinearGradientMode.Vertical
                ),
                light
            );

            _shape.Draw(graphics, SmoothingMode.AntiAlias);

            if (focused)
            {
                Rectangle r = new Rectangle(0, 0, _width, _height);
                r.Inflate(-2, -2);
                ControlPaint.DrawFocusRectangle(graphics, r);
            }
        }