Esempio n. 1
0
        public override void OnPaint(DUIPaintEventArgs e)
        {
            //base.OnPaint(e);
            e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias;
            float radius = 6;

            using (DUIPen pen = new DUIPen(this.ForeColor, 2))
            {
                e.Graphics.DrawEllipse(pen, new RectangleF(3, 3, this.Height - 6, this.Height - 6));
            }
            if (this.Checked)
            {
                e.Graphics.FillEllipse(DUIBrushes.White, new RectangleF(this.Height / 2 - radius / 2, this.Height / 2 - radius / 2, radius, radius));
            }
            SizeF sizef = e.Graphics.MeasureString(this.Text, this.Font);

            using (DUISolidBrush brush = new DUISolidBrush(this.ForeColor))
            {
                e.Graphics.DrawString(this.Text, this.Font, brush, new PointF(this.Height, this.Height / 2 - sizef.Height / 2 - 2));
            }
            if (!this.Enabled)
            {
                using (DUISolidBrush sb = new DUISolidBrush(Color.FromArgb(150, Color.Gray)))
                {
                    e.Graphics.FillRectangle(sb, e.ClipRectangle);
                }
            }
        }
Esempio n. 2
0
 public override void DrawCheckState(DUIPaintEventArgs e)
 {
     using (DUIPen pen = new DUIPen(this.owner.ForeColor, 2))
     {
         e.Graphics.DrawRectangle(pen, new RectangleF(Bounds.X + 3, Bounds.Y + 3, Bounds.Width - 6, Bounds.Height - 6));
     }
 }
Esempio n. 3
0
 public DUIRuler()
 {
     this.Height        = 20;
     this.brush         = new DUISolidBrush(this.ForeColor);
     this.dividingBrush = new DUIThreadSafeBitmapBrush(new Size(1, 1), (g, s) =>
     {
         using (DUIPen pen = new DUIPen(this.ForeColor))
         {
             for (int i = 0; i < 10; i++)
             {
                 if (i == 0)
                 {
                     g.DrawLine(pen, new PointF(i * this.DividingInterval, this.ClientSize.Height), new PointF(i * this.DividingInterval, this.ClientSize.Height - 3 * DividingHeight));
                 }
                 else if (i == 5)
                 {
                     g.DrawLine(pen, new PointF(i * this.DividingInterval, this.ClientSize.Height), new PointF(i * this.DividingInterval, this.ClientSize.Height - 2 * DividingHeight));
                 }
                 else
                 {
                     g.DrawLine(pen, new PointF(i * this.DividingInterval, this.ClientSize.Height), new PointF(i * this.DividingInterval, this.ClientSize.Height - DividingHeight));
                 }
             }
         }
     });
 }
Esempio n. 4
0
 public override void OnPaintBackground(DUIPaintEventArgs e)
 {
     //e.Graphics.FillRectangle(DUIBrushes.LightGreen, e.ClipRectangle);
     //e.Graphics.FillRectangle(DUIBrushes.White, new RectangleF(this.BorderWidth, this.BorderWidth, this.ClientSize.Width, this.ClientSize.Height));
     e.Graphics.TranslateTransform(-this.X, -this.Y);
     e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias;
     using (DUISolidBrush backBrush = new DUISolidBrush(this.BackColor))
     {
         e.Graphics.FillPolygon(backBrush, this.PolygonBounds);
     }
     using (DUIPen borderPen = new DUIPen(this.Border.BorderColor, 1 / ScaleableControlScaling))
     {
         e.Graphics.DrawPolygon(borderPen, this.PolygonBounds);
     }
     //using (DUIPen borderPen = new DUIPen(Color.Red, 1 / ScaleableControlScaling))
     //{
     //    e.Graphics.DrawPolygon(borderPen, this.Polygon);
     //}
     e.Graphics.SmoothingMode = DUISmoothingMode.Default;
     e.Graphics.TranslateTransform(this.X, this.Y);
     //if (PaintBackground != null)
     //{
     //    PaintBackground(this, e);
     //}
 }
