-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmExpTracker.cs
248 lines (215 loc) · 8.67 KB
/
frmExpTracker.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EXPTracker
{
public partial class frmEXPTracker : Form
{
private GeniePlugin.Interfaces.IHost _host;
public frmEXPTracker(ref GeniePlugin.Interfaces.IHost host)
{
InitializeComponent();
_host = host;
}
private void btnOk_Click(object sender, EventArgs e)
{
if (cbEnable.Checked == true)
_host.SendText("#var ExpTracker.Window 1");
else
_host.SendText("#var ExpTracker.Window 0");
if (cbRankGain.Checked == true)
_host.SendText("#var ExpTracker.ShowRankGain 1");
else
_host.SendText("#var ExpTracker.ShowRankGain 0");
if (cbLearningRate.Checked == true)
_host.SendText("#var ExpTracker.LearningRate 1");
else
_host.SendText("#var ExpTracker.LearningRate 0");
if (cbLearningRateNumber.Checked == true)
_host.SendText("#var ExpTracker.LearningRateNumber 1");
else
_host.SendText("#var ExpTracker.LearningRateNumber 0");
if (cbTrackSleep.Checked == true)
_host.SendText("#var ExpTracker.TrackSleep 1");
else
_host.SendText("#var ExpTracker.TrackSleep 0");
if (cbEchoSleep.Checked == true)
_host.SendText("#var ExpTracker.EchoSleep 1");
else
_host.SendText("#var ExpTracker.EchoSleep 0");
_host.SendText("#var {ExpTracker.Echo} {" + txtEcho.Text.Trim() + "}");
if (comboSort.Text == "A to Z")
_host.SendText("#var ExpTracker.SortType 0");
else if (comboSort.Text == "Left to Right")
_host.SendText("#var ExpTracker.SortType 1");
else
_host.SendText("#var ExpTracker.SortType 2");
if (cbGagExp.Checked == true)
_host.SendText("#var ExpTracker.GagExp 1");
else
_host.SendText("#var ExpTracker.GagExp 0");
if (cbShort.Checked == true)
_host.SendText("#var ExpTracker.ShortNames 1");
else
_host.SendText("#var ExpTracker.ShortNames 0");
_host.SendText("#var {ExpTracker.Color.RankGained} {" + txtRankGained.Text.Trim() + "}");
_host.SendText("#var {ExpTracker.Color.Learned} {" + txtLearned.Text.Trim() + "}");
_host.SendText("#var {ExpTracker.Color.Normal} {" + txtNormal.Text.Trim() + "}");
_host.SendText("#var save");
this.Close();
}
public string ColorToHex(Color oColor)
{
return "#" + Hex2Digits(oColor.R) + Hex2Digits(oColor.G) + Hex2Digits(oColor.B);
}
public string ColorToString(Color oColor)
{
if (oColor.IsNamedColor)
{
return oColor.Name;
}
return ColorToHex(oColor);
}
private static string Hex2Digits(byte color)
{
string sColor = color.ToString("X");
if (sColor.Length == 1)
{
sColor = "0" + sColor;
}
return sColor;
}
private void btnLearned_Click(object sender, EventArgs e)
{
ColorDialog colorDialog = new ColorDialog();
colorDialog.FullOpen = true;
if (colorDialog.ShowDialog() != DialogResult.Cancel)
{
txtLearned.Text = ColorToString(colorDialog.Color);
lblLearned.ForeColor = colorDialog.Color;
}
}
private void btnRankGained_Click(object sender, EventArgs e)
{
ColorDialog colorDialog = new ColorDialog();
colorDialog.FullOpen = true;
if (colorDialog.ShowDialog() != DialogResult.Cancel)
{
txtRankGained.Text = ColorToString(colorDialog.Color);
lblRankGained.ForeColor = colorDialog.Color;
}
}
private void btnNormal_Click(object sender, EventArgs e)
{
ColorDialog colorDialog = new ColorDialog();
colorDialog.FullOpen = true;
if (colorDialog.ShowDialog() != DialogResult.Cancel)
{
txtNormal.Text = ColorToString(colorDialog.Color);
lblNormal.ForeColor = colorDialog.Color;
}
}
private void Form1_Load(object sender, EventArgs e)
{
Color color;
color = Color.FromName(txtNormal.Text);
if (color.ToArgb() != 0)
lblNormal.ForeColor = color;
else if (txtNormal.Text.StartsWith("#") && txtNormal.Text.Length == 7)
lblNormal.ForeColor = System.Drawing.ColorTranslator.FromHtml(txtNormal.Text);
color = Color.FromName(txtRankGained.Text);
if (color.ToArgb() != 0)
lblRankGained.ForeColor = color;
else if (txtRankGained.Text.StartsWith("#") && txtRankGained.Text.Length == 7)
lblRankGained.ForeColor = System.Drawing.ColorTranslator.FromHtml(txtRankGained.Text);
color = Color.FromName(txtLearned.Text);
if (color.ToArgb() != 0)
lblLearned.ForeColor = color;
else if (txtLearned.Text.StartsWith("#") && txtLearned.Text.Length == 7)
lblLearned.ForeColor = System.Drawing.ColorTranslator.FromHtml(txtLearned.Text);
cbEnable_CheckedChanged(sender,e);
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void cbEnable_CheckedChanged(object sender, EventArgs e)
{
if (cbEnable.Checked == true)
{
cbRankGain.Enabled = true;
cbLearningRate.Enabled = true;
cbLearningRateNumber.Enabled = true;
cbTrackSleep.Enabled = true;
if (cbTrackSleep.Checked == true)
{
cbEchoSleep.Enabled = true;
if (cbEchoSleep.Checked == true)
txtEcho.Enabled = true;
else
txtEcho.Enabled = false;
}
else
{
cbEchoSleep.Enabled = false;
txtEcho.Enabled = false;
}
comboSort.Enabled = true;
cbGagExp.Enabled = true;
cbShort.Enabled = true;
txtNormal.Enabled = true;
btnNormal.Enabled = true;
txtRankGained.Enabled = true;
btnRankGained.Enabled = true;
txtLearned.Enabled = true;
btnLearned.Enabled = true;
}
else
{
cbRankGain.Enabled = false;
cbLearningRate.Enabled = false;
cbLearningRateNumber.Enabled = false;
cbTrackSleep.Enabled = false;
cbEchoSleep.Enabled = false;
txtEcho.Enabled = false;
comboSort.Enabled = false;
cbGagExp.Enabled = false;
cbShort.Enabled = false;
txtNormal.Enabled = false;
btnNormal.Enabled = false;
txtRankGained.Enabled = false;
btnRankGained.Enabled = false;
txtLearned.Enabled = false;
btnLearned.Enabled = false;
}
}
private void cbTrackSleep_CheckedChanged(object sender, EventArgs e)
{
if (cbTrackSleep.Checked == true)
{
cbEchoSleep.Enabled = true;
if (cbEchoSleep.Checked == true)
txtEcho.Enabled = true;
else
txtEcho.Enabled = false;
}
else
{
cbEchoSleep.Enabled = false;
txtEcho.Enabled = false;
}
}
private void cbEchoSleep_CheckedChanged(object sender, EventArgs e)
{
if(cbEchoSleep.Checked == true)
txtEcho.Enabled = true;
else
txtEcho.Enabled = false;
}
}
}