Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);


            if (_buttonType == ButtonType.Default)
            {
                var BG = DrawHelper.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);
                graphics.DrawPath(new Pen(enterFlag ? (clickFlag ? ThemeColors.DarkPrimary : ThemeColors.PrimaryColor) : ThemeColors.OneLevelBorder, 1), BG);
                graphics.DrawString(Text, Font, new SolidBrush(enterFlag ? (clickFlag ? ThemeColors.DarkPrimary : ThemeColors.PrimaryColor) : ThemeColors.MainText), new RectangleF(0, 0, Width, Height), StringAlign.Center);
            }
            else
            {
                var backColor = ThemeColors.PrimaryColor;
                switch (_buttonType)
                {
                case ButtonType.Primary:
                    backColor = ThemeColors.PrimaryColor;
                    break;

                case ButtonType.Success:
                    backColor = ThemeColors.Success;
                    break;

                case ButtonType.Info:
                    backColor = ThemeColors.Info;
                    break;

                case ButtonType.Waring:
                    backColor = ThemeColors.Warning;
                    break;

                case ButtonType.Danger:
                    backColor = ThemeColors.Danger;
                    break;

                default:
                    break;
                }

                var BG = DrawHelper.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);
                if (!enterFlag)
                {
                    BG = DrawHelper.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);
                    graphics.DrawPath(new Pen(backColor, 0.5f), BG);
                }
                else
                {
                    BG = DrawHelper.CreateRoundRect(0, 0, Width, Height, 3);
                }

                var brush = new SolidBrush(enterFlag ? (clickFlag ? backColor : Color.FromArgb(225, backColor)) : Color.FromArgb(25, backColor));
                graphics.FillPath(brush, BG);
                graphics.DrawString(Text, Font, new SolidBrush(enterFlag ? Color.White : backColor), new RectangleF(0, 0, Width, Height), StringAlign.Center);
            }
        }