chenn
2025-04-11 e98de937b28d42493de5dea6365c853d6b412d3c
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
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Util;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Forms
{
    #region MoonForm
 
    public class MoonForm : MoonLibrary
    {
        private Color G1;
        private Color G2;
        private Color BG;
 
        private Color _TitleColor = Color.Black;
        public Color TitleColor
        {
            get => _TitleColor;
            set
            {
                _TitleColor = value;
                Invalidate();
            }
        }
 
        private Color _BorderColor = Color.LightGray;
        public Color BorderColor
        {
            get => _BorderColor;
            set
            {
                _BorderColor = value;
                Invalidate();
            }
        }
 
        private Color _FirstEdge = Color.LightGray;
        public Color FirstEdge
        {
            get => _FirstEdge;
            set
            {
                _FirstEdge = value;
                Invalidate();
            }
        }
 
        private Color _SecondEdge = Color.White;
        public Color SecondEdge
        {
            get => _SecondEdge;
            set
            {
                _SecondEdge = value;
                Invalidate();
            }
        }
 
        public MoonForm()
        {
            TransparencyKey = Color.Fuchsia;
            SetColor("G1", Color.White);
            SetColor("G2", Color.LightGray);
            SetColor("BG", Color.FromArgb(240, 240, 240));
            StartPosition = FormStartPosition.CenterScreen;
            Padding = new Padding(0, 0, 0, 0);
            Font = new("Segoe UI", 9);
            ForeColor = Color.Gray;
            TitleColor = _TitleColor;
            MinimumSize = new(100, 50);
        }
 
        protected override void ColorHook()
        {
            G1 = GetColor("G1");
            G2 = GetColor("G2");
            BG = GetColor("BG");
        }
 
        protected override void PaintHook()
        {
            G.Clear(BG);
 
            LinearGradientBrush LGB = new(new Rectangle(new Point(1, 1), new Size(Width - 2, 23)), G1, G2, 90f);
            G.FillRectangle(LGB, new Rectangle(new Point(1, 1), new Size(Width - 2, 23)));
 
            G.DrawLine(new(new SolidBrush(FirstEdge)), 1, 25, Width - 2, 25);
            G.DrawLine(new(new SolidBrush(SecondEdge)), 1, 26, Width - 2, 26);
 
            DrawCorners(TransparencyKey);
            DrawBorders(new(new SolidBrush(BorderColor)), 1);
 
            Rectangle IconRec = new(3, 3, 20, 20);
            G.DrawIcon(ParentForm.Icon, IconRec);
 
            G.DrawString(ParentForm.Text, Font, new SolidBrush(TitleColor), new Point(25, 5));
        }
    }
 
    #endregion
}