Ejemplo 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);
                }
            }
        }
Ejemplo n.º 2
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));
                 }
             }
         }
     });
 }
Ejemplo n.º 3
0
 public override void OnPaintForeground(DUIPaintEventArgs e)
 {
     base.OnPaintForeground(e);
     e.Graphics.TranslateTransform(-this.X - this.BorderWidth, -this.Y - this.BorderWidth);
     e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias;
     using (DUISolidBrush sb = new DUISolidBrush(Color.FromArgb(255, Color.Blue)))
     {
         foreach (PointF p in Polygon)
         {
             e.Graphics.FillEllipse(sb, new RectangleF(p.X, p.Y, this.PolygonPointsRadius * 2, this.PolygonPointsRadius * 2));
             //e.Graphics.DrawString(p.ToString(), this.Font, DUIBrushes.Black, p);
         }
     }
     if (hoverPointIndex != -1)
     {
         using (DUISolidBrush sb = new DUISolidBrush(Color.FromArgb(255, Color.Red)))
         {
             if (hoverPointIndex <= this.Polygon.Length - 1)
             {
                 PointF p = this.Polygon[hoverPointIndex];
                 e.Graphics.FillEllipse(sb, new RectangleF(p.X, p.Y, this.PolygonPointsRadius * 2, this.PolygonPointsRadius * 2));
             }
         }
     }
     e.Graphics.SmoothingMode = DUISmoothingMode.Default;
     e.Graphics.TranslateTransform(this.X + this.BorderWidth, this.Y + this.BorderWidth);
 }
Ejemplo n.º 4
0
        public FmDUIScaleableControlDemo()
        {
            InitializeComponent();
            DUIThreadSafeBitmapBrush backMeshBrush = new DUIThreadSafeBitmapBrush(new Size(20, 20), (g, s) =>
            {
                using (DUISolidBrush brushMeshDark = new DUISolidBrush(Color.FromArgb(29, 29, 29)))
                    using (DUISolidBrush brushMeshLight = new DUISolidBrush(Color.FromArgb(159, 159, 159)))
                    {
                        g.FillRectangle(brushMeshDark, new Rectangle(0, 0, 10, 10));
                        g.FillRectangle(brushMeshDark, new Rectangle(10, 10, 10, 10));
                        g.FillRectangle(brushMeshLight, new Rectangle(10, 0, 10, 10));
                        g.FillRectangle(brushMeshLight, new Rectangle(0, 10, 10, 10));
                    }
            });
            DUIImage            dUIImage            = DUIImage.FromFile(@"Resources\1.jpg");
            DUIScaleableControl dUIScaleableControl = new DUIScaleableControl()
            {
                Dock = DockStyle.Fill
            };

            dUIScaleableControl.Paint += (s, e) =>
            {
                backMeshBrush.Draw(e.Graphics, dUIScaleableControl.ScaleableBounds);
                e.Graphics.DrawImage(dUIImage, 0, 0);
            };
            this.duiNativeControl1.DUIControls.Add(dUIScaleableControl);
        }
Ejemplo n.º 5
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);
     //}
 }
Ejemplo n.º 6
0
 public override void OnPaintBackground(DUIPaintEventArgs e)
 {
     base.OnPaintBackground(e);
     using (DUISolidBrush sb = new DUISolidBrush(this.ForeColor))
     {
         e.Graphics.DrawString(Text, this.Font, sb, new Point(0, 0));
     }
 }
Ejemplo n.º 7
0
 public override void DrawCheckState(DUIPaintEventArgs e)
 {
     e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias;
     using (DUISolidBrush brush = new DUISolidBrush(this.owner.CheckBoxColor))
     {
         e.Graphics.FillPolygon(brush, HexagonPath);
     }
 }
Ejemplo n.º 8
0
 public override void DrawCheckState(DUIPaintEventArgs e)
 {
     using (DUISolidBrush brush = new DUISolidBrush(this.owner.CheckBoxColor))
     {
         e.Graphics.FillPolygon(brush, HexagonPath);
     }
     e.Graphics.DrawImage(tickBlackImage, new RectangleF(Bounds.X + 6, Bounds.Y + 6, Bounds.Width - 12, Bounds.Height - 12));
 }
