tangxu
2024-12-24 91105b77c916d06dd30380e20594e29f85eae3da
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
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Util;
using DPumpHydr.WinFrmUI.RLT.Util.FoxBase;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region FoxLinkLabel
 
    public class FoxLinkLabel : ButtonFoxBase
    {
        private Graphics G;
 
        public Color DownColor { get; set; } = FoxLibrary.ColorFromHex("#FF9500");
        public Color OverColor { get; set; } = FoxLibrary.ColorFromHex("#178CE5");
 
        public FoxLinkLabel() : base()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
 
            Size = new(82, 18);
            Font = new("Segoe UI", 10);
            BackColor = Color.Transparent;
            ForeColor = FoxLibrary.ColorFromHex("#0095DD");
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            G = e.Graphics;
            G.SmoothingMode = SmoothingMode.HighQuality;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
 
            //G.Clear(BackColor);
 
            switch (State)
            {
                case FoxLibrary.MouseState.Over:
                    using (SolidBrush TextColor = new(OverColor))
                    {
                        using Font TextFont = new(Font.FontFamily, Font.Size, FontStyle.Underline);
                        G.DrawString(Text, TextFont, TextColor, new Point(0, 0));
                    }
                    break;
                case FoxLibrary.MouseState.Down:
                    using (SolidBrush TextColor = new(DownColor))
                    {
                        G.DrawString(Text, Font, TextColor, new Point(0, 0));
                    }
 
                    break;
                default:
                    using (SolidBrush TextColor = new(ForeColor))
                    {
                        G.DrawString(Text, Font, TextColor, new Point(0, 0));
                    }
 
                    break;
            }
 
            base.OnPaint(e);
        }
 
    }
 
    #endregion
}