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
#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 AirForm
 
    public class AirForm : AirLibrary
    {
        public AirForm()
        {
            TransparencyKey = Color.Fuchsia;
            StartPosition = FormStartPosition.CenterScreen;
            BackColor = Color.White;
            Font = new("Segoe UI", 9);
            SetColor("Title color", Color.Black);
            SetColor("X-color", 90, 90, 90);
            SetColor("X-ellipse", 114, 114, 114);
            MinimumSize = new(112, 35);
        }
 
        private Color TitleColor;
        private Color Xcolor;
        private Color Xellipse;
        protected override void ColorHook()
        {
            TitleColor = GetColor("Title color");
            Xcolor = GetColor("X-color");
            Xellipse = GetColor("X-ellipse");
        }
 
        private int X;
        private int Y;
        protected override void OnMouseMove(MouseEventArgs e)
        {
            X = e.Location.X;
            Y = e.Location.Y;
            base.OnMouseMove(e);
            Invalidate();
        }
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnClick(e);
            Rectangle r = new(Width - 22, 5, 15, 15);
            if (r.Contains(new Point(e.X, e.Y)) || (r.Contains(new Point(X, Y)) && e.Button == MouseButtons.Left))
            {
                FindForm().Close();
            }
        }
 
        protected override void PaintHook()
        {
            G.Clear(BackColor);
            DrawCorners(Color.Fuchsia);
            DrawCorners(Color.Fuchsia, 1, 0, Width - 2, Height);
            DrawCorners(Color.Fuchsia, 0, 1, Width, Height - 2);
            DrawCorners(Color.Fuchsia, 2, 0, Width - 4, Height);
            DrawCorners(Color.Fuchsia, 0, 2, Width, Height - 4);
 
            G.SmoothingMode = SmoothingMode.HighQuality;
            if (new Rectangle(Width - 22, 5, 15, 15).Contains(new Point(X, Y)))
            {
                G.FillEllipse(new SolidBrush(Xellipse), new Rectangle(Width - 24, 6, 16, 16));
                G.DrawString("r", new Font("Webdings", 8), new SolidBrush(BackColor), new Point(Width - 23, 5));
            }
            else
            {
                G.DrawString("r", new Font("Webdings", 8), new SolidBrush(Xcolor), new Point(Width - 23, 5));
            }
 
            DrawText(new SolidBrush(TitleColor), new Point(8, 7));
        }
    }
 
    #endregion
}