Ejemplo n.º 1
0
        public CustomButtonStyle(int width, int height, ButtonBorder border)
        {
            _width = width;
            _height = height;
            _fillBrushNormal = new LinearGradientBrush(new Rectangle(0, 0, _width, _height), SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical);
            _borderPenNormal = new Pen( SystemColors.ControlDark,1.2f);
            _fillBrushHot = new LinearGradientBrush(new Rectangle(0, 0, _width, _height), SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical);
            _borderPenHot = new Pen(Color.FromArgb(150,SystemColors.Highlight),2f);
            _fillBrushPressed = new LinearGradientBrush(new Rectangle(0, 0, _width, _height), SystemColors.Control, SystemColors.ControlLightLight, LinearGradientMode.Vertical);
            _borderPenPressed = new Pen(SystemColors.Highlight, 1.2f);
            _fillBrushDisabled = new LinearGradientBrush(new Rectangle(0, 0, _width, _height), SystemColors.Control, SystemColors.Control, LinearGradientMode.Vertical);
            _borderPenDisabled = SystemPens.ControlDark;
            _border = border;
            _cornerRadius = 3;

            _shape = ConvertShape(_border);
        }
Ejemplo n.º 2
0
 private ShapeRectangle ConvertShape(ButtonBorder border)
 {
     ShapeRectangle shape = null;
     switch (border)
     {
         case ButtonBorder.Rectangle:
             shape = new ShapeRectangle(0, 0, _width - 1, _height - 1);
             break;
         case ButtonBorder.RoundRectangle:
             shape = new ShapeRoundRectangle(0, 0, _width - 1, _height - 1, _cornerRadius);
             break;
         case ButtonBorder.Ellipse:
             shape = new ShapeEllipse(0, 0, _width - 1, _height - 1);
             break;
     }
     if (shape != null)
     {
         shape.Brush = _fillBrushNormal;
         shape.Pen = _borderPenNormal;
     }
     return shape;
 }