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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#region Imports
 
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region NightPanel
 
    public class NightPanel : System.Windows.Forms.Panel
    {
        #region Enum
 
        public enum PanelSide
        {
            Left,
            Right
        }
 
        #endregion
 
        #region Properties
 
        [Browsable(false)]
        [Description("The background color of the component.")]
        public override Color BackColor { get; set; }
 
        private PanelSide _Side = PanelSide.Left;
        public PanelSide Side
        {
            get => _Side;
            set
            {
                _Side = value;
                if (_Side == PanelSide.Left)
                {
                    BackColor = LeftSideColor;
                }
                else
                {
                    BackColor = RightSideColor;
                }
 
                Invalidate();
            }
        }
 
        private Color _LeftSideColor = ColorTranslator.FromHtml("#F25D59");
        public Color LeftSideColor
        {
            get => _LeftSideColor;
            set
            {
                _LeftSideColor = value;
                Invalidate();
            }
        }
 
        private Color _RightSideColor = ColorTranslator.FromHtml("#292C3D");
        public Color RightSideColor
        {
            get => _RightSideColor;
            set
            {
                _RightSideColor = value;
                Invalidate();
            }
        }
 
        #endregion
 
        protected override void OnClick(EventArgs e)
        {
            Focus();
            base.OnClick(e);
        }
 
        public NightPanel()
        {
            DoubleBuffered = true;
 
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
 
            UpdateStyles();
 
            ForeColor = ColorTranslator.FromHtml("#FAFAFA");
            BackColor = RightSideColor;
 
            BorderStyle = BorderStyle.None;
        }
    }
 
    #endregion
}