tangxu
2024-11-04 ebd031e3bed6c1cfddce8fc9b98f7f9e95fb9e32
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
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Extension;
using DPumpHydr.WinFrmUI.RLT.Util;
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region LostPanel
 
    [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
    public class LostPanel : ControlLostBase
    {
 
        #region Properties
 
        private bool _ShowText = true;
        public bool ShowText
        {
            get => _ShowText;
            set
            {
                _ShowText = value;
                Invalidate();
            }
        }
 
        #endregion
 
        public LostPanel()
        {
            DoubleBuffered = true;
            Size = new(222, 111);
            Font = ThemeLost.TitleFont;
            BackColor = ThemeLost.ForeBrush.Color;
            ForeColor = ThemeLost.FontBrush.Color;
            Padding = new Padding(5);
        }
 
        public override void DrawShadow(Graphics g)
        {
            for (int i = 0; i < ThemeLost.ShadowSize; i++)
            {
                g.DrawRectangle(new(ThemeLost.ShadowColor.Shade(ThemeLost.ShadowSize, i)), ShadeRect(i));
            }
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
 
            if (_ShowText)
            {
                e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), 2, 2);
            }
 
            foreach (Control c in Controls)
            {
                if (c is ControlLostBase)
                {
                    (c as ControlLostBase).DrawShadow(e.Graphics);
                }
            }
 
            base.OnPaint(e);
        }
 
        protected override void OnMouseEnter(EventArgs e)
        {
            //return;
        }
 
        protected override void OnMouseLeave(EventArgs e)
        {
            //return;
            foreach (Control c in Controls)
            {
                if (c is ControlLostBase && (c as ControlLostBase).ShadowLevel != 0)
                {
                    (c as ControlLostBase).Invalidate();
                }
            }
        }
    }
 
    #endregion
}