From 0746527aacde79e54d1aeda6cae181fc1e500726 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 31 Jan 2020 18:58:42 -0800 Subject: [PATCH 01/61] Start work on theme support for Mod Assistant --- ModAssistant/App.xaml | 286 ++++++++++++++++++++++++++++++- ModAssistant/ModAssistant.csproj | 4 + ModAssistant/Themes/Blue.xaml | 51 ++++++ 3 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 ModAssistant/Themes/Blue.xaml diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index 28e6858..5807175 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -4,6 +4,290 @@ DispatcherUnhandledException="Application_DispatcherUnhandledException" Startup="Application_Startup"> - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj index 6f66c32..db170d5 100644 --- a/ModAssistant/ModAssistant.csproj +++ b/ModAssistant/ModAssistant.csproj @@ -115,6 +115,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/ModAssistant/Themes/Blue.xaml b/ModAssistant/Themes/Blue.xaml new file mode 100644 index 0000000..964a047 --- /dev/null +++ b/ModAssistant/Themes/Blue.xaml @@ -0,0 +1,51 @@ + + + Tahoma + #FF1E90FF + #454545 + #2E2E2E + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8d4ffd0e354b93a67b14f72d552cb25e0a3a8ab1 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 31 Jan 2020 19:04:01 -0800 Subject: [PATCH 02/61] Rename Blue.xaml to Dark.xaml --- ModAssistant/App.xaml | 2 +- ModAssistant/ModAssistant.csproj | 2 +- ModAssistant/Themes/{Blue.xaml => Dark.xaml} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename ModAssistant/Themes/{Blue.xaml => Dark.xaml} (100%) diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index 5807175..1778246 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -6,7 +6,7 @@ - + + + diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 964a047..93f0a6a 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -47,5 +47,7 @@ + + \ No newline at end of file From 637cf096fd3cbbabc9cc2874b6a2d4230b67bce9 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 31 Jan 2020 20:13:08 -0800 Subject: [PATCH 04/61] Add Rectangle to MainWindow for background color --- ModAssistant/App.xaml | 4 +- ModAssistant/MainWindow.xaml | 171 +++++++++++++++++----------------- ModAssistant/Themes/Dark.xaml | 2 +- 3 files changed, 90 insertions(+), 87 deletions(-) diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index b466329..ebfa1dd 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -288,8 +288,8 @@ - diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index 7b69e67..1b3e668 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -8,95 +8,98 @@ Icon="Resources/icon.ico" Title="Mod Assistant" Width="1280" Height="720" UIElement.PreviewMouseDown="Window_PreviewMouseDown"> - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - + - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + + + + + diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 93f0a6a..6610e77 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -48,6 +48,6 @@ - + \ No newline at end of file From 88f3078232518cca1030a4a526e4c6ccd4a31a9e Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 31 Jan 2020 20:13:17 -0800 Subject: [PATCH 05/61] Removed unneeded style nodes --- ModAssistant/App.xaml | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index ebfa1dd..e9427bf 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -9,35 +9,6 @@ - - - - + + + + diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 8385f1b..7d1d692 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -20,6 +20,12 @@ + + + + + + @@ -29,8 +35,9 @@ - + + From 539696c630dd58a2919f9bd5b6cec39c07659505 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 31 Jan 2020 22:05:52 -0800 Subject: [PATCH 13/61] Commented Dark theme for future reference --- ModAssistant/Themes/Dark.xaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 7d1d692..8041e55 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -1,31 +1,34 @@  - - + + - + + + + @@ -36,8 +39,12 @@ + + + + From b952efc5ee76987fe2351a6c0f25b5e2547dfb7e Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 31 Jan 2020 22:23:00 -0800 Subject: [PATCH 14/61] Add more comments and change icon colors for Dark theme --- ModAssistant/Themes/Dark.xaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 8041e55..f8b7404 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -45,9 +45,13 @@ - - - - + + + + + + + + \ No newline at end of file From 501e3e53220edccc7087c276632f6e05e14c4297 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 1 Feb 2020 08:29:07 -0800 Subject: [PATCH 15/61] Offload Control styles from App.xaml to a Styles folder --- ModAssistant/App.xaml | 359 +----------------- ModAssistant/MainWindow.xaml | 2 +- ModAssistant/ModAssistant.csproj | 40 ++ ModAssistant/Styles/Button.xaml | 44 +++ ModAssistant/Styles/CheckBox.xaml | 76 ++++ ModAssistant/Styles/ComboBox.xaml | 6 + ModAssistant/Styles/ComboBoxItem.xaml | 82 ++++ ModAssistant/Styles/GridViewColumnHeader.xaml | 51 +++ ModAssistant/Styles/Label.xaml | 28 ++ ModAssistant/Styles/ListView.xaml | 5 + ModAssistant/Styles/ListViewItem.xaml | 42 ++ ModAssistant/Styles/Rectangle.xaml | 5 + ModAssistant/Styles/TextBlock.xaml | 7 + 13 files changed, 403 insertions(+), 344 deletions(-) create mode 100644 ModAssistant/Styles/Button.xaml create mode 100644 ModAssistant/Styles/CheckBox.xaml create mode 100644 ModAssistant/Styles/ComboBox.xaml create mode 100644 ModAssistant/Styles/ComboBoxItem.xaml create mode 100644 ModAssistant/Styles/GridViewColumnHeader.xaml create mode 100644 ModAssistant/Styles/Label.xaml create mode 100644 ModAssistant/Styles/ListView.xaml create mode 100644 ModAssistant/Styles/ListViewItem.xaml create mode 100644 ModAssistant/Styles/Rectangle.xaml create mode 100644 ModAssistant/Styles/TextBlock.xaml diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index 64974bb..432619b 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -6,351 +6,24 @@ - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index 8d60ef2..6b994cd 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -80,7 +80,7 @@ - + From 055d5042a395be7439868e5f7d7491aa0c8dcb6a Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 2 Feb 2020 22:41:38 -0800 Subject: [PATCH 23/61] Made Options UI better, on to code --- ModAssistant/Pages/Options.xaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index 212d14b..cc84a0b 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -67,9 +67,9 @@ - - - + + + From 05fb6312d73b6b58cb3f77c2f08c5fa2cc52e1d3 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 2 Feb 2020 22:48:03 -0800 Subject: [PATCH 24/61] Remove Classes namespace from Themes class --- ModAssistant/Classes/Themes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 5e5276f..a691b4f 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using System.Windows; using System.IO; -namespace ModAssistant.Classes +namespace ModAssistant { public class Themes { From 359f0a91cd6710ab5890f1c70d2296c980666177 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 2 Feb 2020 22:53:12 -0800 Subject: [PATCH 25/61] (Untested) Add code to combo box --- ModAssistant/Classes/Themes.cs | 1 + ModAssistant/MainWindow.xaml.cs | 4 ++-- ModAssistant/Pages/Options.xaml | 4 ++-- ModAssistant/Pages/Options.xaml.cs | 8 ++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index a691b4f..0d572db 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -11,6 +11,7 @@ namespace ModAssistant public class Themes { public static string LoadedTheme { get; private set; } + public static List LoadedThemes { get => loadedThemes.Keys.ToList(); } private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark" }; diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index 07d7caa..58ba588 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -60,8 +60,8 @@ namespace ModAssistant return; } - Classes.Themes.LoadThemes(); - Classes.Themes.ApplyTheme("Light"); + Themes.LoadThemes(); + Themes.ApplyTheme("Light"); List versions; string json = string.Empty; diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index cc84a0b..c1898a3 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -68,8 +68,8 @@ - - + + diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index cec36d1..c45c78a 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -53,6 +53,9 @@ namespace ModAssistant.Pages UpdateHandlerStatus(); this.DataContext = this; + + ApplicationThemeComboBox.ItemsSource = Themes.LoadedThemes; + ApplicationThemeComboBox.SelectedItem = Themes.LoadedTheme; } public void UpdateHandlerStatus() @@ -245,5 +248,10 @@ namespace ModAssistant.Pages MainWindow.Instance.MainText = "All Mods Uninstalled..."; } } + + private void ApplicationThemeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString()); + } } } From 8a680df02851a4ffaa3aaafd05db8244957c827c Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 2 Feb 2020 23:09:19 -0800 Subject: [PATCH 26/61] Fix bugs and add event for export template --- ModAssistant/Pages/Options.xaml | 2 +- ModAssistant/Pages/Options.xaml.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index c1898a3..16ada9b 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -69,7 +69,7 @@ - + diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index c45c78a..b6d6f21 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -18,6 +18,7 @@ using Path = System.IO.Path; using System.Net; using System.Web.Script.Serialization; using System.Web; +using System.ComponentModel; namespace ModAssistant.Pages { @@ -54,8 +55,12 @@ namespace ModAssistant.Pages this.DataContext = this; - ApplicationThemeComboBox.ItemsSource = Themes.LoadedThemes; - ApplicationThemeComboBox.SelectedItem = Themes.LoadedTheme; + if (!DesignerProperties.GetIsInDesignMode(this)) + { + if (!Themes.LoadedThemes.Any()) Themes.LoadThemes(); + ApplicationThemeComboBox.ItemsSource = Themes.LoadedThemes; + ApplicationThemeComboBox.SelectedValue = Themes.LoadedTheme; + } } public void UpdateHandlerStatus() @@ -253,5 +258,10 @@ namespace ModAssistant.Pages { Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString()); } + + private void ApplicationThemeExportTemplate_Click(object sender, RoutedEventArgs e) + { + MessageBox.Show("nice going laughShorts this is coming soon"); + } } } From b5c71387a6968ed9421393d5e73de040f41685c7 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 2 Feb 2020 23:10:55 -0800 Subject: [PATCH 27/61] Center content in theme combo box --- ModAssistant/Pages/Options.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index 16ada9b..5bfcce9 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -68,7 +68,7 @@ - + From 9f0e7eb18c1a2f7c6ebd0e89da441c74d998eb72 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 15:38:38 -0800 Subject: [PATCH 28/61] Fix button icons not changing colors with theme with only a slightly hacky fix --- ModAssistant/Classes/Themes.cs | 22 +++++++++++++++++++--- ModAssistant/MainWindow.xaml.cs | 2 +- ModAssistant/Pages/Options.xaml.cs | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 0d572db..1b25d7e 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.IO; +using System.Windows.Media; namespace ModAssistant { @@ -56,7 +55,7 @@ namespace ModAssistant return dictionary; } - public static void ApplyTheme(string theme) + public static void ApplyTheme(string theme, FrameworkElement element) { ResourceDictionary newTheme = loadedThemes[theme]; if (newTheme != null) @@ -64,8 +63,25 @@ namespace ModAssistant Application.Current.Resources.MergedDictionaries.RemoveAt(0); LoadedTheme = theme; Application.Current.Resources.MergedDictionaries.Insert(0, newTheme); + ReloadIcons(element); } else throw new ArgumentException($"{theme} does not exist."); } + + private static void ReloadIcons(FrameworkElement element) + { + ResourceDictionary icons = Application.Current.Resources.MergedDictionaries.First(x => x.Source.ToString() == "Resources/Icons.xaml"); + + ChangeColor(element, icons, "AboutIconColor", "heartDrawingGroup"); + ChangeColor(element, icons, "InfoIconColor", "info_circleDrawingGroup"); + ChangeColor(element, icons, "OptionsIconColor", "cogDrawingGroup"); + ChangeColor(element, icons, "ModsIconColor", "microchipDrawingGroup"); + } + + private static void ChangeColor(FrameworkElement element, ResourceDictionary icons, string ResourceColorName, string DrawingGroupName) + { + element.Resources[ResourceColorName] = loadedThemes[LoadedTheme][ResourceColorName]; + ((GeometryDrawing)((DrawingGroup)icons[DrawingGroupName]).Children[0]).Brush = (Brush)element.Resources[ResourceColorName]; + } } } diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index 58ba588..a4609a6 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -61,7 +61,7 @@ namespace ModAssistant } Themes.LoadThemes(); - Themes.ApplyTheme("Light"); + Themes.ApplyTheme("Light", this); List versions; string json = string.Empty; diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index b6d6f21..5518ebe 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -256,7 +256,7 @@ namespace ModAssistant.Pages private void ApplicationThemeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString()); + Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString(), this); } private void ApplicationThemeExportTemplate_Click(object sender, RoutedEventArgs e) From 9cb7935ce4449e29c2f5dec76bb48ce09e3a0c5f Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 15:41:01 -0800 Subject: [PATCH 29/61] Added try catch when initially loading theme --- ModAssistant/MainWindow.xaml.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index a4609a6..a1881e1 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -61,7 +61,14 @@ namespace ModAssistant } Themes.LoadThemes(); - Themes.ApplyTheme("Light", this); + try + { + Themes.ApplyTheme("Light", this); + }catch (ArgumentException) + { + Themes.ApplyTheme("Light", this); + MainText = "Theme not found, reverting to Light theme..."; + } List versions; string json = string.Empty; From d7676b4ba9b29524e1548d84871bf4ccdacdf3b0 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 15:49:03 -0800 Subject: [PATCH 30/61] Add "Open Folder" button for Themes --- ModAssistant/Pages/Options.xaml | 18 ++++++++++++++---- ModAssistant/Pages/Options.xaml.cs | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index 5bfcce9..25b8a4f 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -66,10 +66,20 @@ - - - - + + + + + + + + + + + + + + diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index 5518ebe..dc5ba26 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -263,5 +263,10 @@ namespace ModAssistant.Pages { MessageBox.Show("nice going laughShorts this is coming soon"); } + + private void ApplicationThemeOpenThemesFolder_Click(object sender, RoutedEventArgs e) + { + MessageBox.Show("nice going laughShorts this is coming soon"); + } } } From c07f6da8ceac99f6fd24e3f2c4113fef9c346ca1 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 15:55:01 -0800 Subject: [PATCH 31/61] Open Themes folder working --- ModAssistant/Classes/Themes.cs | 8 ++++++-- ModAssistant/Pages/Options.xaml | 4 ++-- ModAssistant/Pages/Options.xaml.cs | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 1b25d7e..154e3f0 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Windows; using System.IO; using System.Windows.Media; +using ModAssistant.Pages; namespace ModAssistant { @@ -11,6 +12,7 @@ namespace ModAssistant { public static string LoadedTheme { get; private set; } public static List LoadedThemes { get => loadedThemes.Keys.ToList(); } + public static string ThemeDirectory => $"{Environment.CurrentDirectory}/Themes"; private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark" }; @@ -23,9 +25,9 @@ namespace ModAssistant ResourceDictionary theme = LoadTheme(localTheme, true); loadedThemes.Add(localTheme, theme); } - if (Directory.Exists($"{Environment.CurrentDirectory}/Themes")) + if (Directory.Exists(ThemeDirectory)) { - foreach (string file in Directory.EnumerateFiles($"{Environment.CurrentDirectory}/Themes")) + foreach (string file in Directory.EnumerateFiles(ThemeDirectory)) { FileInfo info = new FileInfo(file); //Ignore Themes without the xaml extension and ignore themes with the same names as others. @@ -42,6 +44,8 @@ namespace ModAssistant } //MessageBox.Show($"(DEBUG) Loaded {loadedThemes.Count - 2} themes from Themes folder."); } + if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null) + Options.Instance.ApplicationThemeComboBox.ItemsSource = LoadedThemes; } private static ResourceDictionary LoadTheme(string name, bool localUri = false) diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index 25b8a4f..950fec0 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -67,14 +67,14 @@ - + - + diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index dc5ba26..14aac81 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -58,7 +58,6 @@ namespace ModAssistant.Pages if (!DesignerProperties.GetIsInDesignMode(this)) { if (!Themes.LoadedThemes.Any()) Themes.LoadThemes(); - ApplicationThemeComboBox.ItemsSource = Themes.LoadedThemes; ApplicationThemeComboBox.SelectedValue = Themes.LoadedTheme; } } @@ -266,7 +265,12 @@ namespace ModAssistant.Pages private void ApplicationThemeOpenThemesFolder_Click(object sender, RoutedEventArgs e) { - MessageBox.Show("nice going laughShorts this is coming soon"); + 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..."); } } } From 23a94aa36ca56fb8dc2ace3685eb5364f8c0eb97 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 16:02:05 -0800 Subject: [PATCH 32/61] Switch Margin from TextBlock to StackPanel --- ModAssistant/Pages/Options.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index 950fec0..27a0b44 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -67,14 +67,14 @@ - + - + From 1c25ceb0c798a826c32209c7b68ce4acf87ae678 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 16:13:27 -0800 Subject: [PATCH 33/61] Fix current theme not being selected in dropdown --- ModAssistant/Classes/Themes.cs | 3 +++ ModAssistant/MainWindow.xaml.cs | 5 ++++- ModAssistant/Pages/Options.xaml.cs | 6 ------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 154e3f0..d8d485e 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -45,7 +45,10 @@ namespace ModAssistant //MessageBox.Show($"(DEBUG) Loaded {loadedThemes.Count - 2} themes from Themes folder."); } if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null) + { Options.Instance.ApplicationThemeComboBox.ItemsSource = LoadedThemes; + Options.Instance.ApplicationThemeComboBox.SelectedIndex = LoadedThemes.IndexOf(LoadedTheme); + } } private static ResourceDictionary LoadTheme(string name, bool localUri = false) diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index a1881e1..9bdbe94 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -64,7 +64,8 @@ namespace ModAssistant try { Themes.ApplyTheme("Light", this); - }catch (ArgumentException) + } + catch (ArgumentException) { Themes.ApplyTheme("Light", this); MainText = "Theme not found, reverting to Light theme..."; @@ -124,6 +125,7 @@ namespace ModAssistant break; case "Options": Main.Content = Options.Instance; + Themes.LoadThemes(); break; default: Main.Content = Intro.Instance; @@ -191,6 +193,7 @@ namespace ModAssistant private void OptionsButton_Click(object sender, RoutedEventArgs e) { Main.Content = Options.Instance; + Themes.LoadThemes(); Properties.Settings.Default.LastTab = "Options"; Properties.Settings.Default.Save(); } diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index 14aac81..4fbb75b 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -54,12 +54,6 @@ namespace ModAssistant.Pages UpdateHandlerStatus(); this.DataContext = this; - - if (!DesignerProperties.GetIsInDesignMode(this)) - { - if (!Themes.LoadedThemes.Any()) Themes.LoadThemes(); - ApplicationThemeComboBox.SelectedValue = Themes.LoadedTheme; - } } public void UpdateHandlerStatus() From f25fe2ade2754991df33125b594c2fae9eb08b8c Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 16:32:48 -0800 Subject: [PATCH 34/61] Added a Light Pink theme for the purpose of being a template --- ModAssistant/ModAssistant.csproj | 4 ++ ModAssistant/Themes/Light Pink.xaml | 66 +++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 ModAssistant/Themes/Light Pink.xaml diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj index 662739e..4a69b8e 100644 --- a/ModAssistant/ModAssistant.csproj +++ b/ModAssistant/ModAssistant.csproj @@ -172,6 +172,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/ModAssistant/Themes/Light Pink.xaml b/ModAssistant/Themes/Light Pink.xaml new file mode 100644 index 0000000..ec4fce0 --- /dev/null +++ b/ModAssistant/Themes/Light Pink.xaml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From dd68fa16c18958c7a503e71aeea621f52ef647c5 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 16:46:20 -0800 Subject: [PATCH 35/61] You can now export Light Pink to disk --- ModAssistant/Classes/Themes.cs | 23 +++++++++++++++++++++++ ModAssistant/Pages/Options.xaml.cs | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index d8d485e..0e8cf2f 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -5,6 +5,8 @@ using System.Windows; using System.IO; using System.Windows.Media; using ModAssistant.Pages; +using System.Xml; +using System.Windows.Markup; namespace ModAssistant { @@ -90,5 +92,26 @@ namespace ModAssistant element.Resources[ResourceColorName] = loadedThemes[LoadedTheme][ResourceColorName]; ((GeometryDrawing)((DrawingGroup)icons[DrawingGroupName]).Children[0]).Brush = (Brush)element.Resources[ResourceColorName]; } + + public static void WriteThemeToDisk(string themeName) + { + if (!Directory.Exists(ThemeDirectory)) + { + Directory.CreateDirectory(ThemeDirectory); + } + + if (!File.Exists($@"{ThemeDirectory}\\{themeName}.xaml")) + { + + ResourceDictionary dictionary = LoadTheme(themeName, true); + + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Indent = true; + XmlWriter writer = XmlWriter.Create($@"{ThemeDirectory}\\{themeName}.xaml", settings); + XamlWriter.Save(dictionary, writer); + MainWindow.Instance.MainText = $"Template theme \"{themeName}\" saved to Themes folder."; + } + else MessageBox.Show("Template theme already exists!"); + } } } diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index 4fbb75b..e4e378c 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -254,7 +254,8 @@ namespace ModAssistant.Pages private void ApplicationThemeExportTemplate_Click(object sender, RoutedEventArgs e) { - MessageBox.Show("nice going laughShorts this is coming soon"); + Themes.WriteThemeToDisk("Light Pink"); + Themes.LoadThemes(); } private void ApplicationThemeOpenThemesFolder_Click(object sender, RoutedEventArgs e) From 621880a9252907e99b28c572ba641e5cb9236509 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 16:56:29 -0800 Subject: [PATCH 36/61] Fix bugs and crashes with exporting template theme --- ModAssistant/Classes/Themes.cs | 13 +++++++++---- ModAssistant/Pages/Options.xaml.cs | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) 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) From 4e0e7c1900cbb0e05de1d65114b5e2d90c2bc8f2 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 17:09:25 -0800 Subject: [PATCH 37/61] Themes refactoring and commenting --- ModAssistant/Classes/Themes.cs | 100 ++++++++++++++++++----------- ModAssistant/MainWindow.xaml.cs | 4 +- ModAssistant/Pages/Options.xaml.cs | 4 +- 3 files changed, 67 insertions(+), 41 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 4ac5a27..81bc457 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -19,27 +19,30 @@ namespace ModAssistant private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark" }; + /// + /// Load all themes from local Themes subfolder and from embedded resources. + /// This also refreshes the Themes dropdown in the Options screen. + /// public static void LoadThemes() { loadedThemes.Clear(); - foreach (string localTheme in preInstalledThemes) + foreach (string localTheme in preInstalledThemes) //Load local themes (Light and Dark) { ResourceDictionary theme = LoadTheme(localTheme, true); loadedThemes.Add(localTheme, theme); } - if (Directory.Exists(ThemeDirectory)) + if (Directory.Exists(ThemeDirectory)) //Load themes from Themes subfolder if it exists. { foreach (string file in Directory.EnumerateFiles(ThemeDirectory)) { FileInfo info = new FileInfo(file); + //FileInfo includes the extension in its Name field, so we have to split the string and select only the actual name. + string name = info.Name.Split('.').First(); //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. - MessageBox.Show(info.Extension); - if (info.Extension.ToLower().Contains("xaml")) + if (info.Extension.ToLower().Contains("xaml") && !loadedThemes.ContainsKey(name)) { - string name = info.Name.Split('.').First(); - MessageBox.Show(name); ResourceDictionary theme = LoadTheme(name); if (theme != null) { @@ -47,27 +50,20 @@ namespace ModAssistant } } } - //MessageBox.Show($"(DEBUG) Loaded {loadedThemes.Count - 2} themes from Themes folder."); } - if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null) + if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null) //Refresh Themes dropdown in Options screen. { Options.Instance.ApplicationThemeComboBox.ItemsSource = LoadedThemes; Options.Instance.ApplicationThemeComboBox.SelectedIndex = LoadedThemes.IndexOf(LoadedTheme); } } - private static ResourceDictionary LoadTheme(string name, bool localUri = false) - { - string location = $"{Environment.CurrentDirectory}/Themes/{name}.xaml"; - if (!File.Exists(location) && !localUri) return null; - if (localUri) location = $"Themes/{name}.xaml"; - Uri uri = new Uri(location, localUri ? UriKind.Relative : UriKind.Absolute); - ResourceDictionary dictionary = new ResourceDictionary(); - dictionary.Source = uri; - return dictionary; - } - - public static void ApplyTheme(string theme, FrameworkElement element) + /// + /// Applies a loaded theme to ModAssistant. + /// + /// Name of the theme. + /// Page that this is called on (Used for refreshing button icon colors). + public static void ApplyTheme(string theme) { ResourceDictionary newTheme = loadedThemes[theme]; if (newTheme != null) @@ -75,27 +71,15 @@ namespace ModAssistant Application.Current.Resources.MergedDictionaries.RemoveAt(0); LoadedTheme = theme; Application.Current.Resources.MergedDictionaries.Insert(0, newTheme); - ReloadIcons(element); + ReloadIcons(); } else throw new ArgumentException($"{theme} does not exist."); } - private static void ReloadIcons(FrameworkElement element) - { - ResourceDictionary icons = Application.Current.Resources.MergedDictionaries.First(x => x.Source.ToString() == "Resources/Icons.xaml"); - - ChangeColor(element, icons, "AboutIconColor", "heartDrawingGroup"); - ChangeColor(element, icons, "InfoIconColor", "info_circleDrawingGroup"); - ChangeColor(element, icons, "OptionsIconColor", "cogDrawingGroup"); - ChangeColor(element, icons, "ModsIconColor", "microchipDrawingGroup"); - } - - private static void ChangeColor(FrameworkElement element, ResourceDictionary icons, string ResourceColorName, string DrawingGroupName) - { - element.Resources[ResourceColorName] = loadedThemes[LoadedTheme][ResourceColorName]; - ((GeometryDrawing)((DrawingGroup)icons[DrawingGroupName]).Children[0]).Brush = (Brush)element.Resources[ResourceColorName]; - } - + /// + /// Writes a local theme to disk. You cannot write a theme loaded from the Themes subfolder to disk. + /// + /// Name of local theme. public static void WriteThemeToDisk(string themeName) { if (!Directory.Exists(ThemeDirectory)) @@ -118,5 +102,47 @@ namespace ModAssistant } else MessageBox.Show("Template theme already exists!"); } + + /// + /// Loads a ResourceDictionary from either Embedded Resources or from a file location. + /// + /// ResourceDictionary file name. + /// Specifies whether or not to search in Embedded Resources or in the Themes subfolder. + /// + private static ResourceDictionary LoadTheme(string name, bool localUri = false) + { + string location = $"{Environment.CurrentDirectory}/Themes/{name}.xaml"; + if (!File.Exists(location) && !localUri) return null; + if (localUri) location = $"Themes/{name}.xaml"; + Uri uri = new Uri(location, localUri ? UriKind.Relative : UriKind.Absolute); + ResourceDictionary dictionary = new ResourceDictionary(); + dictionary.Source = uri; + return dictionary; + } + + /// + /// Reload the icon colors for the About, Info, Options, and Mods buttons from the currently loaded theme. + /// + private static void ReloadIcons() + { + ResourceDictionary icons = Application.Current.Resources.MergedDictionaries.First(x => x.Source.ToString() == "Resources/Icons.xaml"); + + ChangeColor(icons, "AboutIconColor", "heartDrawingGroup"); + ChangeColor(icons, "InfoIconColor", "info_circleDrawingGroup"); + ChangeColor(icons, "OptionsIconColor", "cogDrawingGroup"); + ChangeColor(icons, "ModsIconColor", "microchipDrawingGroup"); + } + + /// + /// Change the color of an image from the loaded theme. + /// + /// ResourceDictionary that contains the image. + /// Resource name of the color to change. + /// DrawingGroup name for the image. + private static void ChangeColor(ResourceDictionary icons, string ResourceColorName, string DrawingGroupName) + { + Application.Current.Resources[ResourceColorName] = loadedThemes[LoadedTheme][ResourceColorName]; + ((GeometryDrawing)((DrawingGroup)icons[DrawingGroupName]).Children[0]).Brush = (Brush)Application.Current.Resources[ResourceColorName]; + } } } diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index 9bdbe94..e60811f 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -63,11 +63,11 @@ namespace ModAssistant Themes.LoadThemes(); try { - Themes.ApplyTheme("Light", this); + Themes.ApplyTheme("Light"); } catch (ArgumentException) { - Themes.ApplyTheme("Light", this); + Themes.ApplyTheme("Light"); MainText = "Theme not found, reverting to Light theme..."; } diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index ed4ab3a..b7e4dd5 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -251,9 +251,9 @@ namespace ModAssistant.Pages { if ((sender as ComboBox).SelectedItem == null) { - Themes.ApplyTheme("Light", this); + Themes.ApplyTheme("Light"); MainWindow.Instance.MainText = "Current theme has been removed, reverting to Light..."; - }else Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString(), this); + }else Themes.ApplyTheme((sender as ComboBox).SelectedItem.ToString()); } private void ApplicationThemeExportTemplate_Click(object sender, RoutedEventArgs e) From bd222a5f1729f26eb2bba6e9eda7f0507bfaceea Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 17:13:41 -0800 Subject: [PATCH 38/61] Add setting for theme, they now persistent through instances --- ModAssistant/App.config | 3 +++ ModAssistant/Classes/Themes.cs | 3 +++ ModAssistant/MainWindow.xaml.cs | 2 +- ModAssistant/Properties/Settings.Designer.cs | 14 +++++++++++++- ModAssistant/Properties/Settings.settings | 3 +++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ModAssistant/App.config b/ModAssistant/App.config index b281c7c..2d7113d 100644 --- a/ModAssistant/App.config +++ b/ModAssistant/App.config @@ -44,6 +44,9 @@ + + Light + diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 81bc457..17e5a1e 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -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."); diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index e60811f..4907cb0 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -63,7 +63,7 @@ namespace ModAssistant Themes.LoadThemes(); try { - Themes.ApplyTheme("Light"); + Themes.ApplyTheme(Properties.Settings.Default.SelectedTheme); } catch (ArgumentException) { diff --git a/ModAssistant/Properties/Settings.Designer.cs b/ModAssistant/Properties/Settings.Designer.cs index 7fd2b22..54f6374 100644 --- a/ModAssistant/Properties/Settings.Designer.cs +++ b/ModAssistant/Properties/Settings.Designer.cs @@ -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; + } + } } } diff --git a/ModAssistant/Properties/Settings.settings b/ModAssistant/Properties/Settings.settings index fb36c01..6f7793a 100644 --- a/ModAssistant/Properties/Settings.settings +++ b/ModAssistant/Properties/Settings.settings @@ -35,5 +35,8 @@ + + Light + \ No newline at end of file From eaba02cfc50f864279b061cc0e52dfe413915aca Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 7 Feb 2020 17:26:06 -0800 Subject: [PATCH 39/61] Add some foolproofing --- ModAssistant/Classes/Themes.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 17e5a1e..f35e739 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -65,8 +65,7 @@ namespace ModAssistant /// Page that this is called on (Used for refreshing button icon colors). public static void ApplyTheme(string theme) { - ResourceDictionary newTheme = loadedThemes[theme]; - if (newTheme != null) + if (loadedThemes.TryGetValue(theme, out ResourceDictionary newTheme)) { Application.Current.Resources.MergedDictionaries.RemoveAt(0); LoadedTheme = theme; @@ -119,7 +118,15 @@ namespace ModAssistant if (localUri) location = $"Themes/{name}.xaml"; Uri uri = new Uri(location, localUri ? UriKind.Relative : UriKind.Absolute); ResourceDictionary dictionary = new ResourceDictionary(); - dictionary.Source = uri; + try + { + dictionary.Source = uri; + } + catch(Exception ex) + { + MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); + return null; + } return dictionary; } From c222316b4107f32f789f9897dab82b630b36ea31 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Thu, 13 Feb 2020 19:22:30 -0800 Subject: [PATCH 40/61] Fix combo box alignment --- ModAssistant/Styles/ComboBox.xaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ModAssistant/Styles/ComboBox.xaml b/ModAssistant/Styles/ComboBox.xaml index d3f7dfe..2bdc7ee 100644 --- a/ModAssistant/Styles/ComboBox.xaml +++ b/ModAssistant/Styles/ComboBox.xaml @@ -22,7 +22,7 @@ Name="DropDownBorder" BorderBrush="{DynamicResource ComboBoxOutline}" Background="{DynamicResource ComboBoxBackground}" - BorderThickness="1"> + BorderThickness="0"> + SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" + Width="{Binding ActualWidth, ElementName=templateRoot}"/> @@ -48,14 +49,14 @@ + Margin="0"> Date: Thu, 13 Feb 2020 19:49:43 -0800 Subject: [PATCH 41/61] Fix template theme exporting --- ModAssistant/Classes/Themes.cs | 17 ++++++++--------- ModAssistant/ModAssistant.csproj | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index f35e739..0b08d83 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using ModAssistant.Pages; using System.Xml; using System.Windows.Markup; +using System.Reflection; namespace ModAssistant { @@ -91,15 +92,13 @@ 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; - XmlWriter writer = XmlWriter.Create($@"{ThemeDirectory}\\{themeName}.xaml", settings); - XamlWriter.Save(dictionary, writer); + using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream($"ModAssistant.Themes.{themeName}.xaml")) + using (FileStream writer = new FileStream($@"{ThemeDirectory}\\{themeName}.xaml", FileMode.Create)) + { + byte[] buffer = new byte[s.Length]; + int read = s.Read(buffer, 0, (int)s.Length); + writer.Write(buffer, 0, buffer.Length); + } MainWindow.Instance.MainText = $"Template theme \"{themeName}\" saved to Themes folder."; } else MessageBox.Show("Template theme already exists!"); diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj index 4a69b8e..0bd970e 100644 --- a/ModAssistant/ModAssistant.csproj +++ b/ModAssistant/ModAssistant.csproj @@ -172,10 +172,10 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + From 3dbcbaf4810a153921b2ca24774e73ca14485ffd Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Thu, 13 Feb 2020 19:51:43 -0800 Subject: [PATCH 42/61] Add to Light Pink header --- ModAssistant/Themes/Light Pink.xaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ModAssistant/Themes/Light Pink.xaml b/ModAssistant/Themes/Light Pink.xaml index ec4fce0..611ed61 100644 --- a/ModAssistant/Themes/Light Pink.xaml +++ b/ModAssistant/Themes/Light Pink.xaml @@ -6,6 +6,8 @@ Feel free to use this as a template for designing your own themes for Mod Assistant. The Color fields take in Hexadecimal RGB (#RRGGBB) or Hexadecimal ARGB (#AARRGGBB). + They can also take in common names like "Gray", "Maroon", "Magenta", "LimeGreen", etc. + For more information, see: https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors To reload your theme, exit and re-enter the Options menu. --> From 5cbabda14bfbabbbda3aa6ec96b0c1a0a913f160 Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Sun, 2 Feb 2020 07:08:38 +0000 Subject: [PATCH 43/61] add themeable modlist border --- ModAssistant/Styles/ListView.xaml | 4 +++- ModAssistant/Themes/Dark.xaml | 3 ++- ModAssistant/Themes/Light.xaml | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ModAssistant/Styles/ListView.xaml b/ModAssistant/Styles/ListView.xaml index e820e4e..24ec7ca 100644 --- a/ModAssistant/Styles/ListView.xaml +++ b/ModAssistant/Styles/ListView.xaml @@ -1,5 +1,7 @@ - + \ No newline at end of file diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 36859d1..a943301 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -1,4 +1,4 @@ - @@ -19,6 +19,7 @@ + diff --git a/ModAssistant/Themes/Light.xaml b/ModAssistant/Themes/Light.xaml index f0f3d33..51baed8 100644 --- a/ModAssistant/Themes/Light.xaml +++ b/ModAssistant/Themes/Light.xaml @@ -1,4 +1,4 @@ - @@ -19,6 +19,7 @@ + From 79be3b7f9c0bc4757530ec895890010b6ca53c71 Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Sun, 2 Feb 2020 07:09:58 +0000 Subject: [PATCH 44/61] theme danger button --- ModAssistant/Pages/Options.xaml | 4 ++-- ModAssistant/Themes/Dark.xaml | 1 + ModAssistant/Themes/Light.xaml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index 27a0b44..f2c3e9f 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -1,4 +1,4 @@ -