Esempio n. 5
0
        protected override void DrawBounds(DUIPaintEventArgs e)
        {
            //base.DrawBounds(e);
            float boundsWidth = 1 / ScaleableControlScaling;

            using (DUIPen pen = new DUIPen(this.Focused ? Color.Blue : Color.Black, boundsWidth))
            {
                e.Graphics.DrawRectangle(pen, new RectangleF(this.BorderWidth - boundsWidth / 2, this.BorderWidth - boundsWidth / 2, this.ClientRectangle.Width + boundsWidth, this.ClientRectangle.Height + boundsWidth));
            }
        }
Esempio n. 6
0
 public override void OnPaintBackground(DUIPaintEventArgs e)
 {
     using (DUIPen borderPen = new DUIPen(this.Border.BorderColor, this.BorderWidth))
         using (DUISolidBrush backBrush = new DUISolidBrush(this.BackColor))
         {
             e.Graphics.DrawRectangle(borderPen, new RectangleF(this.BorderWidth / 2F, this.BorderWidth / 2F, this.Width - this.BorderWidth, this.Height - this.BorderWidth));
             e.Graphics.FillRectangle(backBrush, new RectangleF((this.BorderWidth - this.Center.X) / this.scaling, (this.BorderWidth - this.Center.Y) / this.scaling, this.ClientSize.Width / this.scaling, this.ClientSize.Height / this.scaling));
         }
     if (this.BackgroundImage != null)
     {
         e.Graphics.DrawImage(this.BackgroundImage, new RectangleF(this.BorderWidth, this.BorderWidth, this.ClientSize.Width, this.ClientSize.Height));
     }
     //if (PaintBackground != null)
     //{
     //    PaintBackground(this, e);
     //}
 }
