forked from MarkusMaal/BlueScreenSimulatorPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringEdit.cs
More file actions
521 lines (497 loc) · 20.2 KB
/
StringEdit.cs
File metadata and controls
521 lines (497 loc) · 20.2 KB
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using SimulatorDatabase;
namespace UltimateBlueScreenSimulator
{
public partial class StringEdit : Form
{
internal BlueScreen me;
private string editable = "";
private string type = "String";
private bool theme_bg = false;
private bool theme_hl = false;
public StringEdit()
{
InitializeComponent();
}
private void StringEdit_Load(object sender, EventArgs e)
{
HideAllProps();
MessageView.Clear();
UpdateMessageView();
if (Program.f1.nightThemeToolStripMenuItem.Checked)
{
this.BackColor = Color.Black;
this.ForeColor = Color.Gray;
MessageView.BackColor = Color.Black;
MessageView.ForeColor = Color.Gray;
MessageView.GridLines = false;
MessageView.BorderStyle = BorderStyle.None;
qrProps.BackColor = Color.Black;
qrProps.ForeColor = Color.Gray;
timeoutProps.BackColor = Color.Black;
timeoutProps.ForeColor = Color.Gray;
timeoutBox.BackColor = Color.Black;
timeoutBox.ForeColor = Color.Gray;
timeoutBox.BorderStyle = BorderStyle.FixedSingle;
radioFlowLayoutPanel.BackColor = Color.Black;
radioFlowLayoutPanel.ForeColor = Color.Gray;
fontProps.BackColor = Color.Black;
fontProps.ForeColor = Color.Gray;
blinkProps.BackColor = Color.Black;
blinkProps.ForeColor = Color.Gray;
stringEditor.BackColor = Color.Black;
stringEditor.ForeColor = Color.Gray;
stringEditor.BorderStyle = BorderStyle.FixedSingle;
}
}
private ListViewItem GetColorListViewItem(string title, Color color)
{
ListViewItem li = new ListViewItem
{
ImageIndex = 6,
Text = title
};
li.SubItems.Add("RGB(" + color.R + ", " + color.G + ", " + color.B + ")");
return li;
}
private void WinVers_SelectedIndexChanged(object sender, EventArgs e)
{
HideAllProps();
MessageView.Clear();
UpdateMessageView();
}
private void UpdateMessageView()
{
MessageView.Columns.Add("Property");
MessageView.Columns.Add("Value");
MessageView.Columns[0].Width = 120;
MessageView.Columns[1].Width = 150;
IDictionary<string, string> titles = me.GetTitles();
IDictionary<string, string> texts = me.GetTexts();
if ((me.GetString("os") == "Windows 8/8.1") || me.GetBool("winxplus"))
{
ListViewItem li = new ListViewItem
{
Text = "String: Emoticon"
};
li.SubItems.Add(me.GetString("emoticon"));
li.ImageIndex = 4;
MessageView.Items.Add(li);
}
foreach (KeyValuePair<string, string> entry in titles)
{
ListViewItem li = new ListViewItem
{
Text = "Title: " + entry.Key
};
li.SubItems.Add(entry.Value);
li.ImageIndex = 4;
MessageView.Items.Add(li);
}
foreach (KeyValuePair<string, string> entry in texts)
{
ListViewItem li = new ListViewItem
{
Text = "Text: " + entry.Key
};
li.SubItems.Add(entry.Value);
li.ImageIndex = 4;
MessageView.Items.Add(li);
}
if (me.GetBool("font_support"))
{
ListViewItem lsti = new ListViewItem
{
Text = "Font"
};
lsti.SubItems.Add(me.GetFont().FontFamily.Name + " " + me.GetFont().Size.ToString() + "pt");
lsti.ImageIndex = 5;
MessageView.Items.Add(lsti);
}
if (me.GetString("os") == "Windows CE")
{
ListViewItem lsti = new ListViewItem
{
Text = "Set restart timer"
};
lsti.SubItems.Add(me.GetInt("timer").ToString() + " sec");
lsti.ImageIndex = 5;
MessageView.Items.Add(lsti);
}
if (me.GetBool("blinkblink"))
{
ListViewItem lsti = new ListViewItem
{
Text = "Blink speed"
};
lsti.SubItems.Add(me.GetInt("blink_speed").ToString() + "ms");
lsti.ImageIndex = 5;
MessageView.Items.Add(lsti);
}
if (me.GetBool("winxplus"))
{
ListViewItem lsti = new ListViewItem
{
Text = "QR code image"
};
lsti.SubItems.Add(me.GetString("qr_file").Replace("local:0", "Default").Replace("local:1", "Transparent"));
lsti.ImageIndex = 5;
MessageView.Items.Add(lsti);
lsti = new ListViewItem
{
Text = "QR code size"
};
lsti.SubItems.Add(me.GetInt("qr_size").ToString());
lsti.ImageIndex = 5;
MessageView.Items.Add(lsti);
}
if ((me.GetString("os") == "Windows 8/8.1") || me.GetBool("winxplus"))
{
ListViewItem li = new ListViewItem
{
Text = "Horizontal margin"
};
li.SubItems.Add(me.GetInt("margin-x").ToString() + "%");
li.ImageIndex = 5;
MessageView.Items.Add(li);
li = new ListViewItem
{
Text = "Vertical margin"
};
li.SubItems.Add(me.GetInt("margin-y").ToString() + "%");
li.ImageIndex = 5;
MessageView.Items.Add(li);
}
MessageView.Items.Add(GetColorListViewItem("Background color", me.GetTheme(true)));
MessageView.Items.Add(GetColorListViewItem("Foreground color", me.GetTheme(false)));
if ((me.GetString("os") == "Windows 3.1x") || (me.GetString("os") == "Windows 9x/Me") || (me.GetString("os") == "BOOTMGR"))
{
MessageView.Items.Add(GetColorListViewItem("Highlight background", me.GetTheme(true, true)));
MessageView.Items.Add(GetColorListViewItem("Highlight foreground", me.GetTheme(false, true)));
}
}
private void HideAllProps()
{
colorProps.Visible = false;
stringProps.Visible = false;
blinkProps.Visible = false;
fontProps.Visible = false;
timeoutProps.Visible = false;
xpMsgChooser.Visible = false;
qrProps.Visible = false;
specificProps.Text = "";
previewLabel.Text = "Preview: ";
blinkingDash.Text = "_";
blinkywinky.Enabled = false;
}
private void MessageView_SelectedIndexChanged(object sender, EventArgs e)
{
if (MessageView.SelectedIndices.Count > 0)
{
string selection = MessageView.SelectedItems[0].Text;
if (selection == "Horizontal margin")
{
this.type = "margin-x";
secondsLabel.Text = "%";
timeoutProps.Visible = true;
timeoutBox.Text = me.GetInt("margin-x").ToString();
specificProps.Text = "Margin properties";
}
else if (selection == "Vertical margin")
{
this.type = "margin-y";
secondsLabel.Text = "%";
timeoutProps.Visible = true;
timeoutBox.Text = me.GetInt("margin-y").ToString();
specificProps.Text = "Margin properties";
}
else if (selection.StartsWith("Title: "))
{
this.type = "title";
this.editable = MessageView.SelectedItems[0].Text.Substring(7);
stringEditor.Text = MessageView.SelectedItems[0].SubItems[1].Text;
HideAllProps();
stringProps.Visible = true;
specificProps.Text = "String properties";
}
else if (selection.StartsWith("Text: "))
{
this.type = "text";
this.editable = MessageView.SelectedItems[0].Text.Substring(6);
stringEditor.Text = MessageView.SelectedItems[0].SubItems[1].Text;
HideAllProps();
stringProps.Visible = true;
specificProps.Text = "String properties";
if ((me.GetString("os") == "Windows XP") && (selection.Contains("Troubleshooting")))
{
stringEditor.Enabled = !me.GetBool("auto");
autoRadio.Checked = me.GetBool("auto");
manualRadio.Checked = !me.GetBool("auto");
xpMsgChooser.Visible = true;
} else
{
stringEditor.Enabled = true;
xpMsgChooser.Visible = false;
}
}
else if (selection.StartsWith("String: "))
{
this.type = "string";
this.editable = MessageView.SelectedItems[0].Text.Substring(8).ToLower();
stringEditor.Text = MessageView.SelectedItems[0].SubItems[1].Text;
HideAllProps();
stringProps.Visible = true;
specificProps.Text = "String properties";
}
else if (selection == "Background color")
{
this.theme_bg = true;
this.theme_hl = false;
colorPreview.BackColor = me.GetTheme(true);
HideAllProps();
colorProps.Visible = true;
specificProps.Text = "Color properties";
}
else if (selection == "Foreground color")
{
this.theme_bg = false;
this.theme_hl = false;
colorPreview.BackColor = me.GetTheme(false);
HideAllProps();
colorProps.Visible = true;
specificProps.Text = "Color properties";
}
else if (selection == "Highlight background")
{
this.theme_bg = true;
this.theme_hl = true;
colorPreview.BackColor = me.GetTheme(true, true);
HideAllProps();
colorProps.Visible = true;
specificProps.Text = "Color properties";
}
else if (selection == "Highlight foreground")
{
this.theme_bg = false;
this.theme_hl = true;
colorPreview.BackColor = me.GetTheme(false, true);
HideAllProps();
colorProps.Visible = true;
specificProps.Text = "Color properties";
}
else if (selection == "Blink speed")
{
speedTrackbar.Value = me.GetInt("blink_speed");
HideAllProps();
blinkywinky.Interval = me.GetInt("blink_speed");
blinkywinky.Enabled = true;
blinkProps.Visible = true;
specificProps.Text = "Blink speed properties";
}
else if (selection == "Font")
{
HideAllProps();
fontPreview.Font = me.GetFont();
fontChooser.Font = me.GetFont();
fontProps.Visible = true;
specificProps.Text = "Font properties";
}
else if (selection == "Set restart timer")
{
timeoutBox.Text = me.GetInt("timer").ToString();
HideAllProps();
timeoutProps.Visible = true;
type = "timer";
secondsLabel.Text = "seconds";
specificProps.Text = "Timer properties";
}
else if (selection == "QR code size")
{
HideAllProps();
previewLabel.Text = "Size: ";
blinkingDash.Text = me.GetInt("qr_size").ToString();
speedTrackbar.Value = me.GetInt("qr_size");
blinkProps.Visible = true;
specificProps.Text = "QR code size properties";
}
else if (selection == "QR code image")
{
HideAllProps();
defaultRadioBtn.Checked = false;
transparentRadioBtn.Checked = false;
customRadioBtn.Checked = false;
if (me.GetString("qr_file") == "local:0")
{
defaultRadioBtn.Checked = true;
}
else if (me.GetString("qr_file") == "local:1")
{
transparentRadioBtn.Checked = true;
}
else
{
customRadioBtn.Checked = true;
}
filenameLabel.Text = "Filename: " + me.GetString("qr_file");
qrProps.Visible = true;
specificProps.Text = "QR code image properties";
}
} else
{
HideAllProps();
}
}
private void TextBox1_TextChanged(object sender, EventArgs e)
{
if (stringProps.Visible)
{
if (this.type == "title")
{
me.SetTitle(editable, stringEditor.Text);
MessageView.Clear();
UpdateMessageView();
}
else if (this.type == "text")
{
me.SetText(editable, stringEditor.Text);
MessageView.Clear();
UpdateMessageView();
}
else if (this.type == "string")
{
me.SetString(editable, stringEditor.Text);
MessageView.Clear();
UpdateMessageView();
}
}
}
private void StringEdit_FormClosing(object sender, FormClosingEventArgs e)
{
HideAllProps();
}
private void ColorButton_Click(object sender, EventArgs e)
{
if (colorChooser.ShowDialog() == DialogResult.OK)
{
colorPreview.BackColor = colorChooser.Color;
Color bg = me.GetTheme(true);
Color fg = me.GetTheme(false);
Color hbg = me.GetTheme(true, true);
Color hfg = me.GetTheme(false, true);
if (theme_bg && theme_hl) { hbg = colorChooser.Color; }
else if (theme_bg && !theme_hl) { bg = colorChooser.Color; }
else if (!theme_bg && theme_hl) { hfg = colorChooser.Color; }
else if (!theme_bg && !theme_hl) { fg = colorChooser.Color; }
me.SetTheme(bg, fg);
me.SetTheme(hbg, hfg, true);
MessageView.Clear();
UpdateMessageView();
}
}
private void Button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void TrackBar1_Scroll(object sender, EventArgs e)
{
if (blinkingDash.Text == "_")
{
me.SetInt("blink_speed", speedTrackbar.Value);
blinkywinky.Interval = speedTrackbar.Value;
} else
{
me.SetInt("qr_size", speedTrackbar.Value);
blinkingDash.Text = me.GetInt("qr_size").ToString();
}
MessageView.Clear();
UpdateMessageView();
}
private void Blinkywinky_Tick(object sender, EventArgs e)
{
blinkingDash.Visible = !blinkingDash.Visible;
}
private void FontChangeButton_Click(object sender, EventArgs e)
{
if (fontChooser.ShowDialog() == DialogResult.OK)
{
me.SetFont(fontChooser.Font.FontFamily.Name, fontChooser.Font.Size, fontChooser.Font.Style);
fontPreview.Font = me.GetFont();
MessageView.Clear();
UpdateMessageView();
}
}
private void TimeoutBox_TextChanged(object sender, EventArgs e)
{
if (timeoutProps.Visible)
{
try
{
me.SetInt(type, Convert.ToInt32(timeoutBox.Text));
MessageView.Clear();
UpdateMessageView();
}
catch
{
System.Media.SystemSounds.Asterisk.Play();
}
}
}
private void CustomRadioBtn_CheckedChanged(object sender, EventArgs e)
{
browseButton.Enabled = customRadioBtn.Checked;
}
private void BrowseButton_Click(object sender, EventArgs e)
{
if (customQRBrowser.ShowDialog() == DialogResult.OK)
{
me.SetString("qr_file", customQRBrowser.FileName);
filenameLabel.Text = "Filename: " + customQRBrowser.FileName;
MessageView.Clear();
UpdateMessageView();
}
}
private void TransparentRadioBtn_CheckedChanged(object sender, EventArgs e)
{
if (qrProps.Visible && transparentRadioBtn.Checked)
{
me.SetString("qr_file", "local:1");
filenameLabel.Text = "";
MessageView.Clear();
UpdateMessageView();
}
}
private void DefaultRadioBtn_CheckedChanged(object sender, EventArgs e)
{
if (qrProps.Visible && defaultRadioBtn.Checked)
{
me.SetString("qr_file", "local:0");
filenameLabel.Text = "";
MessageView.Clear();
UpdateMessageView();
}
}
private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MessageBox.Show("They have been moved to a new location. The new location is Settings > Simulator settings > Save/Load configurations", "About the save and load button", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void autoRadio_CheckedChanged(object sender, EventArgs e)
{
if (autoRadio.Checked)
{
me.SetBool("auto", true);
stringEditor.Enabled = false;
}
}
private void manualRadio_CheckedChanged(object sender, EventArgs e)
{
if (manualRadio.Checked)
{
me.SetBool("auto", false);
stringEditor.Enabled = true;
}
}
}
}