Default to Windows' theme

This commit is contained in:
Assistant 2020-02-16 17:39:52 -07:00
parent b367c412a0
commit 87f540853c
4 changed files with 38 additions and 25 deletions

View file

@ -45,7 +45,7 @@
<value />
</setting>
<setting name="SelectedTheme" serializeAs="String">
<value>Light</value>
<value />
</setting>
</ModAssistant.Properties.Settings>
<ModAssistant.Settings1>

View file

@ -60,6 +60,28 @@ namespace ModAssistant
}
}
/// <summary>
/// Runs once at the start of the program, performs settings checking.
/// </summary>
/// <param name="savedTheme">Theme name retrieved from the settings file.</param>
public static void FirstLoad(string savedTheme)
{
if (savedTheme == "")
{
Themes.ApplyWindowsTheme();
return;
}
try
{
Themes.ApplyTheme(savedTheme, false);
}
catch (ArgumentException)
{
Themes.ApplyWindowsTheme();
MainWindow.Instance.MainText = "Theme not found, reverting to default theme...";
}
}
/// <summary>
/// Applies a loaded theme to ModAssistant.
/// </summary>
@ -76,7 +98,7 @@ namespace ModAssistant
Properties.Settings.Default.Save();
if (sendMessage)
{
MainWindow.Instance.MainText = $"Theme changed to {theme}.";
MainWindow.Instance.MainText = $"Theme set to {theme}.";
}
ReloadIcons();
}

View file

@ -61,22 +61,7 @@ namespace ModAssistant
}
Themes.LoadThemes();
try
{
if (Properties.Settings.Default.SelectedTheme != null)
{
Themes.ApplyTheme(Properties.Settings.Default.SelectedTheme, false);
}
else
{
Themes.ApplyWindowsTheme();
}
}
catch (ArgumentException)
{
Themes.ApplyTheme("Light", false);
MainText = "Theme not found, reverting to Light theme...";
}
Themes.FirstLoad(Properties.Settings.Default.SelectedTheme);
List<string> versions;
string json = string.Empty;

View file

@ -251,9 +251,13 @@ namespace ModAssistant.Pages
{
if ((sender as ComboBox).SelectedItem == null)
{
Themes.ApplyTheme("Light");
MainWindow.Instance.MainText = "Current theme has been removed, reverting to Light...";
}else Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString());
Themes.ApplyWindowsTheme();
MainWindow.Instance.MainText = "Current theme has been removed, reverting to default...";
}
else
{
Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString());
}
}
private void ApplicationThemeExportTemplate_Click(object sender, RoutedEventArgs e)
@ -265,10 +269,12 @@ namespace ModAssistant.Pages
{
if (Directory.Exists(Themes.ThemeDirectory))
{
//Code yeeted from ChroMapper
string winPath = Themes.ThemeDirectory.Replace("/", "\\").Replace("\\\\", "\\");
System.Diagnostics.Process.Start("explorer.exe", winPath);
}else MessageBox.Show("Themes folder not found! Try exporting the template...");
System.Diagnostics.Process.Start(Themes.ThemeDirectory);
}
else
{
MessageBox.Show("Themes folder not found! Try exporting the template...");
}
}
}
}