Esempio n. 7
0
 public override void OnPaint(DUIPaintEventArgs e)
 {
     base.OnPaint(e);
     e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias;
     //if (!this.LeftToRight)
     //{
     //    e.Graphics.RotateTransform(-90);
     //}
     using (DUIPen pen1 = new DUIPen(Color.FromArgb(50, 50, 50)))
         using (DUIPen pen2 = new DUIPen(Color.FromArgb(150, 150, 150)))
             using (DUIPen pen3 = new DUIPen(Color.FromArgb(222, 222, 222)))
             {
                 if (this.LeftToRight)
                 {
                     e.Graphics.DrawLine(pen1, new PointF(SliderSize.Width / 2, SliderSize.Width / 2 - 1), new PointF(this.ClientSize.Width - SliderSize.Width / 2, SliderSize.Width / 2 - 1));
                     e.Graphics.DrawLine(pen2, new PointF(SliderSize.Width / 2, SliderSize.Width / 2 + 0), new PointF(this.ClientSize.Width - SliderSize.Width / 2, SliderSize.Width / 2 + 0));
                     e.Graphics.DrawLine(pen3, new PointF(SliderSize.Width / 2, SliderSize.Width / 2 + 1), new PointF(this.ClientSize.Width - SliderSize.Width / 2, SliderSize.Width / 2 + 1));
                 }
                 else
                 {
                     e.Graphics.DrawLine(pen1, new PointF(SliderSize.Height / 2 - 1, SliderSize.Height / 2), new PointF(SliderSize.Height / 2 - 1, this.ClientSize.Height - SliderSize.Height / 2));
                     e.Graphics.DrawLine(pen2, new PointF(SliderSize.Height / 2 + 0, SliderSize.Height / 2), new PointF(SliderSize.Height / 2 + 0, this.ClientSize.Height - SliderSize.Height / 2));
                     e.Graphics.DrawLine(pen3, new PointF(SliderSize.Height / 2 + 1, SliderSize.Height / 2), new PointF(SliderSize.Height / 2 + 1, this.ClientSize.Height - SliderSize.Height / 2));
                 }
             }
     using (DUIPen pen = new DUIPen(this.ForeColor))
     {
         int tickCount = this.Maximum - this.Minimum + 1;
         if (this.LeftToRight)
         {
             for (int i = 0; i <= tickCount; i++)
             {
                 e.Graphics.DrawLine(pen, new PointF((float)SliderSize.Width / 2F + i * ((float)(this.ClientSize.Width - SliderSize.Width) / (float)(tickCount - 1)), SliderSize.Width + 2), new PointF((float)SliderSize.Width / 2 + i * ((float)(this.ClientSize.Width - SliderSize.Width) / (float)(tickCount - 1)), SliderSize.Width + 2 + 5));
             }
         }
         else
         {
             for (int i = 0; i <= tickCount; i++)
             {
                 e.Graphics.DrawLine(pen, new PointF(SliderSize.Height + 2, (float)SliderSize.Height / 2F + i * ((float)(this.ClientSize.Height - SliderSize.Height) / (float)(tickCount - 1))), new PointF(SliderSize.Height + 2 + 5, (float)SliderSize.Height / 2 + i * ((float)(this.ClientSize.Height - SliderSize.Height) / (float)(tickCount - 1))));
             }
         }
     }
 }
        public override void OnPaintForeground(DUIPaintEventArgs e)
        {
            var backupSmoothingMode = e.Graphics.SmoothingMode;

            e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias;
            float  width    = this.ThisRadius / 3;
            PointF endPoint = this.isMouseDownInRotateBounds ? new PointF(mouseMovePoint.X, this.Height / 2) : new PointF(this.Width - this.ThisRadius, this.Height / 2);

            using (DUIPen pen = new DUIPen(Color.Black, width))
            {
                e.Graphics.DrawLine(pen, new PointF(this.ThisRadius, this.Height / 2), endPoint);
            }
            e.Graphics.FillEllipse(DUIBrushes.Black, new RectangleF(0, 0, this.ThisRadius * 2, this.ThisRadius * 2));
            e.Graphics.FillEllipse(DUIBrushes.White, new RectangleF(width, width, this.ThisRadius * 2 - width * 2, this.ThisRadius * 2 - width * 2));
            e.Graphics.FillRectangle(DUIBrushes.Black, new RectangleF(endPoint.X - this.ThisRadius, endPoint.Y - this.ThisRadius, this.ThisRadius * 2, this.ThisRadius * 2));
            e.Graphics.FillRectangle(DUIBrushes.White, new RectangleF(width + endPoint.X - this.ThisRadius, width + endPoint.Y - this.ThisRadius, this.ThisRadius * 2 - width * 2, this.ThisRadius * 2 - width * 2));
            //e.Graphics.FillEllipse(DUIBrushes.Black, new RectangleF(0, 0, this.Width - 1, this.Height - 1));
            //e.Graphics.FillEllipse(DUIBrushes.White, new RectangleF(2, 2, this.Width - 2 * 2 - 1, this.Height - 2 * 2 - 1));
            e.Graphics.SmoothingMode = backupSmoothingMode;
            //base.OnPaint(e);
        }
