Add setting for theme, they now persistent through instances

This commit is contained in:
Caeden Statia 2020-02-07 17:13:41 -08:00
parent 4e0e7c1900
commit bd222a5f17
5 changed files with 23 additions and 2 deletions

View file

@ -44,6 +44,9 @@
<setting name="LastTab" serializeAs="String">
<value />
</setting>
<setting name="SelectedTheme" serializeAs="String">
<value>Light</value>
</setting>
</ModAssistant.Properties.Settings>
<ModAssistant.Settings1>
<setting name="InstallFolder" serializeAs="String">

View file

@ -71,6 +71,9 @@ namespace ModAssistant
Application.Current.Resources.MergedDictionaries.RemoveAt(0);
LoadedTheme = theme;
Application.Current.Resources.MergedDictionaries.Insert(0, newTheme);
Properties.Settings.Default.SelectedTheme = theme;
Properties.Settings.Default.Save();
MainWindow.Instance.MainText = $"Theme changed to {theme}.";
ReloadIcons();
}
else throw new ArgumentException($"{theme} does not exist.");

View file

@ -63,7 +63,7 @@ namespace ModAssistant
Themes.LoadThemes();
try
{
Themes.ApplyTheme("Light");
Themes.ApplyTheme(Properties.Settings.Default.SelectedTheme);
}
catch (ArgumentException)
{

View file

@ -12,7 +12,7 @@ namespace ModAssistant.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -154,5 +154,17 @@ namespace ModAssistant.Properties {
this["LastTab"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Light")]
public string SelectedTheme {
get {
return ((string)(this["SelectedTheme"]));
}
set {
this["SelectedTheme"] = value;
}
}
}
}

View file

@ -35,5 +35,8 @@
<Setting Name="LastTab" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SelectedTheme" Type="System.String" Scope="User">
<Value Profile="(Default)">Light</Value>
</Setting>
</Settings>
</SettingsFile>