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
| #region Imports
|
| using System.Drawing;
| using System.Drawing.Drawing2D;
| using System.Windows.Forms;
|
| #endregion
|
| namespace DPumpHydr.WinFrmUI.RLT.Controls
| {
| #region DreamProgressBar
|
| public class DreamProgressBar : ProgressBar
| {
| private int _Value;
| public int Value
| {
| get => _Value;
| set
| {
| _Value = value;
| Invalidate();
| }
| }
|
| private int _Maximum = 100;
| public int Maximum
| {
| get => _Maximum;
| set
| {
| if (value == 0)
| {
| value = 1;
| }
|
| _Maximum = value;
| Invalidate();
| }
| }
|
| public DreamProgressBar()
| {
| Value = 50;
| }
|
| public Color ColorA { get; set; } = Color.FromArgb(31, 31, 31);
| public Color ColorB { get; set; } = Color.FromArgb(41, 41, 41);
| public Color ColorC { get; set; } = Color.FromArgb(51, 51, 51);
| public Color ColorD { get; set; } = Color.FromArgb(0, 0, 0, 0);
| public Color ColorE { get; set; } = Color.FromArgb(25, 255, 255, 255);
|
|
| protected override void OnPaintBackground(PaintEventArgs e)
| {
| //
| }
|
| protected override void OnPaint(PaintEventArgs e)
| {
| base.OnPaint(e);
| int V = Width * _Value / _Maximum;
| using Bitmap B = new(Width, Height);
| using Graphics G = Graphics.FromImage(B);
| Rectangle R1 = new(1, 1, Width - 2, Height - 2);
| Rectangle R2 = new(2, 2, V - 4, Height - 4);
| Brush GB1 = new LinearGradientBrush(R1, ColorB, ColorC, 90.0F);
| Brush GB2 = new LinearGradientBrush(R2, ColorC, ColorB, 30.0F);
| G.FillRectangle(GB1, R1);
| G.FillRectangle(GB2, R2);
| // Draw.Gradient(G, _ColorB, _ColorC, 1, 1, Width - 2, Height - 2)
| G.DrawRectangle(new(ColorB), 1, 1, V - 3, Height - 3);
| // Draw.Gradient(G, _ColorC, _ColorB, 2, 2, V - 4, Height - 4)
|
| G.DrawRectangle(new(ColorA), 0, 0, Width - 1, Height - 1);
| Bitmap B1 = B;
| e.Graphics.DrawImage(B1, 0, 0);
| /*
| Draw.Gradient(G, _ColorB, _ColorC, 1, 1, Width - 2, Height - 2)
| G.DrawRectangle(new(_ColorB), 1, 1, V - 3, Height - 3)
| Draw.Gradient(G, _ColorC, _ColorB, 2, 2, V - 4, Height - 4)
|
| G.DrawRectangle(new(_ColorA), 0, 0, Width - 1, Height - 1)
|
| e.Graphics.DrawImage(B.Clone, 0, 0)
| */
| }
| }
|
| #endregion
| }
|
|