forked from daPhie79/ProgressODoom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
JavaProgressPainter.cs
138 lines (123 loc) · 4.37 KB
/
JavaProgressPainter.cs
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.JavaProgressPainter), "Icons.JavaProgressPainter.ico")]
public class JavaProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private Color color;
private ColorSet colors;
/// <summary></summary>
public JavaProgressPainter() {
color = Color.SkyBlue;
colors = new ColorSet(false, color, 0.95f, 8);
}
/// <summary></summary>
/// <param name="color"></param>
public JavaProgressPainter(Color color) {
this.color = color;
colors = new ColorSet(false, color, 0.95f, 8);
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the base progress color."), Browsable(true)]
public Color Color {
get { return color; }
set {
color = value;
colors = new ColorSet(false, color, 0.95f, 8);
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
try {
box.Width -= 1;
box.Height -= 1;
} catch {}
if (box.Width <= 1) { return; }
float x = (float)box.X;
float y = (float)box.Y;
float w = (float)box.Right;
float h = (float)box.Bottom;
//Color corner
Pen p;
x += 2f; //x += 3f; //x += 2f; //x = x + 3f;
y += 4f; //y += 5f; //y += 4f; //y = y + 5f;
w -= 2f; //w -= 3f; //w -= 1f; //w = w - 2f;
h -= 4f; //h -= 6f; //h -= 4f; //h = h - 6f;
// Progress
colors = new ColorSet(true, this.color, 0.95f, (int)h);
float z = 2;
float ni;
float th = box.Height - 4;
for (int i = -2; i < th; i++) {
//for (int i = -2; i < th; i++) {
z = (i < 0 ? i * -1 : i);
Color c = colors.Colors[colors.Colors.Length - 1];
try {
c = colors.Colors[(int)z];
} catch {}
p = new Pen(c);
ni = y + i;
g.DrawLine(p, x, ni, w, ni);
}
Color progborder = ColorRange.Morph(0.2f, Color.FromArgb(98, 98, 89), this.color);
Color fade = Color.FromArgb(64, progborder.R, progborder.G, progborder.B);
p = new Pen(new SolidBrush(fade), 1);
//g.DrawRectangle(p, x - 1f, y - 3f, w - 1f, h + 1f);
Rectangle bbox = box;
bbox.Inflate(-1, -1);
g.DrawRectangle(p, bbox);
// Border
p = new Pen(progborder, 1);
////g.DrawRectangle(p, x - 1f, y - 3f, w - 1f, h + 1f);
//g.DrawLine(p, x, y - 3f, w, y - 3f);
//g.DrawLine(p, x, h + 3f, w, h + 3f);
//g.DrawLine(p, x - 1f, y - 2f, x - 1f, h + 2f);
//g.DrawLine(p, w + 1f, y - 2f, w + 1f, h + 2f);
g.DrawLine(p, x + 1f, y - 3f, w - 1f, y - 3f);
g.DrawLine(p, x + 1f, h + 3f, w - 1f, h + 3f);
g.DrawLine(p, x - 1f, y - 1f, x - 1f, h + 1f);
g.DrawLine(p, w + 1f, y - 1f, w + 1f, h + 1f);
// Border corner skirt
//Color skirt = ColorRange.Morph(0.8f, this.color, progborder);
Color skirt = Color.FromArgb(210, progborder.R, progborder.G, progborder.B);
p = new Pen(skirt, 1);
//// Upper Left
//g.DrawLine(p, x - 1f, y - 3f, x, y - 3f);
//g.DrawLine(p, x - 1f, y - 3f, x - 1f, y - 2f);
g.DrawLine(p, x, y - 3f, x - 1f, y - 2f);
//// Lower Left
//g.DrawLine(p, x - 1f, h + 3f, x - 1f, h + 2f);
//g.DrawLine(p, x - 1f, h + 3f, x, h + 3f);
g.DrawLine(p, x, h + 3f, x - 1f, h + 2f);
//// Upper Right
//g.DrawLine(p, w + 1f, y - 3f, w + 1f, y - 2f);
//g.DrawLine(p, w + 1f, y - 3f, w, y - 3f);
g.DrawLine(p, w, y - 3f, w + 1f, y - 2f);
//// Lower Right
//g.DrawLine(p, w + 1f, h + 3f, w, h + 3f);
//g.DrawLine(p, w + 1f, h + 3f, w + 1f, h + 2f);
g.DrawLine(p, w, h + 3f, w + 1f, h + 2f);
//// Border corner x-1f, y-3f, w-2f, h+1f
//Color corners = ColorRange.Morph(0.5f, this.color, progborder); //Color.FromArgb(229, 229, 222)
//p = new Pen(corners, 1);
//g.DrawLine(p, x - 1f, y - 3f, x, y - 2f); // ul
//g.DrawLine(p, x - 1f, h + 3f, x, h + 2f); // ll
//g.DrawLine(p, w + 1f, y - 3f, w, y - 2f); // ur
//g.DrawLine(p, w + 1f, h + 3f, w, h + 2f); // lr
////// Outer corner (Left side only)
////Color outcorner = ColorRange.Morph(0.5f, progborder, Color.FromArgb(229, 229, 222));
////p = new Pen(outcorner, 1);
////g.DrawLine(p, x - 2f, y - 4f, x - 1f, y - 3f);
////g.DrawLine(p, x - 2f, h + 4f, x - 1f, h + 3f);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
}
}