Repository navigation
Expand file tree
/
Copy pathGlobalSettings.cs
More file actions
857 lines (780 loc) · 30.9 KB
/
Copy pathGlobalSettings.cs
File metadata and controls
857 lines (780 loc) · 30.9 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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization; // alias to ms to avoid conflict with ColorScheme
using System.Threading;
using System.Windows.Forms;
using ms = MaterialSkin2Framework;
namespace UltimateBlueScreenSimulator
{
public class GlobalSettings
{
/*
* // Example usage
* GlobalSettings gs = new GlobalSettings();
* gs.EnableEggs = true; // set value
*
* if (gs.EnableEggs) { // get value
* MessageBox.Show("I stored a setting!");
* }
*/
// stored settings (these are saved)
private bool postponeupdate;
private bool hashverify;
private bool autoupdate;
private bool showcursor;
private bool enableeggs;
private bool randomness;
private bool autodark;
private string singlesim;
private string update_server;
private bool quickhelp;
private bool autosave;
private bool legacyui;
private bool mousemoveexit;
// runtime settings (these are not persistent)
[JsonIgnore]
private int errorcode;
[JsonIgnore]
private bool realpostpone;
[JsonIgnore]
private bool nighttheme;
[JsonIgnore]
private string supporttext;
[JsonIgnore]
private bool displayone;
[JsonIgnore]
private bool fileio;
// prank mode
private MessageBoxIcon MsgBoxIcon;
private MessageBoxButtons MsgBoxType;
private string MsgBoxTitle;
private string MsgBoxMessage;
private string appname;
private bool lockout;
private bool closecuzhidden;
private bool showmsg;
private string[] usb_device;
private int[] time;
private bool timecatch;
private bool devmode;
[JsonIgnore]
public List<string> log1;
///<summary>
///Multi-monitor display method for fullscreen mode.
///</summary>
public DisplayModes DisplayModeEnum { get; set; }
///<summary>
///Scaling mode for legacy OS templates, i.e. Windows 7 and earlier.
///</summary>
public ScaleModes ScaleMode { get; set; }
///<summary>
///Accent color used by the application
///</summary>
public ColorSchemes ColorScheme { get; set; }
///<summary>
///Accent color used by the application
///</summary>
public ColorSchemes PrimaryColor { get; set; }
// define enums
public enum DisplayModes
{
None,
Blank,
Mirror,
Freeze
}
public enum ColorSchemes
{
Amber, Blue, Cyan, DeepOrange, DeepPurple,
Green, Indigo, LightBlue, LightGreen, Lime,
Orange, Pink, Purple, Red, Teal, Yellow
}
public enum ScaleModes
{
HighQualityBicubic,
HighQualityBilinear,
Bilinear,
Bicubic,
NearestNeighbour
}
///<summary>
///Settings stored by the application, no initialization parameters required
///</summary>
public GlobalSettings()
{
postponeupdate = false;
autoupdate = true;
hashverify = true;
showcursor = false;
enableeggs = true;
randomness = false;
autodark = true;
devmode = false;
quickhelp = true;
autosave = true;
legacyui = false;
mousemoveexit = false;
fileio = true;
singlesim = "";
update_server = "https://markustegelane.eu/app/";
// runtime settings (these are not persistent)
errorcode = 0;
realpostpone = false;
nighttheme = false;
supporttext = "If this is the first time you've seen this Stop error screen,\nrestart your computer. If this screen appears again, follow\nthese steps:\n\nCheck to make sure any new hardware or software is properly installed.\nIf this is a new installation, ask your hardware or software manufacturer\nfor any Windows updates you might need.\n\nIf problems continue, disable or remove any newly installed hardware\nor software. Disable BIOS memory options such as caching or shadowing.\nIf you need to use Safe mode to remove or disable components, restart\nyour computer, press F8 to select Advanced Startup Options, and then\nselect Safe Mode.";
displayone = false;
// prank mode
time = new int[]{ 0, 5, 0 };
timecatch = true;
log1 = new List<string>();
Log("Info", "Log started");
DisplayModeEnum = DisplayModes.None;
ScaleMode = ScaleModes.HighQualityBicubic;
ColorScheme = ColorSchemes.Blue;
PrimaryColor = ColorSchemes.Indigo;
}
///<summary>
///Specific to screensaver files, exits the simulation when moving the mouse cursor
///</summary>
public bool MouseMoveExit {
get { return mousemoveexit; }
set { mousemoveexit = value; }
}
///<summary>
///Specifies whether or not the user wants a classic user interface (UI)
///</summary>
public bool LegacyUI {
get { return legacyui; }
set { legacyui = value; }
}
///<summary>
///Installs updates only when the application is closed
///</summary>
public bool PostponeUpdate {
get { return postponeupdate; }
set { postponeupdate = value; }
}
///<summary>
///Automatically checks for updates
///</summary>
public bool AutoUpdate {
get { return autoupdate; }
set { autoupdate = value; }
}
///<summary>
///Checks the hash of the executable and any dependencies when downloading updates
///</summary>
public bool HashVerify {
get { return hashverify; }
set { hashverify = value; }
}
///<summary>
///Checks the hash of the executable and any dependencies when downloading updates
///</summary>
[JsonIgnore]
public string SupportText {
get { return supporttext; }
set { supporttext= value; }
}
///<summary>
///Shows the cursor during simulation
///</summary>
public bool ShowCursor {
get { return showcursor; }
set { showcursor = value; }
}
///<summary>
///Toggles easter eggs
///</summary>
public bool EnableEggs {
get { return enableeggs; }
set { enableeggs = value; }
}
///<summary>
///Toggles whether or not to add randomness to legacy configurations loaded from an old bs2cfg or bscfg file
///</summary>
public bool Randomness {
get { return randomness; }
set { randomness = value; }
}
///<summary>
///Selected update server, where the updates are downloaded from
///</summary>
public string UpdateServer {
get { return update_server; }
set { update_server = value; }
}
///<summary>
///Toggles Windows dark mode detection
///</summary>
public bool AutoDark {
get { return autodark; }
set { autodark = value; }
}
/// <summary>
/// Toggles autosave/load feature
/// </summary>
public bool Autosave {
get { return autosave; }
set { autosave = value; }
}
/// <summary>
/// Toggles tooltips
/// </summary>
public bool QuickHelp {
get { return quickhelp; }
set { quickhelp = value; }
}
///<summary>
///This value allows for selecting a configuration through command line arguments
///</summary>
[JsonIgnore]
public bool DisplayOne {
get { return displayone; }
set { displayone = value; }
}
///<summary>
///Sets the error code for current session
///</summary>
[JsonIgnore]
public int ErrorCode {
get { return errorcode; }
set { errorcode = value; }
}
///<summary>
///Icon for the message box that may pop up after prank mode ends
///</summary>
[JsonIgnore]
public MessageBoxIcon PM_MsgIcon {
get { return MsgBoxIcon; }
set { MsgBoxIcon = value; }
}
///<summary>
///Button layout for the message box that may pop up after prank mode ends
///</summary>
[JsonIgnore]
public MessageBoxButtons PM_MsgType {
get { return MsgBoxType; }
set { MsgBoxType = value; }
}
///<summary>
///Title for the message box that may pop up after prank mode ends
///</summary>
[JsonIgnore]
public string PM_MsgTitle {
get { return MsgBoxTitle; }
set { MsgBoxTitle = value; }
}
///<summary>
///Text content for the message box that may pop up after prank mode ends
///</summary>
[JsonIgnore]
public string PM_MsgText {
get { return MsgBoxMessage; }
set { MsgBoxMessage = value; }
}
///<summary>
///Prevent ending the simulation by pressing Alt+F4 or any other key
///</summary>
[JsonIgnore]
public bool PM_Lockout {
get { return lockout; }
set { lockout = value; }
}
///<summary>
///Prevents re-showing the main interface when exiting prank mode
///</summary>
[JsonIgnore]
public bool PM_CloseMainUI {
get { return closecuzhidden; }
set { closecuzhidden = value; }
}
///<summary>
///Displays a message when exiting prank mode
///</summary>
[JsonIgnore]
public bool PM_ShowMessage {
get { return showmsg; }
set { showmsg = value; }
}
///<summary>
///Specifies which process triggers prank mode (if process trigger is selected)
///</summary>
[JsonIgnore]
public string PM_AppName {
get { return appname; }
set { appname = value; }
}
///<summary>
///Specifies which USB device triggers prank mode (if device trigger is selected)
///</summary>
[JsonIgnore]
public string[] PM_UsbDevice {
get { return usb_device; }
set { usb_device = value; }
}
///<summary>
///Specifies the timer, which triggers prank mode (if time based trigger is selected) in [hours, minutes, seconds] format
///</summary>
[JsonIgnore]
public int[] PM_Time {
get { return time; }
set { time = value; }
}
///<summary>
///Determines whether or not the trigger is time based. Device based trigger is only used if the length of PM_UsbDevice is greater than zero, otherwise application based trigger is used.
///</summary>
[JsonIgnore]
public bool PM_Timecatch {
get { return timecatch; }
set { timecatch = value; }
}
///<summary>
///Starts the update process after exiting the program
///</summary>
[JsonIgnore]
public bool UpdateAfterExit {
get { return realpostpone; }
set { realpostpone = value; }
}
///<summary>
///Determines if the interface should have a night theme or not
///</summary>
[JsonIgnore]
public bool NightTheme {
get { return nighttheme; }
set { nighttheme = value; }
}
///<summary>
///Allows the program to be run as a single simulator based on the specified OS template (e.g. Windows Vista, Windows 10, etc.)
///</summary>
[JsonIgnore]
public string SingleSim {
get { return singlesim; }
set { singlesim = value; }
}
///<summary>
///Unlocks certain developer only features, such as DictEdit, Restart application, etc. Also throws exceptions rather than catching them.
///</summary>
[JsonIgnore]
public bool DevBuild {
get { return devmode; }
set { devmode = value; }
}
///<summary>
///Read-write mode flag
///</summary>
[JsonIgnore]
public bool FileIO {
get { return fileio; }
set { fileio = value; }
}
///<summary>
///Saves application configuration settings
///</summary>
public void SaveSettings()
{
Log("Info", "Saving settings");
try
{
JsonSerializerOptions options = new JsonSerializerOptions
{
WriteIndented = true,
Converters =
{
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
}
};
string jsonString = JsonSerializer.Serialize(this, options);
File.WriteAllText(Program.prefix + "settings.json", jsonString);
}
catch (DllNotFoundException) when (!Debugger.IsAttached)
{
Program.DllError();
return;
}
catch (IOException) when (!Debugger.IsAttached)
{
Program.DllError();
return;
} catch (Exception ex) when (!Debugger.IsAttached)
{
if (MessageBox.Show($"Unable to save settings! Reason: {ex.Message}\r\n{ex.StackTrace}", "Blue screen simulator plus", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
{
SaveSettings();
} else
{
return;
}
}
}
///<summary>
///Loads application configuration settings
///</summary>
public GlobalSettings LoadSettings()
{
if (!Directory.Exists(Program.prefix))
{
Directory.CreateDirectory(Program.prefix);
}
if (File.Exists("settings.cfg"))
{
LoadLegacy();
File.Delete("settings.cfg");
SaveSettings();
return this;
}
else if (File.Exists(Program.prefix + "settings.json"))
{
GlobalSettings settings;
Log("Info", $"Loading settings from JSON file");
try
{
JsonSerializerOptions options = new JsonSerializerOptions
{
Converters =
{
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
}
};
settings = JsonSerializer.Deserialize<GlobalSettings>(File.ReadAllText(Program.prefix + "settings.json"), options);
if (File.Exists("settings.cfg"))
{
File.Delete("settings.cfg");
}
}
catch (DllNotFoundException) when (!Debugger.IsAttached)
{
Program.DllError();
return this;
}
catch (IOException) when (!Debugger.IsAttached)
{
Program.DllError();
return this;
}
return settings;
} else
{
Log("Warning", "Settings file does not exist, using defaults");
}
return this;
}
/// <summary>
/// Loads the configuration file, which is stored in legacy format. Avoid using this, unless you're updating from a previous version and want to carry the settings over.
/// </summary>
public void LoadLegacy()
{
Log("Info", $"Loading settings from legacy configuration file");
string[] fc = File.ReadAllText("settings.cfg").Split('\n');
foreach (string element in fc)
{
//Other configurations
if (element.StartsWith("UpdateClose="))
{
PostponeUpdate = Convert.ToBoolean(element.Replace("UpdateClose=", ""));
}
else if (element.StartsWith("HashVerify="))
{
HashVerify = Convert.ToBoolean(element.Replace("HashVerify=", ""));
}
else if (element.StartsWith("AutoUpdate="))
{
AutoUpdate = Convert.ToBoolean(element.Replace("AutoUpdate=", ""));
}
else if (element.StartsWith("ShowCursor="))
{
ShowCursor = Convert.ToBoolean(element.Replace("ShowCursor=", ""));
}
else if (element.StartsWith("MultiMode="))
{
DisplayMode = element.Replace("MultiMode=", "");
}
else if (element.StartsWith("Seecrets="))
{
EnableEggs = Convert.ToBoolean(element.Replace("Seecrets=", ""));
}
else if (element.StartsWith("ScaleMode="))
{
SetScalingFromString(element.Replace("ScaleMode=", ""));
}
else if (element.StartsWith("Server="))
{
UpdateServer = element.Replace("Server=", "");
}
else if (element.StartsWith("Randomness="))
{
Randomness = Convert.ToBoolean(element.Replace("Randomness=", ""));
}
else if (element.StartsWith("AutoDark="))
{
AutoDark = Convert.ToBoolean(element.Replace("AutoDark=", ""));
}
// this skips checking hidden/visible OS-s
// this is a feature that was exclusive to 1.x
else if (element.Contains("\""))
{
break;
}
}
}
///<summary>
///Converts current interpolation mode to System.Drawing.Drawing2D.InterpolationMode. This should be used when setting scaling mode for System.Drawing.Graphics (to avoid a bunch of unnecessary conditional statements).
///</summary>
public System.Drawing.Drawing2D.InterpolationMode GetInterpolationMode()
{
Log("Info", $"Requested interpolation mode");
switch (ScaleMode)
{
case ScaleModes.HighQualityBicubic:
return System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
case ScaleModes.HighQualityBilinear:
return System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
case ScaleModes.Bilinear:
return System.Drawing.Drawing2D.InterpolationMode.Bilinear;
case ScaleModes.Bicubic:
return System.Drawing.Drawing2D.InterpolationMode.Bicubic;
case ScaleModes.NearestNeighbour:
return System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
default:
throw new NotImplementedException();
}
}
///<summary>
///Sets current scaling mode based on a string. Please note that passing an invalid value will throw NotImplementedException.
///</summary>
private void SetScalingFromString(string algorithm)
{
Log("Info", $"Changed scaling mode to {algorithm}");
switch (algorithm)
{
case "HighQualityBicubic":
ScaleMode = ScaleModes.HighQualityBicubic;
break;
case "HighQualityBilinear":
ScaleMode = ScaleModes.HighQualityBilinear;
break;
case "Bicubic":
ScaleMode = ScaleModes.Bicubic;
break;
case "Bilinear":
ScaleMode = ScaleModes.Bilinear;
break;
case "NearestNeighbour":
ScaleMode = ScaleModes.NearestNeighbour;
break;
}
}
///<summary>
///Multi-monitor display method (string input/output). The value must be one of the following: none, mirror, blank or freeze, in any other case NotImplementedException is thrown.
///</summary>
[JsonIgnore]
public string DisplayMode {
get {
Log("Info", "Requested display mode");
switch (DisplayModeEnum)
{
case DisplayModes.None:
return "none";
case DisplayModes.Mirror:
return "mirror";
case DisplayModes.Blank:
return "blank";
case DisplayModes.Freeze:
return "freeze";
default:
throw new NotImplementedException();
}
}
set {
Log("Info", $"Changed display mode to {value}");
switch (value)
{
case "none":
DisplayModeEnum = DisplayModes.None;
break;
case "mirror":
DisplayModeEnum = DisplayModes.Mirror;
break;
case "blank":
DisplayModeEnum = DisplayModes.Blank;
break;
case "freeze":
DisplayModeEnum = DisplayModes.Freeze;
break;
default:
throw new NotImplementedException();
}
}
}
///<summary>
///Creates color scheme from accent color
///</summary>
private ms.ColorScheme MakeScheme(ms.Accent accent, ms.Primary[] primary)
{
return new ms.ColorScheme(primary[0], primary[1], primary[2], accent, ms.TextShade.WHITE);
}
///<summary>
///Applies accent color
///</summary>
public void ApplyScheme()
{
Log("Info", $"Applying color scheme {ColorScheme}");
ms.Primary[] primaryScheme = GetPrimaryColors();
switch (ColorScheme)
{
case ColorSchemes.Indigo:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Indigo700, primaryScheme);
break;
case ColorSchemes.Lime:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Lime700, primaryScheme);
break;
case ColorSchemes.Red:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Red700, primaryScheme);
break;
case ColorSchemes.Pink:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Pink700, primaryScheme);
break;
case ColorSchemes.Orange:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Orange700, primaryScheme);
break;
case ColorSchemes.Amber:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Amber700, primaryScheme);
break;
case ColorSchemes.Blue:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Blue700, primaryScheme);
break;
case ColorSchemes.Cyan:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Cyan700, primaryScheme);
break;
case ColorSchemes.DeepOrange:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.DeepOrange700, primaryScheme);
break;
case ColorSchemes.DeepPurple:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.DeepPurple700, primaryScheme);
break;
case ColorSchemes.Green:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Green700, primaryScheme);
break;
case ColorSchemes.LightBlue:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.LightBlue700, primaryScheme);
break;
case ColorSchemes.LightGreen:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.LightGreen700, primaryScheme);
break;
case ColorSchemes.Purple:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Purple700, primaryScheme);
break;
case ColorSchemes.Teal:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Teal700, primaryScheme);
break;
case ColorSchemes.Yellow:
Program.F1.materialSkinManager.ColorScheme = MakeScheme(ms.Accent.Yellow700, primaryScheme);
break;
}
}
///<summary>
///Gets primary colors
///</summary>
private ms.Primary[] GetPrimaryColors()
{
Log("Info", $"Applying primary color {PrimaryColor}");
switch (PrimaryColor)
{
default:
return new ms.Primary[] { ms.Primary.Indigo800, ms.Primary.Indigo900, ms.Primary.Indigo400 };
case ColorSchemes.Lime:
return new ms.Primary[] { ms.Primary.Lime800, ms.Primary.Lime900, ms.Primary.Lime400 };
case ColorSchemes.Red:
return new ms.Primary[] { ms.Primary.Red800, ms.Primary.Red900, ms.Primary.Red400 };
case ColorSchemes.Pink:
return new ms.Primary[] { ms.Primary.Pink800, ms.Primary.Pink900, ms.Primary.Pink400 };
case ColorSchemes.Orange:
return new ms.Primary[] { ms.Primary.Orange800, ms.Primary.Orange900, ms.Primary.Orange400 };
case ColorSchemes.Amber:
return new ms.Primary[] { ms.Primary.Amber800, ms.Primary.Amber900, ms.Primary.Amber400 };
case ColorSchemes.Blue:
return new ms.Primary[] { ms.Primary.Blue800, ms.Primary.Blue900, ms.Primary.Blue400 };
case ColorSchemes.Cyan:
return new ms.Primary[] { ms.Primary.Cyan800, ms.Primary.Cyan900, ms.Primary.Cyan400 };
case ColorSchemes.DeepOrange:
return new ms.Primary[] { ms.Primary.DeepOrange800, ms.Primary.DeepOrange900, ms.Primary.DeepOrange400 };
case ColorSchemes.DeepPurple:
return new ms.Primary[] { ms.Primary.DeepPurple800, ms.Primary.DeepPurple900, ms.Primary.DeepPurple400 };
case ColorSchemes.Green:
return new ms.Primary[] { ms.Primary.Green800, ms.Primary.Green900, ms.Primary.Green400 };
case ColorSchemes.LightBlue:
return new ms.Primary[] { ms.Primary.LightBlue800, ms.Primary.LightBlue900, ms.Primary.LightBlue400 };
case ColorSchemes.LightGreen:
return new ms.Primary[] { ms.Primary.LightGreen800, ms.Primary.LightGreen900, ms.Primary.LightGreen400 };
case ColorSchemes.Purple:
return new ms.Primary[] { ms.Primary.Purple800, ms.Primary.Purple900, ms.Primary.Purple400 };
case ColorSchemes.Teal:
return new ms.Primary[] { ms.Primary.Teal800, ms.Primary.Teal900, ms.Primary.Teal400 };
case ColorSchemes.Yellow:
return new ms.Primary[] { ms.Primary.Yellow800, ms.Primary.Yellow900, ms.Primary.Yellow400 };
}
}
///<summary>
///Logs an event
///</summary>
///<param name="e">Desired event type</param>
///<param name="message">Description of the event</param>
public void Log(string e, string message, string source = "")
{
string msg = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] " + e + " - " + message;
if (source != "")
{
msg += $" @{source}";
}
if ((log1.Count != 0) && (log1[log1.Count - 1] == msg)) // ignore duplicates
{
return;
}
if ((Program.spl != null) && Program.spl.Visible && !Program.spl.IsDisposed && !message.Contains("Safely closing"))
{
Program.spl.BeginInvoke(new MethodInvoker(delegate {
Program.spl.UpdateMsg();
}));
} else if (message.Contains("Safely closing"))
{
if ((Program.spl == null) || !Program.spl.Visible)
{
return;
}
Program.spl.BeginInvoke(new MethodInvoker(delegate {
Program.spl.Close();
}));
Thread.Sleep(250);
if (Program.gs.LegacyUI && (Program.F1 != null) && Program.F2.Visible)
{
Program.F2.BeginInvoke(new MethodInvoker(delegate {
Program.F2.BringToFront();
}));
} else if ((Program.F1 != null) && Program.F1.Visible)
{
Program.F1.BeginInvoke(new MethodInvoker(delegate {
Program.F1.BringToFront();
}));
}
}
Program.load_message = message;
log1.Add(msg);
}
///<summary>
///Gets all logged events
///</summary>
///<param name="reverse">Allows the log to be reversed, making the recent events show up first (default behaviour). If you don't want the log to be reverse, set this value to false.</param>
///<returns>A string containing all logged events</returns>
public string GetLog(bool reverse = true)
{
if (reverse) { log1.Reverse(); }
string ret = string.Join("\n", log1.ToArray());
if (reverse) { log1.Reverse(); }
return ret;
}
}
}