tangxu
2024-12-16 23fadc9cb0c09b665a1bbcef7eaf16f916045dc4
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
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Util;
using System.Drawing;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region SpaceLabel
 
    public class SpaceLabel : SpaceControl // Create a Custom Label
    {
        private HorizontalAlignment _TextAlignment = HorizontalAlignment.Center;
 
        public HorizontalAlignment TextAlignment
        {
            get => _TextAlignment;
            set
            {
                _TextAlignment = value;
                Invalidate();
            }
        }
 
        public SpaceLabel()
        { // Create a Label
            SetColor("Text", 254, 254, 254); // Text Color for Label
            SetColor("Background", 42, 42, 42); // Background Color
            Size = new(75, 40);
        }
 
        private Color C1; // used for the Basic Background of the Label
        private SolidBrush B1; // The Main Color of the Text, Is painted on with a brush
 
        protected override void ColorHook()
        { // Assigning the colors to variables
            C1 = GetColor("Background"); // Get the Background Color
            B1 = new(GetColor("Text")); // Set up Color for the Text
        }
 
        protected override void PaintHook()
        {
            G.Clear(C1); // Clear the Color of Background
            DrawText(B1, TextAlignment, 0, 0); // Align Text In Center of Label
        }
    }
 
    #endregion
}