diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 0e8cf2f..4ac5a27 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -35,12 +35,15 @@ namespace ModAssistant //Ignore Themes without the xaml extension and ignore themes with the same names as others. //If requests are made I can instead make a Theme class that splits the pre-installed themes from //user-made ones so that one more user-made Light/Dark theme can be added. - if (info.Extension.ToLowerInvariant() == "xaml" && !loadedThemes.ContainsKey(info.Name)) + MessageBox.Show(info.Extension); + if (info.Extension.ToLower().Contains("xaml")) { - ResourceDictionary theme = LoadTheme(info.Name); + string name = info.Name.Split('.').First(); + MessageBox.Show(name); + ResourceDictionary theme = LoadTheme(name); if (theme != null) { - loadedThemes.Add(info.Name, theme); + loadedThemes.Add(name, theme); } } } @@ -102,8 +105,10 @@ namespace ModAssistant if (!File.Exists($@"{ThemeDirectory}\\{themeName}.xaml")) { - + //Store a local copy of the theme to prevent exceptions trying to access the saved copy while it's being written to. ResourceDictionary dictionary = LoadTheme(themeName, true); + loadedThemes.Add(themeName, dictionary); + Options.Instance.ApplicationThemeComboBox.ItemsSource = LoadedThemes; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index e4e378c..ed4ab3a 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -249,13 +249,16 @@ namespace ModAssistant.Pages private void ApplicationThemeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString(), this); + if ((sender as ComboBox).SelectedItem == null) + { + Themes.ApplyTheme("Light", this); + MainWindow.Instance.MainText = "Current theme has been removed, reverting to Light..."; + }else Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString(), this); } private void ApplicationThemeExportTemplate_Click(object sender, RoutedEventArgs e) { Themes.WriteThemeToDisk("Light Pink"); - Themes.LoadThemes(); } private void ApplicationThemeOpenThemesFolder_Click(object sender, RoutedEventArgs e)