-
Notifications
You must be signed in to change notification settings - Fork 5
/
WaveProgressPainter.cs
112 lines (94 loc) · 2.92 KB
/
WaveProgressPainter.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
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
[ToolboxBitmapAttribute(typeof(ProgressODoom.WaveProgressPainter), "Icons.WaveProgressPainter.ico")]
public class WaveProgressPainter : AbstractProgressPainter, IProgressPainter, IAnimatedProgressPainter, IDisposable {
private Color color1 = Color.FromArgb(110, 195, 248);
private Color color2 = Color.FromArgb(056, 150, 230);
private int marqueeSpeed = 10;
private int marqueeX = 0;
private int animateX = 0;
private bool isAnimated = false;
/// <summary></summary>
public Color BaseColor {
get { return color1; }
set {
color1 = value;
FireChange();
}
}
/// <summary></summary>
public Color WaveColor {
get { return color2; }
set {
color2 = value;
FireChange();
}
}
/// <summary></summary>
public int AnimationSpeed {
get { return marqueeSpeed; }
set { marqueeSpeed = value; FireChange(); }
}
/// <summary></summary>
public bool Animating {
get { return isAnimated; }
set { isAnimated = value; }
}
private void AnimateFrame(Rectangle box, Graphics g, ref int marqueeX) {
if (box == null || g == null || box.Width <= 1) { return; }
g.SmoothingMode = SmoothingMode.AntiAlias;
//g.Clip = new Region(box);
g.FillRectangle(new SolidBrush(color1), box);
int h = box.Height;
int hm = (int)((float)h / 2f);
using (GraphicsPath gp = new GraphicsPath()) {
Point MidLeft = new Point(0, hm);
Point MidRight = new Point(h * 2, hm);
int currentX = box.Right + animateX; // Increment currentX to animate
int left = currentX - (h * 2);
if (left < box.Left) { left = box.Left; }
while (currentX > box.Left) {
left = currentX - (h * 2);
MidLeft = new Point(left, hm);
MidRight = new Point(currentX, hm);
int crestX = currentX - h;
gp.AddBezier(MidRight, new Point(crestX, 0), new Point(crestX, h), MidLeft);
currentX -= h * 2;
}
gp.AddLine(MidLeft, new Point(box.Left, box.Bottom)); // left side
gp.AddLine(new Point(box.Left, box.Bottom), new Point(box.Right, box.Bottom)); // bottom
gp.AddLine(new Point(box.Right, box.Bottom), new Point(box.Right, hm)); // right side
g.FillPath(new SolidBrush(color2), gp);
}
g.SmoothingMode = SmoothingMode.Default;
if (isAnimated && ++animateX > (box.Height * 2)) {
animateX = 1;
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
if (box.Width <= 1) {
return;
}
if (isAnimated) {
AnimateFrame(box, g, ref marqueeX);
} else {
int x = 0;
AnimateFrame(box, g, ref x);
}
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
}
}
}