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

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

            var checkmarkPath = DrawHelper.CreateRoundRect(2, 2, 16, 16, 1);
            var checkMarkLine = new Rectangle(3, 3, 14, 14);

            EnabledCheckedColor = ThemeColors.PrimaryColor;
            SolidBrush BG  = new SolidBrush(Enabled ? (Checked || enterFlag ? EnabledCheckedColor : EnabledUnCheckedColor) : DisabledColor);
            Pen        Pen = new Pen(BG.Color);

            graphics.FillPath(BG, checkmarkPath);
            graphics.DrawPath(Pen, checkmarkPath);

            //绘制对号
            graphics.DrawLines(new Pen(Color.White, 2), new PointF[]
            {
                new PointF(5, 9), new PointF(9, 13), new PointF(15, 6)
            });
            graphics.FillRectangle(new SolidBrush(Color.White), PointAnimationNum, PointAnimationNum, SizeAnimationNum, SizeAnimationNum);

            //绘制文字
            graphics.DrawString(Text, Font, new SolidBrush(Checked?ThemeColors.PrimaryColor:ThemeColors.MainText), new RectangleF(22, 0, Width - 22, Height), StringAlign.Center);
        }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            var bitmap   = new Bitmap(Width, Height);
            var graphics = Graphics.FromImage(bitmap);

            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

            graphics.Clear(Parent.BackColor);
            var backPath = DrawHelper.CreateRoundRect(1, 1, Width - 2, Height - 2, 2);

            graphics.FillPath(new SolidBrush(Color.White), backPath);
            graphics.DrawPath(new Pen(ThemeColors.OneLevelBorder, 2), backPath);

            //绘制背景颜色
            graphics.FillRectangle(new SolidBrush(Color.White), new RectangleF(0, 0, Width, Height));

            //绘制文本
            graphics.DrawString(Text, Font, new SolidBrush(ThemeColors.PrimaryColor), new Point(4, 4));

            //绘制下拉箭头
            graphics.DrawString("6", new Font("Marlett", 12), new SolidBrush(SystemColors.ControlDark), new Rectangle(Width - 18, 6, 18, 18));

            //graphics.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(bitmap, 0, 0);
            bitmap.Dispose();
        }
Exemplo n.º 3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

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

            var bg = DrawHelper.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);

            graphics.FillPath(new SolidBrush(ThemeColors.FourLevelBorder), bg);
            graphics.DrawPath(new Pen(enterFlag ? ThemeColors.PrimaryColor : ThemeColors.PlaceholderText, 1f), bg);

            textBox.Text = Math.Round(_value, Precision).ToString();
            switch (_style)
            {
            case NumericStyle.LeftRight:
                textBox.Size     = new Size(Width - 2 * Height, Height - 2);
                textBox.Location = new Point(Height, 5);
                graphics.DrawLine(new Pen(ThemeColors.PlaceholderText, 0.5f), textBox.Location.X - 0.5f, 1, textBox.Location.X - 0.5f, Height - 1);
                break;

            case NumericStyle.TopDown:
                textBox.Size     = new Size(Width - Height - 2, Height - 2);
                textBox.Location = new Point(2, 5);
                graphics.DrawLine(new Pen(ThemeColors.PlaceholderText, 0.5f), textBox.Location.X + textBox.Width + 0.5f, Height / 2, Width - 1, Height / 2);
                break;
            }
            graphics.DrawString("+", new Font("Segoe UI", 14f), new SolidBrush((upRectangleF.Contains(mousePoint) && enterFlag) ? ThemeColors.PrimaryColor : ThemeColors.SecondaryText), upRectangleF, StringAlign.Center);
            graphics.DrawString("-", new Font("Segoe UI", 14f), new SolidBrush((downRectangleF.Contains(mousePoint) && enterFlag) ? ThemeColors.PrimaryColor : ThemeColors.SecondaryText), downRectangleF, StringAlign.Center);
            graphics.DrawLine(new Pen(ThemeColors.PlaceholderText, 0.5f), textBox.Location.X + textBox.Width + 0.5f, 1, textBox.Location.X + textBox.Width + 0.5f, Height - 1);
            graphics.FillRectangle(new SolidBrush(Color.White), textBox.Location.X, 1, textBox.Width, Height - 2);
            base.Controls.Add(textBox);
        }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var graphics = e.Graphics;

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

            var backBrush = new SolidBrush(ThemeColors.PrimaryColor);
            var textBrush = new SolidBrush(ThemeColors.PrimaryColor);

            switch (_type)
            {
            case AlertType.Success:
                backBrush = new SolidBrush(Color.FromArgb(25, ThemeColors.Success));
                textBrush = new SolidBrush(ThemeColors.Success);
                break;

            case AlertType.Warning:
                backBrush = new SolidBrush(Color.FromArgb(25, ThemeColors.Warning));
                textBrush = new SolidBrush(ThemeColors.Warning);
                break;

            case AlertType.info:
                backBrush = new SolidBrush(Color.FromArgb(25, ThemeColors.Info));
                textBrush = new SolidBrush(ThemeColors.Info);
                break;

            case AlertType.Error:
                backBrush = new SolidBrush(Color.FromArgb(25, ThemeColors.Danger));
                textBrush = new SolidBrush(ThemeColors.Danger);
                break;

            default:
                break;
            }

            var back = DrawHelper.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);

            graphics.FillPath(new SolidBrush(Color.White), back);
            graphics.FillPath(backBrush, back);
            graphics.DrawPath(new Pen(textBrush, 1f), back);
            graphics.DrawString(Text, Font, textBrush, new RectangleF(20, 0, Width - 40, Height), StringAlign.Left);
            graphics.DrawString("r", new Font("Marlett", 10), new SolidBrush(DrawHelper.DarkBackColor), new Rectangle(Width - 34, 0, 34, 34), StringAlign.Center);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 绘制整个背景
 /// </summary>
 /// <param name="e"></param>
 protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
 {
     e.ToolStrip.ForeColor = ThemeColors.MainText;
     if (e.ToolStrip is ToolStripDropDown)
     {
         var g = e.Graphics;
         g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
         g.SmoothingMode     = SmoothingMode.HighQuality;
         g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
         g.Clear(Color.White);
         var bg = DrawHelper.CreateRoundRect(0.5f, 0.5f, e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1, 3);
         g.DrawPath(new Pen(ThemeColors.OneLevelBorder, 1), bg);
         g.FillPath(new SolidBrush(Color.White), bg);
     }
     else
     {
         base.OnRenderToolStripBackground(e);
     }
 }