Ejemplo n.º 9
0
        public override void OnPaint(DUIPaintEventArgs e)
        {
            //e.Graphics.FillRectangle(Brushes.Bisque, e.ClipRectangle);
            base.OnPaint(e);
            CurrentCheckState.DrawCheckState(e);
            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(CurrentCheckState.Bounds.Right, this.Height / 2 - sizef.Height / 2 - 2));
            }
        }
Ejemplo n.º 10
0
 public override void OnPaintBackground(DUIPaintEventArgs e)
 {
     base.OnPaintBackground(e);
     using (DUISolidBrush brush = new DUISolidBrush(BackColor))
     {
         e.Graphics.FillRectangle(brush, e.ClipRectangle);
     }
     if (this.Image != null)
     {
         e.Graphics.DrawImage(this.Image, e.ClipRectangle, new Rectangle(0, 0, this.Image.Width, this.Image.Height), GraphicsUnit.Pixel);
     }
 }
Ejemplo n.º 11
0
        protected virtual void DrawTabTitle(DUITabPage tabPage, DUIPaintEventArgs e)
        {
            using (DUISolidBrush sb = new DUISolidBrush(tabPage.Selected ? Color.FromArgb(36, 107, 225) : Color.FromArgb(47, 52, 55)))
            {
                e.Graphics.FillRectangle(sb, new RectangleF(tabPage.TitleX, tabPage.TitleY, this.TabTitleSize.Width, this.TabTitleSize.Height));
            }
            SizeF sizeF = e.Graphics.MeasureString(tabPage.Text, this.Font);

            using (DUISolidBrush brush = new DUISolidBrush(Color.FromArgb(220, 224, 225)))
            {
                e.Graphics.DrawString(tabPage.Text, this.Font, brush, new PointF(tabPage.TitleX + this.TabTitleSize.Width / 2 - sizeF.Width / 2, tabPage.TitleY + this.TabTitleSize.Height / 2 - sizeF.Height / 2));
            }
        }
Ejemplo n.º 12
0
 public override void OnPaint(DUIPaintEventArgs e)
 {
     base.OnPaint(e);
     e.Graphics.TranslateTransform(this.DisplayRectangle.X, this.DisplayRectangle.Y);
     foreach (var displayCube in displayCubes
              .Where(d => !d.Selected)
              .Concat(new DisplayCube[] { this.Selected })
              .Where(d => d != null))
     {
         using (DUISolidBrush brush = new DUISolidBrush(displayCube.BackColor))
         {
             e.Graphics.FillRectangle(brush, displayCube.Bounds);
             e.Graphics.DrawRectangle(DUIPens.Black, displayCube.Bounds);
         }
     }
     e.Graphics.TranslateTransform(-this.DisplayRectangle.X, -this.DisplayRectangle.Y);
 }
Ejemplo n.º 13
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);
     //}
 }
Ejemplo n.º 14
0
        public override void OnPaint(DUIPaintEventArgs e)
        {
            base.OnPaint(e);
            StringFormat format = (StringFormat)StringFormat.GenericTypographic.Clone();

            format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
            foreach (ToolStripItem tsi in this.Items)
            {
                if (tsi.Enabled)
                {
                    Rectangle tsiBounds = GetBounds(tsi);
                    if (isMouseEnter && lastToolStripItem == tsi)
                    {
                        //e.Graphics.DrawRectangle(Pens.Black, new Rectangle(tsiBounds.X, tsiBounds.Y, tsiBounds.Width - 1, this.Height - 1));
                    }
                    using (DUISolidBrush brush = new DUISolidBrush(this.ForeColor))
                    {
                        e.Graphics.DrawString(tsi.Text, this.Font, brush, new PointF(tsiBounds.X + tsiBounds.Width / 2 - this.TextSize(tsi.Text).Width / 2, 0));
                    }
                }
            }
        }
Ejemplo n.º 15
0
 public override void OnPaintBackground(DUIPaintEventArgs e)
 {
     base.OnPaintBackground(e);
     if (this.IsUnknowValue)
     {
         using (DUISolidBrush brush = new DUISolidBrush(this.ProgressBarColor))
         {
             e.Graphics.FillRectangle(brush, AnimateSlider);
         }
     }
     else
     {
         if (this.Maximum == 0)
         {
             return;
         }
         using (DUISolidBrush brush = new DUISolidBrush(this.ProgressBarColor))
         {
             float v = this.Width * this.Value / this.Maximum;
             e.Graphics.FillRectangle(brush, new RectangleF(0, 0, v, this.Height));
         }
     }
 }
Ejemplo n.º 16
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
        }