tangxu
2024-10-22 7a0d1efa4784d176a32f182ecae671711e98ca92
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Colors;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Util
{
    #region ForeverUtil
 
    public static class ForeverLibrary
    {
        public static Color ForeverColor = Color.FromArgb(35, 168, 109);
 
        public static readonly StringFormat NearSF = new()
        {
            Alignment = StringAlignment.Near,
            LineAlignment = StringAlignment.Near
        };
 
        public static readonly StringFormat CenterSF = new()
        {
            Alignment = StringAlignment.Center,
            LineAlignment = StringAlignment.Center
        };
 
        public static GraphicsPath RoundRec(Rectangle Rectangle, int Curve)
        {
            GraphicsPath P = new();
            int ArcRectangleWidth = Curve * 2;
            P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
            P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
            P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
            P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
            P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
            return P;
        }
 
        public static GraphicsPath RoundRect(float x, float y, float w, float h, double r = 0.3, bool TL = true, bool TR = true, bool BR = true, bool BL = true)
        {
            float d = Math.Min(w, h) * (float)r;
            float xw = x + w;
            float yh = y + h;
            GraphicsPath functionReturnValue = new();
 
            GraphicsPath _with1 = functionReturnValue;
            if (TL)
            {
                _with1.AddArc(x, y, d, d, 180, 90);
            }
            else
            {
                _with1.AddLine(x, y, x, y);
            }
 
            if (TR)
            {
                _with1.AddArc(xw - d, y, d, d, 270, 90);
            }
            else
            {
                _with1.AddLine(xw, y, xw, y);
            }
 
            if (BR)
            {
                _with1.AddArc(xw - d, yh - d, d, d, 0, 90);
            }
            else
            {
                _with1.AddLine(xw, yh, xw, yh);
            }
 
            if (BL)
            {
                _with1.AddArc(x, yh - d, d, d, 90, 90);
            }
            else
            {
                _with1.AddLine(x, yh, x, yh);
            }
 
            _with1.CloseFigure();
            return functionReturnValue;
        }
 
        public static GraphicsPath DrawArrow(int x, int y, bool flip)
        {
            GraphicsPath GP = new();
 
            int W = 12;
            int H = 6;
 
            if (flip)
            {
                GP.AddLine(x + 1, y, x + W + 1, y);
                GP.AddLine(x + W, y, x + H, y + H - 1);
            }
            else
            {
                GP.AddLine(x, y + H, x + W, y + H);
                GP.AddLine(x + W, y + H, x + H, y);
            }
 
            GP.CloseFigure();
            return GP;
        }
 
        public static ForeverColors GetColors(Control control)
        {
            if (control == null)
            {
                throw new ArgumentNullException();
            }
 
            ForeverColors colors = new();
 
            while (control != null && (control.GetType() != typeof(Forms.ForeverForm)))
            {
                control = control.Parent;
            }
 
            if (control != null)
            {
                Forms.ForeverForm skin = (Forms.ForeverForm)control;
                colors.Forever = skin.ForeverColor;
            }
 
            return colors;
        }
    }
 
    public enum MouseStateForever : byte
    {
        None = 0,
        Over = 1,
        Down = 2,
        Block = 3
    }
 
    #endregion
}