yangyin
2024-10-22 90573e299e2eea301a0ad8585a7e6b95d7a798bb
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
#region Imports
 
using System.Drawing;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region MoonTextBox
 
    public class MoonTextBox : System.Windows.Forms.TextBox
    {
        private Color _BorderColor = Color.LightGray;
        public Color BorderColor
        {
            get => _BorderColor;
            set
            {
                _BorderColor = value;
                Invalidate();
            }
        }
 
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case 15:
                    Invalidate();
                    base.WndProc(ref m);
                    CustomPaint();
                    break; // TODO: might not be correct. Was : Exit Select
                default:
                    base.WndProc(ref m);
                    break; // TODO: might not be correct. Was : Exit Select
            }
        }
 
        public MoonTextBox()
        {
            Font = new("Microsoft Sans Serif", 8);
            ForeColor = Color.Gray;
            BackColor = Color.FromArgb(235, 235, 235);
            BorderStyle = BorderStyle.FixedSingle;
            Size = new(76, 20);
        }
 
        private void CustomPaint()
        {
            Pen p = new(new SolidBrush(BorderColor));
            CreateGraphics().DrawLine(p, 0, 0, Width, 0);
            CreateGraphics().DrawLine(p, 0, Height - 1, Width, Height - 1);
            CreateGraphics().DrawLine(p, 0, 0, 0, Height - 1);
            CreateGraphics().DrawLine(p, Width - 1, 0, Width - 1, Height - 1);
        }
    }
 
    #endregion
}