Exemplo n.º 6
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            var graphics = pe.Graphics;

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

            if (Image == null)
            {
                graphics.FillRectangle(new SolidBrush(ThemeColors.PlaceholderText), new RectangleF(0, 0, Width, Height));
            }
            base.OnPaint(pe);

            var backPath = DrawHelper.CreateRoundRect(0, 00, Width, Height, 4);

            graphics.DrawPath(new Pen(Parent.BackColor, 4), backPath);
        }
Exemplo n.º 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;          //消除锯齿
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;        //高质量显示
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; //最高质量显示文本
            graphics.Clear(Parent.BackColor);

            var BG = DrawHelper.CreateRoundRect(1, 1, Width - 2, Height - 2, 3);

            graphics.FillPath(new SolidBrush(BackColor), BG);
            graphics.DrawPath(new Pen(ThemeColors.OneLevelBorder), BG);

            if (ShowText)
            {
                graphics.DrawLine(new Pen(ThemeColors.OneLevelBorder, 1), 0, 38, Width, 38);
                graphics.DrawString(Text, new Font("微软雅黑", 12F), new SolidBrush(ThemeColors.MainText), new RectangleF(15, 0, Width - 50, 38), StringAlign.Left);
            }
        }
Exemplo n.º 8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;          //消除锯齿
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;        //高质量显示
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; //最高质量显示文本
            graphics.Clear(Parent.BackColor);

            var BG = DrawHelper.CreateRoundRect(1, 1, Width - 2, Height - 2, 3);

            graphics.FillPath(new SolidBrush(BackColor), BG);
            graphics.DrawPath(new Pen(ThemeColors.OneLevelBorder), BG);

            if (ShowText)
            {
                graphics.DrawLine(HeaderStyle.DrawLine.Pen, HeaderStyle.DrawLine.X1, HeaderStyle.DrawLine.Y1, Width, HeaderStyle.DrawLine.Y2);
                graphics.DrawString(Text, HeaderStyle.HeaderFont, HeaderStyle.HeaderColor, new RectangleF(HeaderStyle.HeaderSize.X, HeaderStyle.HeaderSize.Y, Width - 50, HeaderStyle.HeaderSize.Height), HeaderStyle.HeaderAlignment);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            //通过响应这条消息,所有者窗口可以通过使用给定的相关显示设备的句柄来设置编辑框的文本和背景颜色
            //windows消息值表:https://blog.csdn.net/zhangguofu2/article/details/19236081
            if (m.Msg == 0x000F || //要求一个窗口重绘自己
                m.Msg == 0x133    //当一个编辑型控件将要被绘制时发送此消息给它的父窗口;
                )
            {
                IntPtr hDC = GetWindowDC(m.HWnd);
                if (hDC.ToInt32() == 0) //如果取设备上下文失败则返回
                {
                    return;
                }

                //建立Graphics对像
                Graphics graphics = Graphics.FromHdc(hDC);

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

                var backPath = DrawHelper.CreateRoundRect(1, 1, Width - 2, Height - 2, 2);
                graphics.FillPath(new SolidBrush(Color.White), backPath);
                graphics.DrawPath(new Pen(ThemeColors.OneLevelBorder, 2), backPath);

                //绘制背景颜色
                graphics.FillRectangle(new SolidBrush(Color.White), new RectangleF(1, 1, Width - 2, Height - 2));

                //绘制文本
                graphics.DrawString(Text, Font, new SolidBrush(ThemeColors.PrimaryColor), new Point(6, 6));

                //绘制下拉箭头
                graphics.DrawString("6", new Font("Marlett", 12), new SolidBrush(SystemColors.ControlDark), new Rectangle(Width - 22, (Height - 18) / 2, 18, 18));
                //释放DC
                ReleaseDC(m.HWnd, hDC);
            }
        }
Exemplo n.º 10
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);
            }
        }