tangxu
2025-02-10 e40718947b5aa9205c87a7478aa86c37a82e0510
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Util;
using DPumpHydr.WinFrmUI.RLT.Util.FoxBase;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region FoxNotification
 
    public class FoxNotification : NotifyFoxBase
    {
        public FoxNotification() : base()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
 
            Size = new(130, 40);
            Font = new("Segoe UI", 10);
            BackColor = Color.Transparent;
        }
 
        public Styles Style { get; set; }
 
        private Graphics G;
 
        private Color Background;
        private Color TextColor;
        private Color LeftBar;
 
        public Color GreenBackColor { get; set; } = FoxLibrary.ColorFromHex("#DFF0D6");
        public Color GreenTextColor { get; set; } = FoxLibrary.ColorFromHex("#4E8C45");
        public Color GreenBarColor { get; set; } = FoxLibrary.ColorFromHex("#CEE5B6");
        public Color BlueBackColor { get; set; } = FoxLibrary.ColorFromHex("#D9EDF8");
        public Color BlueTextColor { get; set; } = FoxLibrary.ColorFromHex("#498FB8");
        public Color BlueBarColor { get; set; } = FoxLibrary.ColorFromHex("#AFD9F0");
        public Color YellowBackColor { get; set; } = FoxLibrary.ColorFromHex("#FCF8E1");
        public Color YellowTextColor { get; set; } = FoxLibrary.ColorFromHex("#908358");
        public Color YellowBarColor { get; set; } = FoxLibrary.ColorFromHex("#FAEBC8");
        public Color RedBackColor { get; set; } = FoxLibrary.ColorFromHex("#F2DEDE");
        public Color RedTextColor { get; set; } = FoxLibrary.ColorFromHex("#C2635E");
        public Color RedBarColor { get; set; } = FoxLibrary.ColorFromHex("#EBCCD1");
 
        public enum Styles : byte
        {
            Green = 0,
            Blue = 1,
            Yellow = 2,
            Red = 3
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            G = e.Graphics;
            G.SmoothingMode = SmoothingMode.HighQuality;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
 
            //G.Clear(BackColor);
 
            switch (Style)
            {
                case Styles.Green:
                    Background = GreenBackColor;
                    TextColor = GreenTextColor;
                    LeftBar = GreenBarColor;
                    break;
                case Styles.Blue:
                    Background = BlueBackColor;
                    TextColor = BlueTextColor;
                    LeftBar = BlueBarColor;
                    break;
                case Styles.Yellow:
                    Background = YellowBackColor;
                    TextColor = YellowTextColor;
                    LeftBar = YellowBarColor;
                    break;
                case Styles.Red:
                    Background = RedBackColor;
                    TextColor = RedTextColor;
                    LeftBar = RedBarColor;
                    break;
            }
 
            using (SolidBrush Back = new(Background))
            {
                using SolidBrush TC = new(TextColor);
                using SolidBrush LB = new(LeftBar);
 
                G.FillRectangle(Back, FoxLibrary.FullRectangle(Size, true));
                G.SmoothingMode = SmoothingMode.None;
 
                G.FillRectangle(LB, new Rectangle(1, 1, 6, Height - 2));
                G.SmoothingMode = SmoothingMode.HighQuality;
 
                G.DrawString(Text, Font, TC, new Point(20, 11));
            }
 
            base.OnPaint(e);
        }
 
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            Size = new(Width, 40);
        }
    }
 
    #endregion
}