2 using System.Drawing.Drawing2D;
6 using Syncfusion.Windows.Forms.Tools;
29 public void DrawButton(PaintEventArgs e, ToggleButtonState toggleState, DisplayType displayMode, Font font, ActiveStateCollection activeState, InactiveStateCollection inactiveState, RightToLeft righttoLeft,
bool isMouseHover, ToggleButton toggleButton)
32 SizeF textSize = e.Graphics.MeasureString(displayText, font);
33 Rectangle controlRect =
new Rectangle(e.ClipRectangle.X + 1, e.ClipRectangle.Y + 1, e.ClipRectangle.Width - 4, e.ClipRectangle.Height - 4);
34 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
35 GraphicsPath gp =
new GraphicsPath();
37 if (controlRect.Height > 1)
39 gp.AddArc(controlRect.X, controlRect.Y, controlRect.Height, controlRect.Height, 180, 90);
40 gp.AddArc(controlRect.X + controlRect.Width - controlRect.Height, controlRect.Y, controlRect.Height,
41 controlRect.Height, 270, 90);
42 gp.AddArc(controlRect.X + controlRect.Width - controlRect.Height,
43 controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height, controlRect.Height, 0,
45 gp.AddArc(controlRect.X, controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height,
46 controlRect.Height, 90, 90);
48 e.Graphics.DrawPath(
new Pen(Color.Tan, 2), gp);
50 GraphicsPath gp1 =
new GraphicsPath();
51 using (LinearGradientBrush br =
new LinearGradientBrush(e.ClipRectangle, Color.Tan, Color.PapayaWhip, LinearGradientMode.Vertical))
53 if (controlRect.Height > 1)
55 gp1.AddArc(controlRect.X, controlRect.Y + 1, controlRect.Height + 2, controlRect.Height, 180, 90);
56 gp1.AddArc(controlRect.X + controlRect.Width - controlRect.Height, controlRect.Y, controlRect.Height, controlRect.Height, 270, 90);
57 gp1.AddArc(controlRect.X + 1 + controlRect.Width - controlRect.Height, controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height, controlRect.Height, 0, 90);
58 gp1.AddArc(controlRect.X, controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height, controlRect.Height, 90, 90);
60 e.Graphics.FillPath(br, gp1);
65 using (SolidBrush br =
new SolidBrush(Color.PapayaWhip))
67 e.Graphics.FillPath(br, gp);
69 PointF pt1 =
new PointF(e.ClipRectangle.X + e.ClipRectangle.Width / 2 - textSize.Width / 2, e.ClipRectangle.Y + e.ClipRectangle.Height / 2 - textSize.Height / 2);
70 using (SolidBrush br =
new SolidBrush(Color.Black))
72 if (displayMode == DisplayType.Text)
73 e.Graphics.DrawString(displayText, font, br, pt1);
90 public void DrawSlider(PaintEventArgs e, Point p, ToggleButtonState toggleState, SliderCollection slider, Font font, RightToLeft righttoLeft,
bool isMouseMove,
bool isMouseHover)
92 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
93 Rectangle sliderRectangle;
96 sliderRectangle = toggleState == ToggleButtonState.Inactive ?
new Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Height - 1, e.ClipRectangle.Height - 1) :
new Rectangle(e.ClipRectangle.X + e.ClipRectangle.Width - e.ClipRectangle.Height, e.ClipRectangle.Y, e.ClipRectangle.Height - 1, e.ClipRectangle.Height - 1);
99 sliderRectangle =
new Rectangle(p.X, e.ClipRectangle.Y, e.ClipRectangle.Height - 1, e.ClipRectangle.Height - 1);
102 using (SolidBrush br =
new SolidBrush(slider.BackColor))
104 e.Graphics.FillEllipse(br, sliderRectangle);
105 using (Pen pn =
new Pen(Color.Gray, 2))
106 e.Graphics.DrawEllipse(pn, sliderRectangle);
111 using (SolidBrush br =
new SolidBrush(slider.BackColor))
113 e.Graphics.FillEllipse(br, sliderRectangle);
114 e.Graphics.DrawEllipse(Pens.Gray, sliderRectangle);
Class for creating a singleton for a generic class
static T Instance
Gets the instance.