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
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
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Util;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region FoxBigLabel
 
    public class FoxBigLabel : Control
    {
        private Graphics G;
 
        public Color LineColor { get; set; } = FoxLibrary.ColorFromHex("#C8C8C8");
 
        public Direction Line { get; set; } = Direction.Bottom;
 
        public enum Direction
        {
            Top,
            Bottom
        }
 
        public FoxBigLabel()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
 
            ForeColor = FoxLibrary.ColorFromHex("#4C5864");
            Font = new("Segoe UI Semibold", 20);
            BackColor = Color.Transparent;
            DoubleBuffered = true;
            Size = new(165, 41);
        }
 
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            //Size = new(Width, 51);
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            G = e.Graphics;
            G.SmoothingMode = SmoothingMode.HighQuality;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
 
            //G.Clear(BackColor);
 
            using (SolidBrush HColor = new(ForeColor))
            {
                G.DrawString(Text, Font, HColor, new Point(0, 0));
            }
 
            using (Pen BottomLine = new(LineColor))
            {
                if (Line == Direction.Bottom)
                {
                    G.DrawLine(BottomLine, new Point(0, Height - 1), new Point(Width, Height - 1));
                }
                else
                {
                    G.DrawLine(BottomLine, new Point(0, 0), new Point(Width, 0));
                }
            }
 
            base.OnPaint(e);
 
        }
 
    }
 
    #endregion
}