Esempio n. 9
0
        public override void OnPaintBackground(DUIPaintEventArgs e)
        {
            e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias;
            RectangleF borderRect = new RectangleF(0, 0, this.Width - 1, this.Height - 1);

            using (DUISolidBrush borderBrush = new DUISolidBrush(this.Border.BorderColor))
                using (DUIPen borderPen = new DUIPen(this.Border.BorderColor, 1))
                {
                    e.Graphics.FillRoundedRectangle(borderBrush, borderRect, this.Radius);
                }
            RectangleF backRect       = new RectangleF(this.Border.BorderWidth, this.Border.BorderWidth, this.ClientSize.Width - 1, (this.ClientSize.Height - 1) / 2);
            RectangleF backShadowRect = new RectangleF(this.Border.BorderWidth, this.Border.BorderWidth + ((this.ClientSize.Height - 1) - (this.ClientSize.Height - 1) / 2), this.ClientSize.Width - 1, ((this.ClientSize.Height - 1) - (this.ClientSize.Height - 1) / 2));

            if (this.mouseDownImage == null)
            {
                if (isMouseDown)
                {
                    Color backColor   = Color.FromArgb(this.BackColor.R, Math.Max(this.BackColor.G - 15, 0), Math.Max(this.BackColor.B - 25, 0));
                    Color shadowColor = Color.FromArgb(Math.Max(backColor.R - 25, 0), Math.Max(backColor.G - 25, 0), Math.Max(backColor.B - 25, 0));
                    using (DUISolidBrush backBrush = new DUISolidBrush(backColor))
                        using (DUISolidBrush backShadowBrush = new DUISolidBrush(shadowColor))
                            using (Pen backPen = new Pen(backColor, 1))
                                using (Pen backShadowPen = new Pen(shadowColor, 1))
                                {
                                    e.Graphics.FillRoundedRectangle(backBrush, backRect, this.Radius);
                                }
                }
            }
            else
            {
                if (this.MouseDownImage != null)
                {
                    e.Graphics.DrawImage(this.MouseDownImage, new RectangleF(0, 0, this.ClientSize.Width, this.ClientSize.Height), new RectangleF(0, 0, this.mouseDownImage.Width, this.mouseDownImage.Height), GraphicsUnit.Pixel);
                }
            }
            if (this.mouseHoverImage == null)
            {
                if (!isMouseDown && this.RectangleToScreen(this.Bounds).Contains(MousePosition))
                {
                    Color backColor   = Color.FromArgb(this.BackColor.R, Math.Min(this.BackColor.G + 15, 255), Math.Min(this.BackColor.B + 25, 255));
                    Color shadowColor = Color.FromArgb(Math.Max(backColor.R - 25, 0), Math.Max(backColor.G - 25, 0), Math.Max(backColor.B - 25, 0));
                    using (DUISolidBrush backBrush = new DUISolidBrush(backColor))
                        using (DUISolidBrush backShadowBrush = new DUISolidBrush(shadowColor))
                            using (Pen backPen = new Pen(backColor, 1))
                                using (Pen backShadowPen = new Pen(shadowColor, 1))
                                {
                                    e.Graphics.FillRoundedRectangle(backBrush, backRect, this.Radius);
                                }
                }
            }
            else
            {
                if (this.MouseHoverImage != null)
                {
                    e.Graphics.DrawImage(this.MouseHoverImage, new RectangleF(0, 0, this.ClientSize.Width, this.ClientSize.Height), new RectangleF(0, 0, this.mouseHoverImage.Width, this.mouseHoverImage.Height), GraphicsUnit.Pixel);
                }
            }
            if (this.mouseNormalImage == null)
            {
                if (!isMouseDown && !isMouseHover)
                {
                    Color shadowColor = Color.FromArgb(Math.Max(this.BackColor.R - 25, 0), Math.Max(this.BackColor.G - 25, 0), Math.Max(this.BackColor.B - 25, 0));
                    using (DUISolidBrush backBrush = new DUISolidBrush(this.BackColor))
                        using (DUISolidBrush backShadowBrush = new DUISolidBrush(shadowColor))
                            using (Pen backPen = new Pen(this.BackColor, 1))
                                using (Pen backShadowPen = new Pen(shadowColor, 1))
                                {
                                    e.Graphics.FillRoundedRectangle(backBrush, backRect, this.Radius);
                                }
                }
            }
            else
            {
                if (this.MouseNormalImage != null)
                {
                    e.Graphics.DrawImage(this.MouseNormalImage, new RectangleF(0, 0, this.ClientSize.Width, this.ClientSize.Height), new RectangleF(0, 0, this.mouseNormalImage.Width, this.mouseNormalImage.Height), GraphicsUnit.Pixel);
                }
            }
            #region 背景图
            if (this.BackgroundImage != null)
            {
                e.Graphics.DrawImage(this.BackgroundImage, new RectangleF(this.Border.BorderWidth, this.Border.BorderWidth, this.ClientSize.Width, this.ClientSize.Height));
            }
            #endregion
            #region 绘制文字
            SizeF sizeF = e.Graphics.MeasureString(this.Text, this.Font);
            using (DUISolidBrush textbrush = new DUISolidBrush(this.ForeColor))
            {
                e.Graphics.DrawString(this.Text, this.Font, textbrush, new PointF(this.Width / 2 - sizeF.Width / 2, this.Height / 2 - sizeF.Height / 2));
            }
            #endregion
        }