/
App.xaml.cs
104 lines (82 loc) · 2.59 KB
/
App.xaml.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.IO;
namespace Sonic3AIR_ModManager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
///
public enum Skin { Dark, Light }
public partial class App : Application
{
public static App Instance;
public static Skin Skin { get; set; } = Skin.Dark;
public static bool SkinChanged { get; set; } = false;
public App()
{
if (Sonic3AIR_ModManager.MainDataModel.Settings.UseDarkTheme == true) ChangeSkin(Skin.Dark);
else ChangeSkin(Skin.Light);
DebugDisable();
Instance = this;
this.InitializeComponent();
}
#region Launch
public void RunAutoBoot(bool isForced = false)
{
int? value = null;
if (isForced)
{
Program.Log.InfoFormat("Starting in forced auto-boot mode...");
value = 7;
}
else Program.Log.InfoFormat("Starting Auto-Boot Mode...");
var auto = new AutoBootDialog(value);
if (auto.ShowDialog() == true)
{
if (Program.AutoBootCanceled == false)
{
this.Run(new ModManager(true));
}
else if (!isForced) this.Run(new ModManager(false));
}
}
public void GBAPI(string Arguments)
{
Program.Log.InfoFormat("Starting Mod Manager with GB API Arguments...");
this.Run(new ModManager(Arguments));
}
public void DefaultStart()
{
Program.Log.InfoFormat("Starting Mod Manager...");
this.Run(new ModManager());
}
#endregion
#region Misc
private void DebugDisable()
{
#if DEBUG
System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical;
#endif
}
public static void ChangeSkin(Skin newSkin)
{
Skin = newSkin;
foreach (ResourceDictionary dict in Sonic3AIR_ModManager.App.Current.Resources.MergedDictionaries)
{
if (dict is SkinResourceDictionary skinDict)
skinDict.UpdateSource();
else
dict.Source = dict.Source;
}
}
#endregion
}
}