1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
| #region Imports
|
| using System;
| using System.Drawing;
| using System.Drawing.Drawing2D;
| using System.Globalization;
|
| #endregion
|
| namespace DPumpHydr.WinFrmUI.RLT.Util
| {
| #region AloneUtil
|
| public sealed class AloneLibrary
| {
| public enum RoundingStyle : byte
| {
| All,
| Top,
| Bottom,
| Left,
| Right,
| TopRight,
| BottomRight
| }
|
| public static void CenterString(Graphics G, string T, Font F, Color C, Rectangle R)
| {
| SizeF sizeF = G.MeasureString(T, F);
| using SolidBrush solidBrush = new(C);
| G.DrawString(T, F, solidBrush, checked(new Point((int)Math.Round(unchecked((R.Width / 2.0) - (double)(sizeF.Width / 2f))), (int)Math.Round(unchecked((R.Height / 2.0) - (double)(sizeF.Height / 2f))))));
| }
|
| public static Color ColorFromHex(string Hex)
| {
| return Color.FromArgb(checked((int)long.Parse(string.Format("FFFFFFFFFF{0}", Hex.Substring(1)), NumberStyles.HexNumber)));
| }
|
| public static Rectangle FullRectangle(Size S, bool Subtract)
| {
| Rectangle result;
| if (Subtract)
| {
| result = checked(new Rectangle(0, 0, S.Width - 1, S.Height - 1));
| }
| else
| {
| result = new(0, 0, S.Width, S.Height);
| }
|
| return result;
| }
|
| public static GraphicsPath RoundRect(Rectangle Rect, int Rounding, RoundingStyle Style = RoundingStyle.All)
| {
| GraphicsPath graphicsPath = new();
| checked
| {
| int num = Rounding * 2;
| graphicsPath.StartFigure();
| bool flag = Rounding == 0;
| GraphicsPath result;
| if (flag)
| {
| graphicsPath.AddRectangle(Rect);
| graphicsPath.CloseAllFigures();
| result = graphicsPath;
| }
| else
| {
| switch (Style)
| {
| case RoundingStyle.All:
| graphicsPath.AddArc(new Rectangle(Rect.X, Rect.Y, num, num), -180f, 90f);
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Y, num, num), -90f, 90f);
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Height - num + Rect.Y, num, num), 0f, 90f);
| graphicsPath.AddArc(new Rectangle(Rect.X, Rect.Height - num + Rect.Y, num, num), 90f, 90f);
| break;
| case RoundingStyle.Top:
| graphicsPath.AddArc(new Rectangle(Rect.X, Rect.Y, num, num), -180f, 90f);
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Y, num, num), -90f, 90f);
| graphicsPath.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
| break;
| case RoundingStyle.Bottom:
| graphicsPath.AddLine(new Point(Rect.X, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Height - num + Rect.Y, num, num), 0f, 90f);
| graphicsPath.AddArc(new Rectangle(Rect.X, Rect.Height - num + Rect.Y, num, num), 90f, 90f);
| break;
| case RoundingStyle.Left:
| graphicsPath.AddArc(new Rectangle(Rect.X, Rect.Y, num, num), -180f, 90f);
| graphicsPath.AddLine(new Point(Rect.X + Rect.Width, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
| graphicsPath.AddArc(new Rectangle(Rect.X, Rect.Height - num + Rect.Y, num, num), 90f, 90f);
| break;
| case RoundingStyle.Right:
| graphicsPath.AddLine(new Point(Rect.X, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y));
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Y, num, num), -90f, 90f);
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Height - num + Rect.Y, num, num), 0f, 90f);
| break;
| case RoundingStyle.TopRight:
| graphicsPath.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Y, num, num), -90f, 90f);
| graphicsPath.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height - 1), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
| graphicsPath.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
| break;
| case RoundingStyle.BottomRight:
| graphicsPath.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
| graphicsPath.AddLine(new Point(Rect.X + Rect.Width - 1, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
| graphicsPath.AddArc(new Rectangle(Rect.Width - num + Rect.X, Rect.Height - num + Rect.Y, num, num), 0f, 90f);
| graphicsPath.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
| break;
| }
| graphicsPath.CloseAllFigures();
| result = graphicsPath;
| }
| return result;
| }
| }
| }
|
| #endregion
| }
|
|