From c9c5885a3ef43922919fa1638a7e8c0fb2d8ebf6 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Wed, 19 Feb 2020 20:19:38 -0800 Subject: [PATCH 01/30] Themes refactor, non-zip themes support video backgrounds now --- ModAssistant/Classes/Themes.cs | 125 +++++++++++++++++++++------------ ModAssistant/MainWindow.xaml | 1 + 2 files changed, 81 insertions(+), 45 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index d32f00f..0790161 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -20,8 +20,7 @@ namespace ModAssistant public static string ThemeDirectory => $"{Environment.CurrentDirectory}/Themes"; //Self explanatory. //Local dictionary of ResourceDictionarys mapped by their names. - private static Dictionary loadedThemes = new Dictionary(); - private static Dictionary loadedWaifus = new Dictionary(); + private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; //These themes will always be available to use. /// @@ -31,7 +30,6 @@ namespace ModAssistant public static void LoadThemes() { loadedThemes.Clear(); - loadedWaifus.Clear(); if (Directory.Exists(ThemeDirectory)) //Load themes from Themes subfolder if it exists. { foreach (string file in Directory.EnumerateFiles(ThemeDirectory)) @@ -44,7 +42,8 @@ namespace ModAssistant //user-made ones so that one more user-made Light/Dark theme can be added. if (info.Extension.ToLower().Equals(".xaml") && !loadedThemes.ContainsKey(name)) { - ResourceDictionary theme = LoadTheme(name); + Theme theme = LoadTheme(name, false); + theme.Waifus = LoadWaifus(name); if (theme != null) { loadedThemes.Add(name, theme); @@ -58,7 +57,11 @@ namespace ModAssistant //Look for zip files with ".mat" extension. if (info.Extension.ToLower().Equals(".mat") && !loadedThemes.ContainsKey(name)) { - LoadZipTheme(ThemeDirectory, name, ".mat"); + Theme theme = LoadZipTheme(ThemeDirectory, name, ".mat"); + if (theme != null) + { + loadedThemes.Add(name, theme); + } } } } @@ -66,7 +69,7 @@ namespace ModAssistant { if (!loadedThemes.ContainsKey(localTheme)) { - ResourceDictionary theme = LoadTheme(localTheme, true); + Theme theme = LoadTheme(localTheme, true); loadedThemes.Add(localTheme, theme); } } @@ -106,18 +109,31 @@ namespace ModAssistant /// Send message to MainText (default: true). public static void ApplyTheme(string theme, bool sendMessage = true) { - if (loadedThemes.TryGetValue(theme, out ResourceDictionary newTheme)) + if (loadedThemes.TryGetValue(theme, out Theme newTheme)) { + MainWindow.Instance.BackgroundVideo.Pause(); + MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. LoadedTheme = theme; - Application.Current.Resources.MergedDictionaries.Insert(2, newTheme); //Insert our new theme into the same spot as last time. + Application.Current.Resources.MergedDictionaries.Insert(2, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. Properties.Settings.Default.SelectedTheme = theme; Properties.Settings.Default.Save(); if (sendMessage) { MainWindow.Instance.MainText = string.Format((string)Application.Current.FindResource("Themes:ThemeSet"), theme); } - LoadWaifus(theme); + ApplyWaifus(); + if (File.Exists(newTheme.VideoLocation)) + { + Uri videoUri = new Uri(newTheme.VideoLocation, UriKind.Absolute); + MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Visible; + if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri) + { + MainWindow.Instance.BackgroundVideo.Stop(); + MainWindow.Instance.BackgroundVideo.Source = videoUri; + } + MainWindow.Instance.BackgroundVideo.Play(); + } ReloadIcons(); } else @@ -190,9 +206,9 @@ namespace ModAssistant /// ResourceDictionary file name. /// Specifies whether or not to search locally or in the Themes subfolder. /// - private static ResourceDictionary LoadTheme(string name, bool localUri = false) + private static Theme LoadTheme(string name, bool localUri = false) { - string location = $"{Environment.CurrentDirectory}/Themes/{name}.xaml"; + string location = $"{ThemeDirectory}/{name}.xaml"; if (!File.Exists(location) && !localUri) //Return null if we're looking for an item in the Themes subfolder that doesn't exist. { return null; @@ -212,7 +228,12 @@ namespace ModAssistant MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); return null; } - return dictionary; + Theme theme = new Theme(name, dictionary); + if (File.Exists($"{ThemeDirectory}/{name}.mp4")) + { + theme.VideoLocation = $"{ThemeDirectory}/{name}.mp4"; + } + return theme; } /// @@ -221,14 +242,10 @@ namespace ModAssistant /// Theme directory /// Theme name /// Theme extension - private static void LoadZipTheme(string directory, string name, string extension) + private static Theme LoadZipTheme(string directory, string name, string extension) { - if (!loadedWaifus.TryGetValue(name, out Waifus waifus)) - { - waifus = new Waifus(); - loadedWaifus.Add(name, waifus); - } - + Waifus waifus = new Waifus(); + ResourceDictionary dictionary = null; using (FileStream stream = new FileStream(Path.Combine(directory, name + extension), FileMode.Open)) using (ZipArchive archive = new ZipArchive(stream)) { @@ -249,8 +266,7 @@ namespace ModAssistant { try { - ResourceDictionary dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); - loadedThemes.Add(name, dictionary); + dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); } catch (Exception ex) { @@ -260,7 +276,9 @@ namespace ModAssistant } } } - loadedWaifus[name] = waifus; + Theme theme = new Theme(name, dictionary); + theme.Waifus = waifus; + return theme; } /// @@ -284,41 +302,44 @@ namespace ModAssistant } /// - /// Applies waifus from Dictionary. + /// Applies waifus from currently loaded Theme. /// - /// - private static void ApplyWaifus(string theme) + private static void ApplyWaifus() { - loadedWaifus.TryGetValue(theme, out Waifus waifus); - MainWindow.Instance.BackgroundImage.ImageSource = waifus.Background; - MainWindow.Instance.SideImage.ImageSource = waifus.Sidebar; + Waifus waifus = loadedThemes[LoadedTheme].Waifus; + ApplyImageToBrush(ref MainWindow.Instance.BackgroundImage, waifus?.Background); + ApplyImageToBrush(ref MainWindow.Instance.SideImage, waifus?.Background); + } + + private static void ApplyImageToBrush(ref ImageBrush brush, BitmapImage image) + { + if (image is null) + { + brush.Opacity = 0; + } + else + { + brush.Opacity = 1; + brush.ImageSource = image; + } } /// /// Loads the waifus from the Themes folder or theme files if they exist. /// /// Theme's name. - private static void LoadWaifus(string name) + private static Waifus LoadWaifus(string name) { - string location = Path.Combine(Environment.CurrentDirectory, "Themes"); - if (!loadedWaifus.TryGetValue(name, out Waifus waifus)) + Waifus waifus = new Waifus(); + if (File.Exists($"{ThemeDirectory}\\{name}.png")) { - waifus = new Waifus(); - loadedWaifus.Add(name, waifus); + waifus.Background = new BitmapImage(new Uri(Path.Combine($"{ThemeDirectory}\\{name}.png"))); } - - if (File.Exists(Path.Combine(location, name + ".png"))) + if (File.Exists($"{ThemeDirectory}\\{name}.png")) { - waifus.Background = new BitmapImage(new Uri(Path.Combine(location, name + ".png"))); + waifus.Sidebar = new BitmapImage(new Uri(Path.Combine($"{ThemeDirectory}\\{name}.side.png"))); } - - if (File.Exists(Path.Combine(location, name + ".side.png"))) - { - waifus.Sidebar = new BitmapImage(new Uri(Path.Combine(location, name + ".side.png"))); - } - - loadedWaifus[name] = waifus; - ApplyWaifus(name); + return waifus; } /// @@ -342,7 +363,7 @@ namespace ModAssistant /// DrawingGroup name for the image. private static void ChangeColor(ResourceDictionary icons, string ResourceColorName, string DrawingGroupName) { - Application.Current.Resources[ResourceColorName] = loadedThemes[LoadedTheme][ResourceColorName]; + Application.Current.Resources[ResourceColorName] = loadedThemes[LoadedTheme].ThemeDictionary[ResourceColorName]; ((GeometryDrawing)((DrawingGroup)icons[DrawingGroupName]).Children[0]).Brush = (Brush)Application.Current.Resources[ResourceColorName]; } @@ -351,5 +372,19 @@ namespace ModAssistant public BitmapImage Background = null; public BitmapImage Sidebar = null; } + + private class Theme + { + public string Name; + public ResourceDictionary ThemeDictionary; + public Waifus Waifus = null; + public string VideoLocation = null; + + public Theme(string name, ResourceDictionary dictionary) + { + Name = name; + ThemeDictionary = dictionary; + } + } } } diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index 1613d5a..cdc8d60 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -15,6 +15,7 @@ + From 1fef8716d7fc59d175bdf2442bd6e68cdec6ef53 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Wed, 19 Feb 2020 20:19:38 -0800 Subject: [PATCH 02/30] Themes refactor, non-zip themes support video backgrounds now --- ModAssistant/Classes/Themes.cs | 125 +++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 45 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 971fb90..0790161 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -20,8 +20,7 @@ namespace ModAssistant public static string ThemeDirectory => $"{Environment.CurrentDirectory}/Themes"; //Self explanatory. //Local dictionary of ResourceDictionarys mapped by their names. - private static Dictionary loadedThemes = new Dictionary(); - private static Dictionary loadedWaifus = new Dictionary(); + private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; //These themes will always be available to use. /// @@ -31,7 +30,6 @@ namespace ModAssistant public static void LoadThemes() { loadedThemes.Clear(); - loadedWaifus.Clear(); if (Directory.Exists(ThemeDirectory)) //Load themes from Themes subfolder if it exists. { foreach (string file in Directory.EnumerateFiles(ThemeDirectory)) @@ -44,7 +42,8 @@ namespace ModAssistant //user-made ones so that one more user-made Light/Dark theme can be added. if (info.Extension.ToLower().Equals(".xaml") && !loadedThemes.ContainsKey(name)) { - ResourceDictionary theme = LoadTheme(name); + Theme theme = LoadTheme(name, false); + theme.Waifus = LoadWaifus(name); if (theme != null) { loadedThemes.Add(name, theme); @@ -58,7 +57,11 @@ namespace ModAssistant //Look for zip files with ".mat" extension. if (info.Extension.ToLower().Equals(".mat") && !loadedThemes.ContainsKey(name)) { - LoadZipTheme(ThemeDirectory, name, ".mat"); + Theme theme = LoadZipTheme(ThemeDirectory, name, ".mat"); + if (theme != null) + { + loadedThemes.Add(name, theme); + } } } } @@ -66,7 +69,7 @@ namespace ModAssistant { if (!loadedThemes.ContainsKey(localTheme)) { - ResourceDictionary theme = LoadTheme(localTheme, true); + Theme theme = LoadTheme(localTheme, true); loadedThemes.Add(localTheme, theme); } } @@ -106,18 +109,31 @@ namespace ModAssistant /// Send message to MainText (default: true). public static void ApplyTheme(string theme, bool sendMessage = true) { - if (loadedThemes.TryGetValue(theme, out ResourceDictionary newTheme)) + if (loadedThemes.TryGetValue(theme, out Theme newTheme)) { + MainWindow.Instance.BackgroundVideo.Pause(); + MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. LoadedTheme = theme; - Application.Current.Resources.MergedDictionaries.Insert(2, newTheme); //Insert our new theme into the same spot as last time. + Application.Current.Resources.MergedDictionaries.Insert(2, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. Properties.Settings.Default.SelectedTheme = theme; Properties.Settings.Default.Save(); if (sendMessage) { MainWindow.Instance.MainText = string.Format((string)Application.Current.FindResource("Themes:ThemeSet"), theme); } - LoadWaifus(theme); + ApplyWaifus(); + if (File.Exists(newTheme.VideoLocation)) + { + Uri videoUri = new Uri(newTheme.VideoLocation, UriKind.Absolute); + MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Visible; + if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri) + { + MainWindow.Instance.BackgroundVideo.Stop(); + MainWindow.Instance.BackgroundVideo.Source = videoUri; + } + MainWindow.Instance.BackgroundVideo.Play(); + } ReloadIcons(); } else @@ -190,9 +206,9 @@ namespace ModAssistant /// ResourceDictionary file name. /// Specifies whether or not to search locally or in the Themes subfolder. /// - private static ResourceDictionary LoadTheme(string name, bool localUri = false) + private static Theme LoadTheme(string name, bool localUri = false) { - string location = $"{Environment.CurrentDirectory}/Themes/{name}.xaml"; + string location = $"{ThemeDirectory}/{name}.xaml"; if (!File.Exists(location) && !localUri) //Return null if we're looking for an item in the Themes subfolder that doesn't exist. { return null; @@ -212,7 +228,12 @@ namespace ModAssistant MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); return null; } - return dictionary; + Theme theme = new Theme(name, dictionary); + if (File.Exists($"{ThemeDirectory}/{name}.mp4")) + { + theme.VideoLocation = $"{ThemeDirectory}/{name}.mp4"; + } + return theme; } /// @@ -221,14 +242,10 @@ namespace ModAssistant /// Theme directory /// Theme name /// Theme extension - private static void LoadZipTheme(string directory, string name, string extension) + private static Theme LoadZipTheme(string directory, string name, string extension) { - if (!loadedWaifus.TryGetValue(name, out Waifus waifus)) - { - waifus = new Waifus(); - loadedWaifus.Add(name, waifus); - } - + Waifus waifus = new Waifus(); + ResourceDictionary dictionary = null; using (FileStream stream = new FileStream(Path.Combine(directory, name + extension), FileMode.Open)) using (ZipArchive archive = new ZipArchive(stream)) { @@ -249,8 +266,7 @@ namespace ModAssistant { try { - ResourceDictionary dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); - loadedThemes.Add(name, dictionary); + dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); } catch (Exception ex) { @@ -260,7 +276,9 @@ namespace ModAssistant } } } - loadedWaifus[name] = waifus; + Theme theme = new Theme(name, dictionary); + theme.Waifus = waifus; + return theme; } /// @@ -284,41 +302,44 @@ namespace ModAssistant } /// - /// Applies waifus from Dictionary. + /// Applies waifus from currently loaded Theme. /// - /// - private static void ApplyWaifus(string theme) + private static void ApplyWaifus() { - loadedWaifus.TryGetValue(theme, out Waifus waifus); - MainWindow.Instance.BackgroundImage.ImageSource = waifus.Background; - MainWindow.Instance.SideImage.Source = waifus.Sidebar; + Waifus waifus = loadedThemes[LoadedTheme].Waifus; + ApplyImageToBrush(ref MainWindow.Instance.BackgroundImage, waifus?.Background); + ApplyImageToBrush(ref MainWindow.Instance.SideImage, waifus?.Background); + } + + private static void ApplyImageToBrush(ref ImageBrush brush, BitmapImage image) + { + if (image is null) + { + brush.Opacity = 0; + } + else + { + brush.Opacity = 1; + brush.ImageSource = image; + } } /// /// Loads the waifus from the Themes folder or theme files if they exist. /// /// Theme's name. - private static void LoadWaifus(string name) + private static Waifus LoadWaifus(string name) { - string location = Path.Combine(Environment.CurrentDirectory, "Themes"); - if (!loadedWaifus.TryGetValue(name, out Waifus waifus)) + Waifus waifus = new Waifus(); + if (File.Exists($"{ThemeDirectory}\\{name}.png")) { - waifus = new Waifus(); - loadedWaifus.Add(name, waifus); + waifus.Background = new BitmapImage(new Uri(Path.Combine($"{ThemeDirectory}\\{name}.png"))); } - - if (File.Exists(Path.Combine(location, name + ".png"))) + if (File.Exists($"{ThemeDirectory}\\{name}.png")) { - waifus.Background = new BitmapImage(new Uri(Path.Combine(location, name + ".png"))); + waifus.Sidebar = new BitmapImage(new Uri(Path.Combine($"{ThemeDirectory}\\{name}.side.png"))); } - - if (File.Exists(Path.Combine(location, name + ".side.png"))) - { - waifus.Sidebar = new BitmapImage(new Uri(Path.Combine(location, name + ".side.png"))); - } - - loadedWaifus[name] = waifus; - ApplyWaifus(name); + return waifus; } /// @@ -342,7 +363,7 @@ namespace ModAssistant /// DrawingGroup name for the image. private static void ChangeColor(ResourceDictionary icons, string ResourceColorName, string DrawingGroupName) { - Application.Current.Resources[ResourceColorName] = loadedThemes[LoadedTheme][ResourceColorName]; + Application.Current.Resources[ResourceColorName] = loadedThemes[LoadedTheme].ThemeDictionary[ResourceColorName]; ((GeometryDrawing)((DrawingGroup)icons[DrawingGroupName]).Children[0]).Brush = (Brush)Application.Current.Resources[ResourceColorName]; } @@ -351,5 +372,19 @@ namespace ModAssistant public BitmapImage Background = null; public BitmapImage Sidebar = null; } + + private class Theme + { + public string Name; + public ResourceDictionary ThemeDictionary; + public Waifus Waifus = null; + public string VideoLocation = null; + + public Theme(string name, ResourceDictionary dictionary) + { + Name = name; + ThemeDictionary = dictionary; + } + } } } From b884f8da75559032d6ef6e822e7e2b05f3c81ea8 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Wed, 19 Feb 2020 20:30:06 -0800 Subject: [PATCH 03/30] Re-add mediaelement and fix bugs from rebase --- ModAssistant/Classes/Themes.cs | 24 ++++++++++++++---------- ModAssistant/MainWindow.xaml | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 0790161..48eff73 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -307,20 +307,24 @@ namespace ModAssistant private static void ApplyWaifus() { Waifus waifus = loadedThemes[LoadedTheme].Waifus; - ApplyImageToBrush(ref MainWindow.Instance.BackgroundImage, waifus?.Background); - ApplyImageToBrush(ref MainWindow.Instance.SideImage, waifus?.Background); - } - - private static void ApplyImageToBrush(ref ImageBrush brush, BitmapImage image) - { - if (image is null) + if (waifus?.Background is null) { - brush.Opacity = 0; + MainWindow.Instance.BackgroundImage.Opacity = 0; } else { - brush.Opacity = 1; - brush.ImageSource = image; + MainWindow.Instance.BackgroundImage.Opacity = 1; + MainWindow.Instance.BackgroundImage.ImageSource = waifus.Background; + } + + if (waifus?.Sidebar is null) + { + MainWindow.Instance.SideImage.Visibility = Visibility.Hidden; + } + else + { + MainWindow.Instance.SideImage.Visibility = Visibility.Visible; + MainWindow.Instance.SideImage.Source = waifus.Sidebar; } } diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index 3871b61..902647e 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -16,6 +16,7 @@ + From 7e999af2be65913f17fb2a337187f707c132b1f7 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Thu, 20 Feb 2020 20:54:25 -0800 Subject: [PATCH 04/30] Themes override each other correctly, loose themes are now put into their own subfolder --- ModAssistant/Classes/Themes.cs | 139 +++++++++++++++------------------ 1 file changed, 65 insertions(+), 74 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 48eff73..6d819e3 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -30,26 +30,17 @@ namespace ModAssistant public static void LoadThemes() { loadedThemes.Clear(); + foreach (string localTheme in preInstalledThemes) //Load local themes (Light and Dark). We should always load these first. + { + string location = $"Themes/{localTheme}.xaml"; + Uri local = new Uri(location, UriKind.Relative); + ResourceDictionary localDictionary = new ResourceDictionary(); + localDictionary.Source = local; + Theme theme = new Theme(localTheme, localDictionary); + loadedThemes.Add(localTheme, theme); + } 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 select only the actual name. - string name = Path.GetFileNameWithoutExtension(info.Name); - //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.ToLower().Equals(".xaml") && !loadedThemes.ContainsKey(name)) - { - Theme theme = LoadTheme(name, false); - theme.Waifus = LoadWaifus(name); - if (theme != null) - { - loadedThemes.Add(name, theme); - } - } - } foreach (string file in Directory.EnumerateFiles(ThemeDirectory)) { FileInfo info = new FileInfo(file); @@ -58,19 +49,16 @@ namespace ModAssistant if (info.Extension.ToLower().Equals(".mat") && !loadedThemes.ContainsKey(name)) { Theme theme = LoadZipTheme(ThemeDirectory, name, ".mat"); - if (theme != null) - { - loadedThemes.Add(name, theme); - } + if (theme is null) continue; + AddOrModifyTheme(name, theme); } } - } - foreach (string localTheme in preInstalledThemes) //Load local themes (Light and Dark) - { - if (!loadedThemes.ContainsKey(localTheme)) + foreach (string directory in Directory.EnumerateDirectories(ThemeDirectory)) { - Theme theme = LoadTheme(localTheme, true); - loadedThemes.Add(localTheme, theme); + string name = directory.Split('\\').Last(); + Theme theme = LoadTheme(directory, name); + if (theme is null) continue; + AddOrModifyTheme(name, theme); } } if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null) //Refresh Themes dropdown in Options screen. @@ -156,7 +144,7 @@ namespace ModAssistant if (!File.Exists($@"{ThemeDirectory}\\{themeName}.xaml")) { /* - * Light Pink theme is set to build as an Embedded Resource instead of the default Page. + * Any theme that you want to write must be set as an Embedded Resource instead of the default Page. * This is so that we can grab its exact content from Manifest, shown below. * Writing it as is instead of using XAMLWriter keeps the source as is with comments, spacing, and organization. * Using XAMLWriter would compress it into an unorganized mess. @@ -201,41 +189,62 @@ namespace ModAssistant } /// - /// Loads a ResourceDictionary from either Embedded Resources or from a file location. + /// Loads a Theme from a directory location. /// - /// ResourceDictionary file name. - /// Specifies whether or not to search locally or in the Themes subfolder. + /// The full directory path to the theme. + /// Name of the containing folder. /// - private static Theme LoadTheme(string name, bool localUri = false) + private static Theme LoadTheme(string directory, string name) { - string location = $"{ThemeDirectory}/{name}.xaml"; - if (!File.Exists(location) && !localUri) //Return null if we're looking for an item in the Themes subfolder that doesn't exist. + Theme theme = new Theme(name, null); + theme.Waifus = new Waifus(); + foreach (string file in Directory.EnumerateFiles(directory)) { - return null; - } - if (localUri) //Change the location of the theme since we're not looking in a directory but rather in ModAssistant itself. - { - location = $"Themes/{name}.xaml"; - } - Uri uri = new Uri(location, localUri ? UriKind.Relative : UriKind.Absolute); - ResourceDictionary dictionary = new ResourceDictionary(); - try - { - dictionary.Source = uri; - } - catch (Exception ex) - { - MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); - return null; - } - Theme theme = new Theme(name, dictionary); - if (File.Exists($"{ThemeDirectory}/{name}.mp4")) - { - theme.VideoLocation = $"{ThemeDirectory}/{name}.mp4"; + FileInfo info = new FileInfo(file); + if (info.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) && + !info.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase)) + { + theme.Waifus.Background = new BitmapImage(new Uri(info.FullName)); + } + if (info.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase)) + { + theme.Waifus.Sidebar = new BitmapImage(new Uri(info.FullName)); + } + if (info.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) + { + Uri resourceSource = new Uri(info.FullName); + ResourceDictionary dictionary = new ResourceDictionary(); + dictionary.Source = resourceSource; + theme.ThemeDictionary = dictionary; + } + if (info.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)) + { + theme.VideoLocation = info.FullName; + } } return theme; } + private static void AddOrModifyTheme(string name, Theme theme) + { + if (loadedThemes.TryGetValue(name, out _)) + { + if (theme.ThemeDictionary != null) + { + loadedThemes[name].ThemeDictionary = theme.ThemeDictionary; + } + if (theme.Waifus != null) + { + loadedThemes[name].Waifus = theme.Waifus; + } + if (!string.IsNullOrEmpty(theme.VideoLocation)) + { + loadedThemes[name].VideoLocation = theme.VideoLocation; + } + } + else loadedThemes.Add(name, theme); + } + /// /// Loads themes from pre-packged zips. /// @@ -328,24 +337,6 @@ namespace ModAssistant } } - /// - /// Loads the waifus from the Themes folder or theme files if they exist. - /// - /// Theme's name. - private static Waifus LoadWaifus(string name) - { - Waifus waifus = new Waifus(); - if (File.Exists($"{ThemeDirectory}\\{name}.png")) - { - waifus.Background = new BitmapImage(new Uri(Path.Combine($"{ThemeDirectory}\\{name}.png"))); - } - if (File.Exists($"{ThemeDirectory}\\{name}.png")) - { - waifus.Sidebar = new BitmapImage(new Uri(Path.Combine($"{ThemeDirectory}\\{name}.side.png"))); - } - return waifus; - } - /// /// Reload the icon colors for the About, Info, Options, and Mods buttons from the currently loaded theme. /// From 8ea83222dd736f4ab056afc5a1eb44489bcb12ee Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Thu, 20 Feb 2020 21:03:00 -0800 Subject: [PATCH 05/30] Comment updates and code fixes --- ModAssistant/Classes/Themes.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 6d819e3..3b2d883 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -30,7 +30,9 @@ namespace ModAssistant public static void LoadThemes() { loadedThemes.Clear(); - foreach (string localTheme in preInstalledThemes) //Load local themes (Light and Dark). We should always load these first. + //Begin by loading local themes. We should always load these first. + //I am doing loading here to prevent the LoadTheme function from becoming too crazy. + foreach (string localTheme in preInstalledThemes) { string location = $"Themes/{localTheme}.xaml"; Uri local = new Uri(location, UriKind.Relative); @@ -41,18 +43,20 @@ namespace ModAssistant } if (Directory.Exists(ThemeDirectory)) //Load themes from Themes subfolder if it exists. { + //We then load each zipped theme. foreach (string file in Directory.EnumerateFiles(ThemeDirectory)) { FileInfo info = new FileInfo(file); string name = Path.GetFileNameWithoutExtension(info.Name); //Look for zip files with ".mat" extension. - if (info.Extension.ToLower().Equals(".mat") && !loadedThemes.ContainsKey(name)) + if (info.Extension.ToLower().Equals(".mat")) { Theme theme = LoadZipTheme(ThemeDirectory, name, ".mat"); if (theme is null) continue; AddOrModifyTheme(name, theme); } } + //Finally load any loose theme files in subfolders. foreach (string directory in Directory.EnumerateDirectories(ThemeDirectory)) { string name = directory.Split('\\').Last(); @@ -99,6 +103,7 @@ namespace ModAssistant { if (loadedThemes.TryGetValue(theme, out Theme newTheme)) { + //First, pause our video and hide it. MainWindow.Instance.BackgroundVideo.Pause(); MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. @@ -111,10 +116,11 @@ namespace ModAssistant MainWindow.Instance.MainText = string.Format((string)Application.Current.FindResource("Themes:ThemeSet"), theme); } ApplyWaifus(); - if (File.Exists(newTheme.VideoLocation)) + if (File.Exists(newTheme.VideoLocation)) //Load our video if it exists. { Uri videoUri = new Uri(newTheme.VideoLocation, UriKind.Absolute); MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Visible; + //Load the source video if it's not the same as what's playing, or if the theme is loading for the first time. if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri) { MainWindow.Instance.BackgroundVideo.Stop(); @@ -131,7 +137,7 @@ namespace ModAssistant } /// - /// Writes a local theme to disk. You cannot write a theme loaded from the Themes subfolder to disk. + /// Writes an Embedded Resource theme to disk. You cannot write an outside theme to disk. /// /// Name of local theme. public static void WriteThemeToDisk(string themeName) From 79e434f5087c2db28bf0d499133f616a0c7f7c88 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Thu, 20 Feb 2020 21:04:37 -0800 Subject: [PATCH 06/30] Template theme now exports correctly --- 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 3b2d883..ff46bba 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -156,7 +156,7 @@ namespace ModAssistant * Using XAMLWriter would compress it into an unorganized mess. */ using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream($"ModAssistant.Themes.{themeName}.xaml")) - using (FileStream writer = new FileStream($@"{ThemeDirectory}\\{themeName}.xaml", FileMode.Create)) + using (FileStream writer = new FileStream($@"{ThemeDirectory}\\{themeName}\\{themeName}.xaml", FileMode.Create)) { byte[] buffer = new byte[s.Length]; int read = s.Read(buffer, 0, (int)s.Length); From 0b12e6a90a83950e5288eccebefc8738c6a8741c Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 21 Feb 2020 17:04:16 -0800 Subject: [PATCH 07/30] Fix crash when .xaml file doesn't exist with loose themes --- ModAssistant/Classes/Themes.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index ff46bba..4b57135 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -104,11 +104,14 @@ namespace ModAssistant if (loadedThemes.TryGetValue(theme, out Theme newTheme)) { //First, pause our video and hide it. + LoadedTheme = theme; MainWindow.Instance.BackgroundVideo.Pause(); MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; - Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. - LoadedTheme = theme; - Application.Current.Resources.MergedDictionaries.Insert(2, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. + if (newTheme.ThemeDictionary != null) + { + Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. + Application.Current.Resources.MergedDictionaries.Insert(2, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. + } Properties.Settings.Default.SelectedTheme = theme; Properties.Settings.Default.Save(); if (sendMessage) From 711deb50a8b0d67675969213d5543b53f4c5d39e Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 21 Feb 2020 17:07:22 -0800 Subject: [PATCH 08/30] Video backgrounds now loop --- ModAssistant/Classes/Themes.cs | 2 +- ModAssistant/MainWindow.xaml | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 4b57135..56131b6 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -127,7 +127,7 @@ namespace ModAssistant if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri) { MainWindow.Instance.BackgroundVideo.Stop(); - MainWindow.Instance.BackgroundVideo.Source = videoUri; + MainWindow.Instance.BackgroundVideoSource.Source = videoUri; } MainWindow.Instance.BackgroundVideo.Play(); } diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index 902647e..7e70a8f 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -16,7 +16,19 @@ - + + + + + + + + + + + + + From 73ecc0590cb8e9045fdecee12992904f5740144d Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 21 Feb 2020 17:10:21 -0800 Subject: [PATCH 09/30] Changed to better performant video looping code --- ModAssistant/Classes/Themes.cs | 2 +- ModAssistant/MainWindow.xaml | 14 +------------- ModAssistant/MainWindow.xaml.cs | 6 ++++++ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 56131b6..4b57135 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -127,7 +127,7 @@ namespace ModAssistant if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri) { MainWindow.Instance.BackgroundVideo.Stop(); - MainWindow.Instance.BackgroundVideoSource.Source = videoUri; + MainWindow.Instance.BackgroundVideo.Source = videoUri; } MainWindow.Instance.BackgroundVideo.Play(); } diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index 7e70a8f..5a11a66 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -16,19 +16,7 @@ - - - - - - - - - - - - - + diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index b88fd23..e24a75d 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -303,5 +303,11 @@ namespace ModAssistant Mods.Instance.RefreshColumns(); } } + + private void BackgroundVideo_MediaEnded(object sender, RoutedEventArgs e) + { + BackgroundVideo.Position = TimeSpan.Zero; + BackgroundVideo.Play(); + } } } From ab3c39b26b10741ae482731a998dfd7535aa5a01 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 22 Feb 2020 18:19:26 -0800 Subject: [PATCH 10/30] Scroll Bar themified, start work on .mat video support --- ModAssistant/App.xaml | 3 + ModAssistant/Classes/Themes.cs | 17 +- ModAssistant/ModAssistant.csproj | 12 + ModAssistant/Styles/RepeatButton.xaml | 105 +++++++ ModAssistant/Styles/ScrollBar.xaml | 336 +++++++++++++++++++++++ ModAssistant/Styles/Thumb.xaml | 45 +++ ModAssistant/Themes/Dark.xaml | 17 +- ModAssistant/Themes/Light Pink.xaml | 13 + ModAssistant/Themes/Light.xaml | 15 +- ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml | 13 + 10 files changed, 572 insertions(+), 4 deletions(-) create mode 100644 ModAssistant/Styles/RepeatButton.xaml create mode 100644 ModAssistant/Styles/ScrollBar.xaml create mode 100644 ModAssistant/Styles/Thumb.xaml diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index 513b6f9..38ac730 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -28,6 +28,9 @@ + + + diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 4b57135..856508f 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -149,6 +149,10 @@ namespace ModAssistant { Directory.CreateDirectory(ThemeDirectory); } + if (!Directory.Exists($"{ThemeDirectory}\\{themeName}")) + { + Directory.CreateDirectory($"{ThemeDirectory}\\{themeName}"); + } if (!File.Exists($@"{ThemeDirectory}\\{themeName}.xaml")) { @@ -207,7 +211,7 @@ namespace ModAssistant { Theme theme = new Theme(name, null); theme.Waifus = new Waifus(); - foreach (string file in Directory.EnumerateFiles(directory)) + foreach (string file in Directory.EnumerateFiles(directory).OrderByDescending(x => x)) { FileInfo info = new FileInfo(file); if (info.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) && @@ -278,6 +282,17 @@ namespace ModAssistant { waifus.Sidebar = GetImageFromStream(Utils.StreamToArray(file.Open())); } + if (file.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)) + { + if (!Directory.Exists($"{ThemeDirectory}\\{name}")) + { + Directory.CreateDirectory($"{ThemeDirectory}\\{name}"); + } + if (!File.Exists($"{ThemeDirectory}\\{name}\\_{name}.mp4")) + { + file.ExtractToFile($"{ThemeDirectory}\\{name}\\_{name}.mp4", false); + } + } if (file.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) { if (!loadedThemes.ContainsKey(name)) diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj index b8e73d3..a475b28 100644 --- a/ModAssistant/ModAssistant.csproj +++ b/ModAssistant/ModAssistant.csproj @@ -169,10 +169,22 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/ModAssistant/Styles/RepeatButton.xaml b/ModAssistant/Styles/RepeatButton.xaml new file mode 100644 index 0000000..599c92a --- /dev/null +++ b/ModAssistant/Styles/RepeatButton.xaml @@ -0,0 +1,105 @@ + + + + diff --git a/ModAssistant/Styles/ScrollBar.xaml b/ModAssistant/Styles/ScrollBar.xaml new file mode 100644 index 0000000..5c65bad --- /dev/null +++ b/ModAssistant/Styles/ScrollBar.xaml @@ -0,0 +1,336 @@ + + + diff --git a/ModAssistant/Styles/Thumb.xaml b/ModAssistant/Styles/Thumb.xaml new file mode 100644 index 0000000..0bb8794 --- /dev/null +++ b/ModAssistant/Styles/Thumb.xaml @@ -0,0 +1,45 @@ + + + diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 29c827a..ef3ac95 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -13,7 +13,7 @@ #AEAEAE - + @@ -56,9 +56,22 @@ - + + + + + + + + + + + + + 0 + diff --git a/ModAssistant/Themes/Light Pink.xaml b/ModAssistant/Themes/Light Pink.xaml index 51bfa25..5efca59 100644 --- a/ModAssistant/Themes/Light Pink.xaml +++ b/ModAssistant/Themes/Light Pink.xaml @@ -49,6 +49,19 @@ + + + + + + + + + + + + 0 + diff --git a/ModAssistant/Themes/Light.xaml b/ModAssistant/Themes/Light.xaml index 10b7e3f..42ad6ae 100644 --- a/ModAssistant/Themes/Light.xaml +++ b/ModAssistant/Themes/Light.xaml @@ -55,9 +55,22 @@ - + + + + + + + + + + + + + 0 + diff --git a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml index b0779d9..04321f1 100644 --- a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml +++ b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml @@ -73,6 +73,19 @@ + + + + + + + + + + + + 0 + From f0e68fdd614cc07dc35cdbdc615f70ab07a14e15 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 22 Feb 2020 18:33:44 -0800 Subject: [PATCH 11/30] Finish .mat video support --- ModAssistant/Classes/Themes.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 856508f..44e77b1 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -211,7 +211,7 @@ namespace ModAssistant { Theme theme = new Theme(name, null); theme.Waifus = new Waifus(); - foreach (string file in Directory.EnumerateFiles(directory).OrderByDescending(x => x)) + foreach (string file in Directory.EnumerateFiles(directory).OrderBy(x => x)) { FileInfo info = new FileInfo(file); if (info.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) && @@ -292,6 +292,15 @@ namespace ModAssistant { file.ExtractToFile($"{ThemeDirectory}\\{name}\\_{name}.mp4", false); } + else + { + //Check to see if the lengths of each file are different. If they are, overwrite what currently exists. + FileInfo existingInfo = new FileInfo($"{ThemeDirectory}\\{name}\\_{name}.mp4"); + if (existingInfo.Length != file.Length) + { + file.ExtractToFile($"{ThemeDirectory}\\{name}\\_{name}.mp4", true); + } + } } if (file.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) { From 35b995e6f0b29d934db8d63d9eb0f398ab250b2c Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 22 Feb 2020 18:50:44 -0800 Subject: [PATCH 12/30] Fix crash when trying to replace .mat video when its currently playing --- 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 44e77b1..f07f277 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -296,7 +296,7 @@ namespace ModAssistant { //Check to see if the lengths of each file are different. If they are, overwrite what currently exists. FileInfo existingInfo = new FileInfo($"{ThemeDirectory}\\{name}\\_{name}.mp4"); - if (existingInfo.Length != file.Length) + if (existingInfo.Length != file.Length && LoadedTheme != name) { file.ExtractToFile($"{ThemeDirectory}\\{name}\\_{name}.mp4", true); } From c67c6094c89fc3e0d722e255fb1afe41455ebad6 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 22 Feb 2020 20:48:25 -0800 Subject: [PATCH 13/30] Fix sidebar fucking up if the theme doesn't style it --- ModAssistant/App.xaml | 3 +++ ModAssistant/Classes/Themes.cs | 19 +++++++++++++++---- ModAssistant/ModAssistant.csproj | 4 ++++ ModAssistant/Themes/Default_Sidebar.xaml | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 ModAssistant/Themes/Default_Sidebar.xaml diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index 38ac730..ed8c11d 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -11,6 +11,9 @@ + + + diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index f07f277..4c9c177 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -23,6 +23,8 @@ namespace ModAssistant private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; //These themes will always be available to use. + private static readonly int LOADEDTHEME_INDEX = 3; + /// /// Load all themes from local Themes subfolder and from embedded resources. /// This also refreshes the Themes dropdown in the Options screen. @@ -109,8 +111,8 @@ namespace ModAssistant MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; if (newTheme.ThemeDictionary != null) { - Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. - Application.Current.Resources.MergedDictionaries.Insert(2, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. + Application.Current.Resources.MergedDictionaries.RemoveAt(LOADEDTHEME_INDEX); //We might want to change this to a static integer or search by name. + Application.Current.Resources.MergedDictionaries.Insert(LOADEDTHEME_INDEX, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. } Properties.Settings.Default.SelectedTheme = theme; Properties.Settings.Default.Save(); @@ -238,6 +240,11 @@ namespace ModAssistant return theme; } + /// + /// Modifies an already existing theme, or adds the theme if it doesn't exist + /// + /// Name of the theme. + /// Theme to modify/apply private static void AddOrModifyTheme(string name, Theme theme) { if (loadedThemes.TryGetValue(name, out _)) @@ -246,9 +253,13 @@ namespace ModAssistant { loadedThemes[name].ThemeDictionary = theme.ThemeDictionary; } - if (theme.Waifus != null) + if (theme.Waifus?.Background != null) { - loadedThemes[name].Waifus = theme.Waifus; + loadedThemes[name].Waifus.Background = theme.Waifus.Background; + } + if (theme.Waifus?.Sidebar != null) + { + loadedThemes[name].Waifus.Sidebar = theme.Waifus.Sidebar; } if (!string.IsNullOrEmpty(theme.VideoLocation)) { diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj index a475b28..505e440 100644 --- a/ModAssistant/ModAssistant.csproj +++ b/ModAssistant/ModAssistant.csproj @@ -193,6 +193,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/ModAssistant/Themes/Default_Sidebar.xaml b/ModAssistant/Themes/Default_Sidebar.xaml new file mode 100644 index 0000000..ebc2b76 --- /dev/null +++ b/ModAssistant/Themes/Default_Sidebar.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + 0 + From 03ecbee5f9b507f7bdc0c8f43d72b8b70666e476 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 22 Feb 2020 21:00:39 -0800 Subject: [PATCH 14/30] Falls back to Light theme if loaded theme does not include some elements. --- ModAssistant/App.xaml | 8 ++++++-- ModAssistant/Classes/Themes.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index ed8c11d..97dcbf3 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -13,8 +13,12 @@ - - + + + + + diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 4c9c177..1f108d5 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -23,7 +23,7 @@ namespace ModAssistant private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; //These themes will always be available to use. - private static readonly int LOADEDTHEME_INDEX = 3; + private static readonly int LOADEDTHEME_INDEX = 4; /// /// Load all themes from local Themes subfolder and from embedded resources. From 3f2bdff6d177ed9431d7c277533105dc5a8e53c8 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 22 Feb 2020 21:07:28 -0800 Subject: [PATCH 15/30] Add a wee bit of commenting --- ModAssistant/Classes/Themes.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 1f108d5..14084ce 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -306,6 +306,8 @@ namespace ModAssistant else { //Check to see if the lengths of each file are different. If they are, overwrite what currently exists. + //The reason we are also checking LoadedTheme against the name variable is to prevent overwriting a file that's + //already being used by ModAssistant and causing a System.IO.IOException. FileInfo existingInfo = new FileInfo($"{ThemeDirectory}\\{name}\\_{name}.mp4"); if (existingInfo.Length != file.Length && LoadedTheme != name) { From a6d779e0a3acd6e3e58ff9b3c198c6a33571de7d Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sat, 22 Feb 2020 21:28:34 -0800 Subject: [PATCH 16/30] Add list of supported extensions --- ModAssistant/Classes/Themes.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 14084ce..f22193b 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -23,7 +23,9 @@ namespace ModAssistant private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; //These themes will always be available to use. - private static readonly int LOADEDTHEME_INDEX = 4; + private static readonly int LOADEDTHEME_INDEX = 4; //Index of "LoadedTheme" in App.xaml + + private static List supportedVideoExtensions = new List() { ".mp4", ".webm", ".mkv", ".avi", ".m2ts" }; //Self explanatory. /// /// Load all themes from local Themes subfolder and from embedded resources. @@ -232,7 +234,7 @@ namespace ModAssistant dictionary.Source = resourceSource; theme.ThemeDictionary = dictionary; } - if (info.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)) + if (supportedVideoExtensions.Contains(info.Extension)) { theme.VideoLocation = info.FullName; } @@ -293,25 +295,27 @@ namespace ModAssistant { waifus.Sidebar = GetImageFromStream(Utils.StreamToArray(file.Open())); } - if (file.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)) + string videoExtension = $".{file.Name.Split('.').Last()}"; + if (supportedVideoExtensions.Contains(videoExtension)) { + string videoName = $"{ThemeDirectory}\\{name}\\_{name}{videoExtension}"; if (!Directory.Exists($"{ThemeDirectory}\\{name}")) { Directory.CreateDirectory($"{ThemeDirectory}\\{name}"); } - if (!File.Exists($"{ThemeDirectory}\\{name}\\_{name}.mp4")) + if (!File.Exists(videoName)) { - file.ExtractToFile($"{ThemeDirectory}\\{name}\\_{name}.mp4", false); + file.ExtractToFile(videoName, false); } else { //Check to see if the lengths of each file are different. If they are, overwrite what currently exists. //The reason we are also checking LoadedTheme against the name variable is to prevent overwriting a file that's //already being used by ModAssistant and causing a System.IO.IOException. - FileInfo existingInfo = new FileInfo($"{ThemeDirectory}\\{name}\\_{name}.mp4"); + FileInfo existingInfo = new FileInfo(videoName); if (existingInfo.Length != file.Length && LoadedTheme != name) { - file.ExtractToFile($"{ThemeDirectory}\\{name}\\_{name}.mp4", true); + file.ExtractToFile(videoName, true); } } } From 07707e37ae135b30570cc715dbc33fdc712cc0c0 Mon Sep 17 00:00:00 2001 From: Assistant Date: Sat, 22 Feb 2020 23:58:21 -0700 Subject: [PATCH 17/30] Make videos have correct order --- ModAssistant/Classes/Themes.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index f22193b..bfe77bb 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -236,7 +236,10 @@ namespace ModAssistant } if (supportedVideoExtensions.Contains(info.Extension)) { - theme.VideoLocation = info.FullName; + if (info.Name != $"_{name}{info.Extension}" || theme.VideoLocation is null) + { + theme.VideoLocation = info.FullName; + } } } return theme; From c317b65f30f523f143f19a1127eb22de055f1bba Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Sun, 23 Feb 2020 15:21:15 +0000 Subject: [PATCH 18/30] remove extraneous comments --- ModAssistant/Classes/Themes.cs | 62 +++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index bfe77bb..a5a5747 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Windows; @@ -15,17 +15,22 @@ namespace ModAssistant { public class Themes { - public static string LoadedTheme { get; private set; } //Currently loaded theme - public static List LoadedThemes { get => loadedThemes.Keys.ToList(); } //String of themes that can be loaded - public static string ThemeDirectory => $"{Environment.CurrentDirectory}/Themes"; //Self explanatory. + public static string LoadedTheme { get; private set; } + public static List LoadedThemes { get => loadedThemes.Keys.ToList(); } + public static string ThemeDirectory => $"{Environment.CurrentDirectory}/Themes"; - //Local dictionary of ResourceDictionarys mapped by their names. + /// + /// Local dictionary of Resource Dictionaries mapped by their names. + /// private static Dictionary loadedThemes = new Dictionary(); - private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; //These themes will always be available to use. + private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; - private static readonly int LOADEDTHEME_INDEX = 4; //Index of "LoadedTheme" in App.xaml + /// + /// Index of "LoadedTheme" in App.xaml + /// + private static readonly int LOADED_THEME_INDEX = 4; - private static List supportedVideoExtensions = new List() { ".mp4", ".webm", ".mkv", ".avi", ".m2ts" }; //Self explanatory. + private static List supportedVideoExtensions = new List() { ".mp4", ".webm", ".mkv", ".avi", ".m2ts" }; /// /// Load all themes from local Themes subfolder and from embedded resources. @@ -34,8 +39,11 @@ namespace ModAssistant public static void LoadThemes() { loadedThemes.Clear(); - //Begin by loading local themes. We should always load these first. - //I am doing loading here to prevent the LoadTheme function from becoming too crazy. + + /* + * Begin by loading local themes. We should always load these first. + * I am doing loading here to prevent the LoadTheme function from becoming too crazy. + */ foreach (string localTheme in preInstalledThemes) { string location = $"Themes/{localTheme}.xaml"; @@ -45,14 +53,15 @@ namespace ModAssistant Theme theme = new Theme(localTheme, localDictionary); loadedThemes.Add(localTheme, theme); } - if (Directory.Exists(ThemeDirectory)) //Load themes from Themes subfolder if it exists. + + // Load themes from Themes subfolder if it exists. + if (Directory.Exists(ThemeDirectory)) { - //We then load each zipped theme. foreach (string file in Directory.EnumerateFiles(ThemeDirectory)) { FileInfo info = new FileInfo(file); string name = Path.GetFileNameWithoutExtension(info.Name); - //Look for zip files with ".mat" extension. + if (info.Extension.ToLower().Equals(".mat")) { Theme theme = LoadZipTheme(ThemeDirectory, name, ".mat"); @@ -60,7 +69,8 @@ namespace ModAssistant AddOrModifyTheme(name, theme); } } - //Finally load any loose theme files in subfolders. + + // Finally load any loose theme files in subfolders. foreach (string directory in Directory.EnumerateDirectories(ThemeDirectory)) { string name = directory.Split('\\').Last(); @@ -69,7 +79,9 @@ namespace ModAssistant AddOrModifyTheme(name, theme); } } - if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null) //Refresh Themes dropdown in Options screen. + + // Refresh Themes dropdown in Options screen. + if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null) { Options.Instance.ApplicationThemeComboBox.ItemsSource = LoadedThemes; Options.Instance.ApplicationThemeComboBox.SelectedIndex = LoadedThemes.IndexOf(LoadedTheme); @@ -107,14 +119,14 @@ namespace ModAssistant { if (loadedThemes.TryGetValue(theme, out Theme newTheme)) { - //First, pause our video and hide it. LoadedTheme = theme; MainWindow.Instance.BackgroundVideo.Pause(); MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; if (newTheme.ThemeDictionary != null) { - Application.Current.Resources.MergedDictionaries.RemoveAt(LOADEDTHEME_INDEX); //We might want to change this to a static integer or search by name. - Application.Current.Resources.MergedDictionaries.Insert(LOADEDTHEME_INDEX, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. + // TODO: Search by name + Application.Current.Resources.MergedDictionaries.RemoveAt(LOADED_THEME_INDEX); + Application.Current.Resources.MergedDictionaries.Insert(LOADED_THEME_INDEX, newTheme.ThemeDictionary); } Properties.Settings.Default.SelectedTheme = theme; Properties.Settings.Default.Save(); @@ -123,11 +135,13 @@ namespace ModAssistant MainWindow.Instance.MainText = string.Format((string)Application.Current.FindResource("Themes:ThemeSet"), theme); } ApplyWaifus(); - if (File.Exists(newTheme.VideoLocation)) //Load our video if it exists. + + if (File.Exists(newTheme.VideoLocation)) { Uri videoUri = new Uri(newTheme.VideoLocation, UriKind.Absolute); MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Visible; - //Load the source video if it's not the same as what's playing, or if the theme is loading for the first time. + + // Load the source video if it's not the same as what's playing, or if the theme is loading for the first time. if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri) { MainWindow.Instance.BackgroundVideo.Stop(); @@ -312,9 +326,11 @@ namespace ModAssistant } else { - //Check to see if the lengths of each file are different. If they are, overwrite what currently exists. - //The reason we are also checking LoadedTheme against the name variable is to prevent overwriting a file that's - //already being used by ModAssistant and causing a System.IO.IOException. + /* + * Check to see if the lengths of each file are different. If they are, overwrite what currently exists. + * The reason we are also checking LoadedTheme against the name variable is to prevent overwriting a file that's + * already being used by ModAssistant and causing a System.IO.IOException. + */ FileInfo existingInfo = new FileInfo(videoName); if (existingInfo.Length != file.Length && LoadedTheme != name) { From f46fd8c92a7cdfefa879b9fe08a73e6eaa5544dd Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Sun, 23 Feb 2020 15:22:29 +0000 Subject: [PATCH 19/30] minor loop optimisations --- ModAssistant/Classes/Themes.cs | 42 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index a5a5747..3130fc8 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -232,16 +232,21 @@ namespace ModAssistant foreach (string file in Directory.EnumerateFiles(directory).OrderBy(x => x)) { FileInfo info = new FileInfo(file); - if (info.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) && - !info.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase)) + bool isPng = info.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase); + bool isSidePng = info.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase); + bool isXaml = info.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase); + + if (isPng && !isSidePng) { theme.Waifus.Background = new BitmapImage(new Uri(info.FullName)); } - if (info.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase)) + + if (isSidePng) { theme.Waifus.Sidebar = new BitmapImage(new Uri(info.FullName)); } - if (info.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) + + if (isXaml) { Uri resourceSource = new Uri(info.FullName); ResourceDictionary dictionary = new ResourceDictionary(); @@ -303,12 +308,16 @@ namespace ModAssistant { foreach (ZipArchiveEntry file in archive.Entries) { - if (file.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) && - !file.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase)) + bool isPng = file.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase); + bool isSidePng = file.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase); + bool isXaml = file.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase); + + if (isPng && !isSidePng) { waifus.Background = GetImageFromStream(Utils.StreamToArray(file.Open())); } - if (file.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase)) + + if (isSidePng) { waifus.Sidebar = GetImageFromStream(Utils.StreamToArray(file.Open())); } @@ -338,22 +347,21 @@ namespace ModAssistant } } } - if (file.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)) + + if (isXaml && loadedThemes.ContainsKey(name) == false) { - if (!loadedThemes.ContainsKey(name)) + try { - try - { - dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); - } - catch (Exception ex) - { - MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); - } + dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); + } + catch (Exception ex) + { + MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); } } } } + Theme theme = new Theme(name, dictionary); theme.Waifus = waifus; return theme; From 757b38c186637722ee88119c36fef63ddaf77732 Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Sun, 23 Feb 2020 15:23:04 +0000 Subject: [PATCH 20/30] couple more optimisations and readability changes --- ModAssistant/Classes/Themes.cs | 77 +++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 3130fc8..c8007d2 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Windows; @@ -19,14 +19,14 @@ namespace ModAssistant public static List LoadedThemes { get => loadedThemes.Keys.ToList(); } public static string ThemeDirectory => $"{Environment.CurrentDirectory}/Themes"; - /// - /// Local dictionary of Resource Dictionaries mapped by their names. + /// + /// Local dictionary of Resource Dictionaries mapped by their names. /// private static Dictionary loadedThemes = new Dictionary(); private static List preInstalledThemes = new List { "Light", "Dark", "Light Pink" }; - /// - /// Index of "LoadedTheme" in App.xaml + /// + /// Index of "LoadedTheme" in App.xaml /// private static readonly int LOADED_THEME_INDEX = 4; @@ -48,8 +48,10 @@ namespace ModAssistant { string location = $"Themes/{localTheme}.xaml"; Uri local = new Uri(location, UriKind.Relative); + ResourceDictionary localDictionary = new ResourceDictionary(); localDictionary.Source = local; + Theme theme = new Theme(localTheme, localDictionary); loadedThemes.Add(localTheme, theme); } @@ -66,6 +68,7 @@ namespace ModAssistant { Theme theme = LoadZipTheme(ThemeDirectory, name, ".mat"); if (theme is null) continue; + AddOrModifyTheme(name, theme); } } @@ -75,6 +78,7 @@ namespace ModAssistant { string name = directory.Split('\\').Last(); Theme theme = LoadTheme(directory, name); + if (theme is null) continue; AddOrModifyTheme(name, theme); } @@ -99,6 +103,7 @@ namespace ModAssistant Themes.ApplyWindowsTheme(); return; } + try { Themes.ApplyTheme(savedTheme, false); @@ -122,18 +127,22 @@ namespace ModAssistant LoadedTheme = theme; MainWindow.Instance.BackgroundVideo.Pause(); MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; + if (newTheme.ThemeDictionary != null) { // TODO: Search by name Application.Current.Resources.MergedDictionaries.RemoveAt(LOADED_THEME_INDEX); Application.Current.Resources.MergedDictionaries.Insert(LOADED_THEME_INDEX, newTheme.ThemeDictionary); } + Properties.Settings.Default.SelectedTheme = theme; Properties.Settings.Default.Save(); + if (sendMessage) { MainWindow.Instance.MainText = string.Format((string)Application.Current.FindResource("Themes:ThemeSet"), theme); } + ApplyWaifus(); if (File.Exists(newTheme.VideoLocation)) @@ -147,8 +156,10 @@ namespace ModAssistant MainWindow.Instance.BackgroundVideo.Stop(); MainWindow.Instance.BackgroundVideo.Source = videoUri; } + MainWindow.Instance.BackgroundVideo.Play(); } + ReloadIcons(); } else @@ -163,16 +174,10 @@ namespace ModAssistant /// Name of local theme. public static void WriteThemeToDisk(string themeName) { - if (!Directory.Exists(ThemeDirectory)) - { - Directory.CreateDirectory(ThemeDirectory); - } - if (!Directory.Exists($"{ThemeDirectory}\\{themeName}")) - { - Directory.CreateDirectory($"{ThemeDirectory}\\{themeName}"); - } + Directory.CreateDirectory(ThemeDirectory); + Directory.CreateDirectory($"{ThemeDirectory}\\{themeName}"); - if (!File.Exists($@"{ThemeDirectory}\\{themeName}.xaml")) + if (File.Exists($@"{ThemeDirectory}\\{themeName}.xaml") == false) { /* * Any theme that you want to write must be set as an Embedded Resource instead of the default Page. @@ -215,6 +220,7 @@ namespace ModAssistant return; } } + ApplyTheme("Light", false); } } @@ -229,6 +235,7 @@ namespace ModAssistant { Theme theme = new Theme(name, null); theme.Waifus = new Waifus(); + foreach (string file in Directory.EnumerateFiles(directory).OrderBy(x => x)) { FileInfo info = new FileInfo(file); @@ -253,6 +260,7 @@ namespace ModAssistant dictionary.Source = resourceSource; theme.ThemeDictionary = dictionary; } + if (supportedVideoExtensions.Contains(info.Extension)) { if (info.Name != $"_{name}{info.Extension}" || theme.VideoLocation is null) @@ -261,6 +269,7 @@ namespace ModAssistant } } } + return theme; } @@ -277,20 +286,26 @@ namespace ModAssistant { loadedThemes[name].ThemeDictionary = theme.ThemeDictionary; } + if (theme.Waifus?.Background != null) { loadedThemes[name].Waifus.Background = theme.Waifus.Background; } + if (theme.Waifus?.Sidebar != null) { loadedThemes[name].Waifus.Sidebar = theme.Waifus.Sidebar; } + if (!string.IsNullOrEmpty(theme.VideoLocation)) { loadedThemes[name].VideoLocation = theme.VideoLocation; } } - else loadedThemes.Add(name, theme); + else + { + loadedThemes.Add(name, theme); + } } /// @@ -303,12 +318,13 @@ namespace ModAssistant { Waifus waifus = new Waifus(); ResourceDictionary dictionary = null; + using (FileStream stream = new FileStream(Path.Combine(directory, name + extension), FileMode.Open)) using (ZipArchive archive = new ZipArchive(stream)) { foreach (ZipArchiveEntry file in archive.Entries) { - bool isPng = file.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase); + bool isPng = file.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase); bool isSidePng = file.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase); bool isXaml = file.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase); @@ -321,15 +337,14 @@ namespace ModAssistant { waifus.Sidebar = GetImageFromStream(Utils.StreamToArray(file.Open())); } + string videoExtension = $".{file.Name.Split('.').Last()}"; if (supportedVideoExtensions.Contains(videoExtension)) { string videoName = $"{ThemeDirectory}\\{name}\\_{name}{videoExtension}"; - if (!Directory.Exists($"{ThemeDirectory}\\{name}")) - { - Directory.CreateDirectory($"{ThemeDirectory}\\{name}"); - } - if (!File.Exists(videoName)) + Directory.CreateDirectory($"{ThemeDirectory}\\{name}"); + + if (File.Exists(videoName) == false) { file.ExtractToFile(videoName, false); } @@ -350,13 +365,13 @@ namespace ModAssistant if (isXaml && loadedThemes.ContainsKey(name) == false) { - try - { - dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); - } - catch (Exception ex) - { - MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); + try + { + dictionary = (ResourceDictionary)XamlReader.Load(file.Open()); + } + catch (Exception ex) + { + MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); } } } @@ -364,6 +379,7 @@ namespace ModAssistant Theme theme = new Theme(name, dictionary); theme.Waifus = waifus; + return theme; } @@ -381,8 +397,8 @@ namespace ModAssistant image.CacheOption = BitmapCacheOption.OnLoad; image.StreamSource = mStream; image.EndInit(); - if (image.CanFreeze) - image.Freeze(); + if (image.CanFreeze) image.Freeze(); + return image; } } @@ -393,6 +409,7 @@ namespace ModAssistant private static void ApplyWaifus() { Waifus waifus = loadedThemes[LoadedTheme].Waifus; + if (waifus?.Background is null) { MainWindow.Instance.BackgroundImage.Opacity = 0; From fa3616fafc7980c01631a8dbe43fdf5ef814fc12 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 23 Feb 2020 11:56:30 -0800 Subject: [PATCH 21/30] Remove Light theme fallback since it's too aggressive --- ModAssistant/App.xaml | 4 ---- ModAssistant/Classes/Themes.cs | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index 97dcbf3..b489681 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -14,10 +14,6 @@ - - - diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index c8007d2..0dae42a 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -28,7 +28,7 @@ namespace ModAssistant /// /// Index of "LoadedTheme" in App.xaml /// - private static readonly int LOADED_THEME_INDEX = 4; + private static readonly int LOADED_THEME_INDEX = 3; private static List supportedVideoExtensions = new List() { ".mp4", ".webm", ".mkv", ".avi", ".m2ts" }; From e7021b870c958668951acdb3fcd1f469edb71e93 Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Sun, 23 Feb 2020 21:58:26 +0000 Subject: [PATCH 22/30] rename default_sidebar to default scrollbar --- ModAssistant/App.xaml | 6 +- ModAssistant/ModAssistant.csproj | 490 +++++++++--------- ...lt_Sidebar.xaml => Default Scrollbar.xaml} | 4 +- 3 files changed, 250 insertions(+), 250 deletions(-) rename ModAssistant/Themes/{Default_Sidebar.xaml => Default Scrollbar.xaml} (86%) diff --git a/ModAssistant/App.xaml b/ModAssistant/App.xaml index b489681..8b75b66 100644 --- a/ModAssistant/App.xaml +++ b/ModAssistant/App.xaml @@ -1,4 +1,4 @@ - - - + + diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj index 505e440..f019050 100644 --- a/ModAssistant/ModAssistant.csproj +++ b/ModAssistant/ModAssistant.csproj @@ -1,246 +1,246 @@ - - - - - Debug - AnyCPU - {6A224B82-40DA-40B3-94DC-EFBEC2BDDA39} - WinExe - ModAssistant - ModAssistant - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - Resources\icon.ico - - - - - - - - - - - - - - - - - - - 4.0 - - - - - - - - - MSBuild:Compile - Designer - - - - - - - - - Intro.xaml - - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Invalid.xaml - - - Loading.xaml - - - Mods.xaml - - - About.xaml - - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - Options.xaml - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - PublicSettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - + + + + + Debug + AnyCPU + {6A224B82-40DA-40B3-94DC-EFBEC2BDDA39} + WinExe + ModAssistant + ModAssistant + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + Resources\icon.ico + + + + + + + + + + + + + + + + + + + 4.0 + + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + Intro.xaml + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Invalid.xaml + + + Loading.xaml + + + Mods.xaml + + + About.xaml + + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + Options.xaml + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + PublicSettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + \ No newline at end of file diff --git a/ModAssistant/Themes/Default_Sidebar.xaml b/ModAssistant/Themes/Default Scrollbar.xaml similarity index 86% rename from ModAssistant/Themes/Default_Sidebar.xaml rename to ModAssistant/Themes/Default Scrollbar.xaml index ebc2b76..b71f4c0 100644 --- a/ModAssistant/Themes/Default_Sidebar.xaml +++ b/ModAssistant/Themes/Default Scrollbar.xaml @@ -1,6 +1,6 @@ - - + From 5b0b1ad60606b854308f776a636f91039631fd81 Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Sun, 23 Feb 2020 22:03:52 +0000 Subject: [PATCH 23/30] minor tweaks to scrollbar active colours --- ModAssistant/Themes/Dark.xaml | 2 +- ModAssistant/Themes/Light.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index ef3ac95..88861fc 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -69,7 +69,7 @@ - + 0 diff --git a/ModAssistant/Themes/Light.xaml b/ModAssistant/Themes/Light.xaml index 42ad6ae..6347454 100644 --- a/ModAssistant/Themes/Light.xaml +++ b/ModAssistant/Themes/Light.xaml @@ -68,7 +68,7 @@ - + 0 From 225a1f2b9167dcde68f9d5d69c00e5136ad79176 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 23 Feb 2020 15:37:20 -0800 Subject: [PATCH 24/30] Add localization for a theme loading error message --- ModAssistant/Classes/Themes.cs | 18 +++++++++++++----- ModAssistant/Localisation/en-DEBUG.xaml | 1 + ModAssistant/Localisation/en-US.xaml | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 0dae42a..2ed42d7 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -255,10 +255,17 @@ namespace ModAssistant if (isXaml) { - Uri resourceSource = new Uri(info.FullName); - ResourceDictionary dictionary = new ResourceDictionary(); - dictionary.Source = resourceSource; - theme.ThemeDictionary = dictionary; + try + { + Uri resourceSource = new Uri(info.FullName); + ResourceDictionary dictionary = new ResourceDictionary(); + dictionary.Source = resourceSource; + theme.ThemeDictionary = dictionary; + }catch(Exception ex) + { + string message = string.Format((string)Application.Current.FindResource("Themes:FailedToLoadXaml"), name, ex.Message); + MessageBox.Show(message); + } } if (supportedVideoExtensions.Contains(info.Extension)) @@ -371,7 +378,8 @@ namespace ModAssistant } catch (Exception ex) { - MessageBox.Show($"Could not load {name}.\n\n{ex.Message}\n\nIgnoring..."); + string message = string.Format((string)Application.Current.FindResource("Themes:FailedToLoadXaml"), name, ex.Message); + MessageBox.Show(message); } } } diff --git a/ModAssistant/Localisation/en-DEBUG.xaml b/ModAssistant/Localisation/en-DEBUG.xaml index 43248ba..1c705c5 100644 --- a/ModAssistant/Localisation/en-DEBUG.xaml +++ b/ModAssistant/Localisation/en-DEBUG.xaml @@ -149,6 +149,7 @@ {0} Themes:ThemeMissing Themes:SavedTemplateTheme {0} Themes:TemplateThemeExists + Themes:FailedToLoadXaml {0} {1} Updater:CheckFailed diff --git a/ModAssistant/Localisation/en-US.xaml b/ModAssistant/Localisation/en-US.xaml index 5bce64f..259c5bf 100644 --- a/ModAssistant/Localisation/en-US.xaml +++ b/ModAssistant/Localisation/en-US.xaml @@ -208,6 +208,7 @@ {0} does not exist. Template theme "{0}" saved to Themes folder. Template theme already exists! + Failed to load .xaml file for theme {0}: {1} Couldn't check for updates. From e091f8dfded64612abef99dfdf70d96e1268a4e7 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 23 Feb 2020 20:40:40 -0800 Subject: [PATCH 25/30] Run Visual Studio's Auto Format on all changed files --- ModAssistant/Classes/Themes.cs | 3 ++- ModAssistant/Localisation/en-US.xaml | 8 ++++---- ModAssistant/Themes/Dark.xaml | 6 ++++-- ModAssistant/Themes/Default Scrollbar.xaml | 2 +- ModAssistant/Themes/Light Pink.xaml | 8 +++++--- ModAssistant/Themes/Light.xaml | 8 +++++--- ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml | 6 ++++-- 7 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index 2ed42d7..fa15ffd 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -261,7 +261,8 @@ namespace ModAssistant ResourceDictionary dictionary = new ResourceDictionary(); dictionary.Source = resourceSource; theme.ThemeDictionary = dictionary; - }catch(Exception ex) + } + catch (Exception ex) { string message = string.Format((string)Application.Current.FindResource("Themes:FailedToLoadXaml"), name, ex.Message); MessageBox.Show(message); diff --git a/ModAssistant/Localisation/en-US.xaml b/ModAssistant/Localisation/en-US.xaml index 259c5bf..0fcf166 100644 --- a/ModAssistant/Localisation/en-US.xaml +++ b/ModAssistant/Localisation/en-US.xaml @@ -71,7 +71,7 @@ Please read the Beginners Guide on the Wiki - . + . I Agree Disagree @@ -169,7 +169,7 @@ please purchase the game HERE - . + . @@ -177,14 +177,14 @@ not pirated, please do a clean install - . + . If those don't help, ask for support in the #support channel in BSMG - . + . If you used to have a pirated version but have since bought the game Select Folder diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index 88861fc..dc3856f 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -87,7 +87,9 @@ - UniformToFill - Bottom + UniformToFill + + Bottom + diff --git a/ModAssistant/Themes/Default Scrollbar.xaml b/ModAssistant/Themes/Default Scrollbar.xaml index b71f4c0..a0c3718 100644 --- a/ModAssistant/Themes/Default Scrollbar.xaml +++ b/ModAssistant/Themes/Default Scrollbar.xaml @@ -1,7 +1,7 @@ - + diff --git a/ModAssistant/Themes/Light Pink.xaml b/ModAssistant/Themes/Light Pink.xaml index 5efca59..7a9b96b 100644 --- a/ModAssistant/Themes/Light Pink.xaml +++ b/ModAssistant/Themes/Light Pink.xaml @@ -75,7 +75,9 @@ - UniformToFill - Bottom - + UniformToFill + + Bottom + + diff --git a/ModAssistant/Themes/Light.xaml b/ModAssistant/Themes/Light.xaml index 6347454..0a16680 100644 --- a/ModAssistant/Themes/Light.xaml +++ b/ModAssistant/Themes/Light.xaml @@ -86,7 +86,9 @@ - UniformToFill - Bottom - + UniformToFill + + Bottom + + diff --git a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml index 04321f1..432f75b 100644 --- a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml +++ b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml @@ -102,7 +102,9 @@ - UniformToFill - Bottom + UniformToFill + + Bottom + From c48a14bcb31cab39de3ea9b816c475c66dd008e8 Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Sun, 23 Feb 2020 20:44:23 -0800 Subject: [PATCH 26/30] Visual Studio Auto Format accidentally added a space in between the end of sentences and periods --- ModAssistant/Localisation/en-US.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ModAssistant/Localisation/en-US.xaml b/ModAssistant/Localisation/en-US.xaml index 0fcf166..fe84566 100644 --- a/ModAssistant/Localisation/en-US.xaml +++ b/ModAssistant/Localisation/en-US.xaml @@ -169,22 +169,22 @@ please purchase the game HERE - . - + + . If your copy of the game is not pirated, please do a clean install - . + . If those don't help, ask for support in the #support channel in BSMG - . + . If you used to have a pirated version but have since bought the game Select Folder From 352562288af1aab397cd0606c8d21ece1fa8727e Mon Sep 17 00:00:00 2001 From: Assistant Date: Mon, 24 Feb 2020 22:13:46 -0700 Subject: [PATCH 27/30] Fix'd no waifus --- ModAssistant/Classes/Themes.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index fa15ffd..3ba3411 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -297,11 +297,13 @@ namespace ModAssistant if (theme.Waifus?.Background != null) { + if (loadedThemes[name].Waifus is null) loadedThemes[name].Waifus = new Waifus(); loadedThemes[name].Waifus.Background = theme.Waifus.Background; } if (theme.Waifus?.Sidebar != null) { + if (loadedThemes[name].Waifus is null) loadedThemes[name].Waifus = new Waifus(); loadedThemes[name].Waifus.Sidebar = theme.Waifus.Sidebar; } From a484a93f4c5af4ce3cd628b9b8cba386c1045ec6 Mon Sep 17 00:00:00 2001 From: Assistant Date: Mon, 24 Feb 2020 22:21:57 -0700 Subject: [PATCH 28/30] Fix'd waifu theme comments --- ModAssistant/Themes/Dark.xaml | 4 ++-- ModAssistant/Themes/Light Pink.xaml | 4 ++-- ModAssistant/Themes/Light.xaml | 6 +++--- ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml | 5 +++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ModAssistant/Themes/Dark.xaml b/ModAssistant/Themes/Dark.xaml index dc3856f..23434e3 100644 --- a/ModAssistant/Themes/Dark.xaml +++ b/ModAssistant/Themes/Dark.xaml @@ -87,9 +87,9 @@ - UniformToFill - Bottom + UniformToFill + Bottom diff --git a/ModAssistant/Themes/Light Pink.xaml b/ModAssistant/Themes/Light Pink.xaml index 7a9b96b..5b7dfb2 100644 --- a/ModAssistant/Themes/Light Pink.xaml +++ b/ModAssistant/Themes/Light Pink.xaml @@ -75,9 +75,9 @@ - UniformToFill - Bottom + UniformToFill + Bottom diff --git a/ModAssistant/Themes/Light.xaml b/ModAssistant/Themes/Light.xaml index 0a16680..8cbbcd7 100644 --- a/ModAssistant/Themes/Light.xaml +++ b/ModAssistant/Themes/Light.xaml @@ -85,10 +85,10 @@ - - UniformToFill + - Bottom + UniformToFill + Bottom diff --git a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml index 432f75b..0a825a4 100644 --- a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml +++ b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml @@ -102,9 +102,10 @@ - UniformToFill + - Bottom + UniformToFill + Bottom From 92e8fcf77b2bcd6c6754787ddf5dd9c8a14713e8 Mon Sep 17 00:00:00 2001 From: Assistant Date: Mon, 24 Feb 2020 22:43:07 -0700 Subject: [PATCH 29/30] Add fields to template theme --- ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml index 0a825a4..5f27e91 100644 --- a/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml +++ b/ModAssistant/Themes/Ugly Kulu-Ya-Ku.xaml @@ -51,6 +51,7 @@ + @@ -90,7 +91,9 @@ + + From ae1387b6958884e804e6ee826d871cb2f0aa6497 Mon Sep 17 00:00:00 2001 From: Assistant Date: Tue, 25 Feb 2020 00:31:40 -0700 Subject: [PATCH 30/30] Made window 1280x720 excluding chrome --- ModAssistant/MainWindow.xaml | 2 +- ModAssistant/MainWindow.xaml.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index 5a11a66..f9c3eaf 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:ModAssistant" mc:Ignorable="d" Icon="Resources/icon.ico" - Title="{DynamicResource MainWindow:WindowTitle}" Width="1280" Height="720" + Title="{DynamicResource MainWindow:WindowTitle}" SizeChanged="Window_SizeChanged" UIElement.PreviewMouseDown="Window_PreviewMouseDown"> diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index e24a75d..66e21ee 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -39,6 +39,16 @@ namespace ModAssistant InitializeComponent(); Instance = this; + const int ContentWidth = 1280; + const int ContentHeight = 720; + + double ChromeWidth = SystemParameters.WindowNonClientFrameThickness.Left + SystemParameters.WindowNonClientFrameThickness.Right; + double ChromeHeight = SystemParameters.WindowNonClientFrameThickness.Top + SystemParameters.WindowNonClientFrameThickness.Bottom; + double ResizeBorder = SystemParameters.ResizeFrameVerticalBorderWidth; + + Width = ChromeWidth + ContentWidth + 2 * ResizeBorder; + Height = ChromeHeight + ContentHeight + 2 * ResizeBorder; + VersionText.Text = App.Version; if (Utils.IsVoid())