forked from MarkusMaal/BlueScreenSimulatorPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgressTuner.cs
163 lines (148 loc) · 4.95 KB
/
ProgressTuner.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
namespace UltimateBlueScreenSimulator
{
public partial class ProgressTuner : Form
{
internal IDictionary<int, int> KFrames = new Dictionary<int, int>();
Bitmap bmp = new Bitmap(1000, 10);
int last = 0;
public ProgressTuner()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
progressTrackBar.Maximum = Convert.ToInt32(100 * float.Parse(totalTimeText.Text, CultureInfo.InvariantCulture.NumberFormat));
ReloadBitmap();
} catch {}
}
internal void ReloadBitmap()
{
progressVisualization.Image = null;
try
{
bmp.Dispose();
} catch { }
bmp = new Bitmap((int)((float)progressTrackBar.Maximum / 10f), 10);
foreach (float position in KFrames.Keys)
{
for (int i = 0; i < 10; i++)
{
if ((float)position / 10f >= bmp.Width) { break; }
bmp.SetPixel((int)((float)position / 10f), i, Color.Red);
}
}
progressVisualization.Image = bmp;
}
private void progressTrackBar_Scroll(object sender, EventArgs e)
{
SetLabelText();
if (KFrames.ContainsKey(progressTrackBar.Value))
{
incPercent.Text = KFrames[progressTrackBar.Value].ToString();
} else
{
incPercent.Text = "0";
}
}
internal void SetLabelText()
{
int totalpercent = 0;
foreach (int perc in KFrames.Values)
{
totalpercent += perc;
}
progressPositionLabel.Text = string.Format("total: {0}%, position: {1}s", totalpercent, ((float)progressTrackBar.Value / 100.0f).ToString().Replace(",", "."));
}
private void randomButton_Click(object sender, EventArgs e)
{
Random r = new Random();
incPercent.Text = r.Next(0, 10).ToString();
}
private void nextKeyFrameButton_Click(object sender, EventArgs e)
{
foreach (int position in KFrames.Keys)
{
if (position > (progressTrackBar.Value))
{
try
{
progressTrackBar.Value = position;
} catch { }
break;
}
}
}
private void previousKeyFrameButton_Click(object sender, EventArgs e)
{
int minimum = 0;
foreach (int position in KFrames.Keys)
{
if (position < progressTrackBar.Value)
{
minimum = position;
}
}
progressTrackBar.Value = minimum;
}
private void AddKeyFrame_Click(object sender, EventArgs e)
{
deleteKeyFrame.PerformClick();
KFrames.Add(progressTrackBar.Value, int.Parse(incPercent.Text));
ReloadBitmap();
last = progressTrackBar.Value - last;
SetLabelText();
repeatButton.Enabled = true;
}
private void deleteKeyFrame_Click(object sender, EventArgs e)
{
if (KFrames.ContainsKey(progressTrackBar.Value))
{
KFrames.Remove(progressTrackBar.Value);
ReloadBitmap();
}
SetLabelText();
}
private void repeatButton_Click(object sender, EventArgs e)
{
if (KFrames.ContainsKey(progressTrackBar.Value + last))
{
KFrames.Remove(progressTrackBar.Value + last);
}
KFrames.Add(progressTrackBar.Value + last, int.Parse(incPercent.Text));
ReloadBitmap();
SetLabelText();
try
{
progressTrackBar.Value += last;
}
catch { }
repeatButton.Enabled = true;
}
private void OKClick(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void CancelClick(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void ClearAll(object sender, EventArgs e)
{
if (MessageBox.Show("This will remove all keyframes. This cannot be undone. Do you still want to continue?", "Clear all keyframes", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
KFrames.Clear();
ReloadBitmap();
SetLabelText();
}
}
}
}