Exemple #1
0
 private void drawBackground(Graphics g)
 {
     if (isHovered)
     {
         g.ExcludeClip(rectBackGrad);
     }
     g.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
     g.ResetClip();
     if (isHovered && isFocused && IsPressed)
     {
         g.FillRectangle(pressedBackGradient, rectBackGrad);
         g.SmoothingMode = SmoothingMode.AntiAlias;
         g.DrawPath(innerPen, GraphicUtils.RoundRect(0, 1, Width - 1, Height - 2, 3, 1));
         g.DrawPath(selHoverOuterPen, GraphicUtils.RoundRect(-1, 0, Width + 1, Height, 3, 1));
     }
     else if (Checked)
     {
         g.FillRectangle(selHoverBackGrad, rectBackGrad);
         g.SmoothingMode = SmoothingMode.AntiAlias;
         g.DrawPath(innerPen, GraphicUtils.RoundRect(0, 1, Width - 1, Height - 2, 3, 1));
         g.DrawPath(selHoverOuterPen, GraphicUtils.RoundRect(-1, 0, Width + 1, Height, 3, 1));
     }
     else
     {
         if (!isHovered && !ClientRectangle.Contains(PointToClient(MousePosition)))
         {
             return;
         }
         g.FillRectangle(hoverBackGradient, rectBackGrad);
         g.SmoothingMode = SmoothingMode.AntiAlias;
         g.DrawPath(innerPen, GraphicUtils.RoundRect(0, 1, Width - 1, Height - 2, 3, 1));
         g.DrawPath(hoverOuterPen, GraphicUtils.RoundRect(-1, 0, Width + 1, Height, 3, 1));
     }
 }
Exemple #2
0
 private void refreshGradient()
 {
     rectBackGrad        = new Rectangle(1, 1, Width - 2, Height - 2);
     hoverBackGradient   = new LinearGradientBrush(new Rectangle(rectBackGrad.X, rectBackGrad.Y, 1, rectBackGrad.Height), Color.FromArgb(250, 251, 253), Color.FromArgb(235, 243, 253), 90f);
     selHoverBackGrad    = new LinearGradientBrush(new Rectangle(rectBackGrad.X, rectBackGrad.Y, 1, rectBackGrad.Height), Color.FromArgb(220, 235, 252), Color.FromArgb(193, 219, 252), 90f);
     selNoHoverBackGrad  = new LinearGradientBrush(new Rectangle(rectBackGrad.X, rectBackGrad.Y, 1, rectBackGrad.Height), Color.FromArgb(248, 248, 248), Color.FromArgb(229, 229, 229), 90f);
     pressedBackGradient = new LinearGradientBrush(new Rectangle(rectBackGrad.X, rectBackGrad.Y, 1, rectBackGrad.Height), GraphicUtils.DarkenColor(Color.FromArgb(220, 235, 252), 20), GraphicUtils.DarkenColor(Color.FromArgb(193, 219, 252), 20), 90f);
 }