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); //} }
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); }
protected virtual void OnBorderPaint(DUIPaintEventArgs e) { using (SolidBrush borderColorBrush = new SolidBrush(this.Owner.BorderColor == Color.Transparent ? this.Owner.BackColor : this.Owner.BorderColor)) { e.Graphics.FillRectangle(borderColorBrush, e.ClipRectangle); } }
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); } } }
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)); } }
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)); }
public override void DrawCheckState(DUIPaintEventArgs e) { e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias; using (DUISolidBrush brush = new DUISolidBrush(this.owner.CheckBoxColor)) { e.Graphics.FillPolygon(brush, HexagonPath); } }
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)); } }
public override void OnPaintBackground(DUIPaintEventArgs e) { base.OnPaintBackground(e); this.owner.DrawTabTitle(e); foreach (DUITabPage tabPage in this.owner.TabPages) { this.owner.DrawTabTitle(tabPage, e); } }
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)); } }
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)); } }
internal override void DoPaint(DUIPaintEventArgs e) { #region OnPaintBackground var backupSmoothingMode = e.Graphics.SmoothingMode; var backupTextRenderingHint = e.Graphics.TextRenderingHint; var backupTransform = e.Graphics.Transform; OnPaintBackground(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, this.Width, this.Height))); //绘制背景 e.Graphics.Transform = backupTransform; e.Graphics.TextRenderingHint = backupTextRenderingHint; e.Graphics.SmoothingMode = backupSmoothingMode; #endregion #region OnPaint backupSmoothingMode = e.Graphics.SmoothingMode; backupTextRenderingHint = e.Graphics.TextRenderingHint; backupTransform = e.Graphics.Transform; OnPaint(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, ClientSize.Width, this.ClientSize.Height))); //先让子类画图 e.Graphics.Transform = backupTransform; e.Graphics.TextRenderingHint = backupTextRenderingHint; e.Graphics.SmoothingMode = backupSmoothingMode; #endregion #region 子控件 List <DUIControl> dUIControls = new List <DUIControl>(); List <DUIControl> dUITopMostControls = new List <DUIControl>(); foreach (DUIControl d in this.DUIControls) { if (d.Visible && !this.IsOutOfArea(d)) { if (d.TopMost) { dUITopMostControls.Add(d); } else { dUIControls.Add(d); } } } dUITopMostControls.ForEach(t => { dUIControls.Add(t); }); foreach (DUIControl dUIControl in dUIControls) { dUIControl.DoPaint(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, dUIControl.Width, dUIControl.Height))); } #endregion #region OnPaintForeground backupSmoothingMode = e.Graphics.SmoothingMode; backupTextRenderingHint = e.Graphics.TextRenderingHint; backupTransform = e.Graphics.Transform; OnPaintForeground(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, this.Width, this.Height))); //先让子类画图 e.Graphics.Transform = backupTransform; e.Graphics.TextRenderingHint = backupTextRenderingHint; e.Graphics.SmoothingMode = backupSmoothingMode; #endregion }
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); } }
public virtual void DrawSliderBody(DUIPaintEventArgs e) { e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias; if (DUIControl.MouseButtons != System.Windows.Forms.MouseButtons.None && this.sliderBody.isMouseDown) { e.Graphics.FillEllipse(DUIBrushes.PowderBlue, new RectangleF(0, 0, this.sliderBody.Width, this.sliderBody.Height)); } else { e.Graphics.FillEllipse(DUIBrushes.White, new RectangleF(0, 0, this.sliderBody.Width, this.sliderBody.Height)); } e.Graphics.DrawEllipse(DUIPens.Black, new RectangleF(0, 0, this.sliderBody.Width, this.sliderBody.Height)); }
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)); } }
public override void OnPaintBackground(DUIPaintEventArgs e) { base.OnPaintBackground(e); brush.Color = this.ForeColor; float partWidth = this.DividingInterval * 10; e.Graphics.TranslateTransform(this.DividingStartSpace % partWidth, 0); this.DividingBrush.Draw(e.Graphics, new RectangleF(-partWidth, 0, this.ClientSize.Width + 2 * partWidth, this.ClientSize.Height)); e.Graphics.TranslateTransform(this.WordStartSpace, 0); for (int i = 0; i < this.Width / partWidth + 1; i++) { e.Graphics.DrawString(DividingFormat(-this.DividingStartSpace / partWidth + i), this.Font, brush, new PointF(i * partWidth - DividingWidth(-this.DividingStartSpace / partWidth + i) / 2, this.ClientSize.Height - 3 * DividingHeight - 14)); } e.Graphics.TranslateTransform(-this.WordStartSpace, 0); e.Graphics.TranslateTransform(-this.DividingStartSpace % partWidth, 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); //} }
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); }
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); }
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)); } } } }
public override void OnPaint(DUIPaintEventArgs e) { //e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias; if (this.Image != null) { float cw = e.ClipRectangle.Width; float ch = e.ClipRectangle.Height; float iw = this.Image.Width; float ih = this.Image.Height; if (this.Image.Width > this.Image.Height) { iw = cw; ih = (float)this.Image.Height * iw / (float)this.Image.Width; } else { ih = ch; iw = (float)this.Image.Width * ih / (float)this.Image.Height; } e.Graphics.DrawImage(this.Image, new RectangleF(0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height), new RectangleF(0, 0, this.Image.Width, this.Image.Height), GraphicsUnit.Pixel); } base.OnPaint(e); }
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)); } } }
public override void OnPaintForeground(DUIPaintEventArgs e) { this.owner.OnPaintForeground(e); }
public override void OnPaint(DUIPaintEventArgs e) { e.Graphics.SmoothingMode = DUISmoothingMode.AntiAlias; e.Graphics.FillEllipse(DUIBrushes.Black, new RectangleF(0, 0, this.ThisRadius * 2, this.ThisRadius * 2)); e.Graphics.FillEllipse(DUIBrushes.White, new RectangleF(this.ThisRadius / 3, this.ThisRadius / 3, this.ThisRadius * 2 * 2 / 3, this.ThisRadius * 2 * 2 / 3)); }
protected override void DrawBounds(DUIPaintEventArgs e) { //base.DrawBounds(e); }
protected override void DrawVertex(DUIPaintEventArgs e) { //base.DrawVertex(e); }
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 }
internal override void DoPaint(DUIPaintEventArgs e) { e.Graphics.TranslateTransform(this.X, this.Y); //偏移一下坐标系将控件的坐标定义为坐标系原点 e.Graphics.PushLayer(this.Width, this.Height); //背景图层 PointF center = new PointF(this.BorderWidth + this.CenterX, this.BorderWidth + this.CenterY); e.Graphics.RotateTransform(this.Rotate, center.X, center.Y); e.Graphics.TranslateTransform(this.Center.X, this.Center.Y); e.Graphics.ScaleTransform(this.scaling, this.scaling); var backupSmoothingMode = e.Graphics.SmoothingMode; var backupTextRenderingHint = e.Graphics.TextRenderingHint; var backupTransform = e.Graphics.Transform; OnPaintBackground(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, this.Width, this.Height))); //绘制背景 e.Graphics.Transform = backupTransform; e.Graphics.TextRenderingHint = backupTextRenderingHint; e.Graphics.SmoothingMode = backupSmoothingMode; e.Graphics.ScaleTransform(1 / this.scaling, 1 / this.scaling); e.Graphics.TranslateTransform(-this.Center.X, -this.Center.Y); if (this.BorderWidth != 0) { e.Graphics.PopLayer(); e.Graphics.TranslateTransform(this.BorderWidth, this.BorderWidth); //偏移一个边框的坐标系 e.Graphics.PushLayer(this.ClientSize.Width, this.ClientSize.Height); //背景图层 } e.Graphics.TranslateTransform(this.Center.X, this.Center.Y); e.Graphics.ScaleTransform(this.scaling, this.scaling); backupSmoothingMode = e.Graphics.SmoothingMode; backupTextRenderingHint = e.Graphics.TextRenderingHint; backupTransform = e.Graphics.Transform; OnPaint(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, this.ClientSize.Width, this.ClientSize.Height))); //先让子类画图 e.Graphics.Transform = backupTransform; e.Graphics.TextRenderingHint = backupTextRenderingHint; e.Graphics.SmoothingMode = backupSmoothingMode; List <DUIControl> dUIControls = new List <DUIControl>(); List <DUIControl> dUITopMostControls = new List <DUIControl>(); foreach (DUIControl d in this.DUIControls) { if (d.Visible && !this.IsOutOfArea(d)) { if (d.TopMost) { dUITopMostControls.Add(d); } else { dUIControls.Add(d); } } } dUITopMostControls.ForEach(t => { dUIControls.Add(t); }); foreach (DUIControl dUIControl in dUIControls) { dUIControl.DoPaint(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, dUIControl.Width, dUIControl.Height))); } e.Graphics.TranslateTransform(-this.BorderWidth, -this.BorderWidth); e.Graphics.PopLayer(); backupSmoothingMode = e.Graphics.SmoothingMode; backupTextRenderingHint = e.Graphics.TextRenderingHint; backupTransform = e.Graphics.Transform; OnPaintForeground(new DUIPaintEventArgs(e.Graphics, new RectangleF(0, 0, this.Width, this.Height))); //先让子类画图 e.Graphics.Transform = backupTransform; e.Graphics.TextRenderingHint = backupTextRenderingHint; e.Graphics.SmoothingMode = backupSmoothingMode; e.Graphics.ScaleTransform(1 / this.scaling, 1 / this.scaling); e.Graphics.TranslateTransform(-this.Center.X, -this.Center.Y); e.Graphics.RotateTransform(-this.Rotate, this.BorderWidth + this.CenterX, this.BorderWidth + this.CenterY); //设置旋转中心点 e.Graphics.TranslateTransform(-this.X, -this.Y); //偏移一下坐标系将控件的坐标定义为坐标系原点 }
public abstract void DrawCheckState(DUIPaintEventArgs e);