yangyin
2025-02-24 b3b65a002fe68b1383314098790f5a153b87765f
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
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Extension;
using DPumpHydr.WinFrmUI.RLT.Util;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region LostProgressBar
 
    public class LostProgressBar : ControlLostBase
    {
        private int _progress = 50;
        private Color _color = ThemeLost.AccentBrush.Color;
        private bool _hover = false;
 
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public int Progress
        {
            get => _progress;
            set { _progress = value; Invalidate(); }
        }
 
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public Color Color
        {
            get => _color;
            set { _color = value; Invalidate(); }
        }
 
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool Hover
        {
            get => _hover;
            set { _hover = value; Invalidate(); }
        }
 
        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            pevent.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
 
            if (MouseOver && _hover)
            {
                pevent.Graphics.FillRectangle(new SolidBrush(ThemeLost.ForeColor.Shade(ThemeLost.ShadowSize, 0)), ClientRectangle);
            }
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.DrawRectangle(ThemeLost.FontPen, 1, 1, Width - 2, Height - 2);
            e.Graphics.FillRectangle(new SolidBrush(_color), 5, 5, (Width - 10) * (_progress / 100f), Height - 9);
        }
 
        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            HasShadow = true;
            Parent.Invalidate(ShadeRect(ThemeLost.ShadowSize), false);
            Invalidate();
        }
 
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            HasShadow = false;
            Parent.Invalidate(ShadeRect(ThemeLost.ShadowSize), false);
            Invalidate();
        }
    }
 
    #endregion
}