From 5e0804b43c08d9bb1d23ebe19619b37a37efc5d3 Mon Sep 17 00:00:00 2001 From: oZ-Zo <50652175+oz-zo@users.noreply.github.com> Date: Mon, 2 Mar 2020 18:09:46 +0300 Subject: [PATCH] Add dynamic hamburger width --- W10SS_GUI/Classes/AppCulture.cs | 11 ++--- W10SS_GUI/Classes/Gui.cs | 60 ++++++++++++++++++++++++++++ W10SS_GUI/Classes/Tags.cs | 23 +++++++++++ W10SS_GUI/Localized/EN.xaml | 32 +++++++-------- W10SS_GUI/Localized/RU.xaml | 24 +++++------ W10SS_GUI/MainWindow.xaml | 50 +++++++++++------------ W10SS_GUI/MainWindow.xaml.cs | 54 +++++++++++-------------- W10SS_GUI/Resource/animations.xaml | 2 +- W10SS_GUI/Resource/controlsSize.xaml | 7 ++-- W10SS_GUI/W10SS_GUI.csproj | 2 + 10 files changed, 171 insertions(+), 94 deletions(-) create mode 100644 W10SS_GUI/Classes/Gui.cs create mode 100644 W10SS_GUI/Classes/Tags.cs diff --git a/W10SS_GUI/Classes/AppCulture.cs b/W10SS_GUI/Classes/AppCulture.cs index 95ce2f81..4b12b4c9 100644 --- a/W10SS_GUI/Classes/AppCulture.cs +++ b/W10SS_GUI/Classes/AppCulture.cs @@ -19,13 +19,10 @@ namespace W10SS_GUI private string _culture = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName == Culture.RU ? Culture.RU : Culture.EN; private ResourceDictionary resourceDictionaryEn = new ResourceDictionary() { Source = new Uri("pack://application:,,,/Localized/EN.xaml", UriKind.Absolute) }; private ResourceDictionary resourceDictionaryRu = new ResourceDictionary() { Source = new Uri("pack://application:,,,/Localized/RU.xaml", UriKind.Absolute) }; - internal ResourceDictionary CurrentCulture - { - get - { - return _culture == Culture.RU ? resourceDictionaryRu : resourceDictionaryEn; - } - } + + internal ResourceDictionary CurrentCulture => _culture == Culture.RU ? resourceDictionaryRu : resourceDictionaryEn; + + internal string CurrentCultureName => _culture == Culture.RU ? Culture.RU : Culture.EN; internal ResourceDictionary ChangeCulture() { diff --git a/W10SS_GUI/Classes/Gui.cs b/W10SS_GUI/Classes/Gui.cs new file mode 100644 index 00000000..7b022543 --- /dev/null +++ b/W10SS_GUI/Classes/Gui.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media.Animation; +using W10SS_GUI.Controls; +using W10SS_GUI.Properties; + +namespace W10SS_GUI.Classes +{ + internal class Gui + { + private Dictionary _togglesCategoryPanels = new Dictionary(); + private MainWindow MainWindow = Application.Current.MainWindow as MainWindow; + private HamburgerCategoryButton _lastclickedbutton; + + internal string LastClickedButtonName + { + get + { + return _lastclickedbutton.Name as string; + } + } + + internal Gui() + { + InitializeVariables(); + } + + internal void InitializeVariables() + { + foreach (var tagValue in Application.Current.Resources.MergedDictionaries.Where(r => r.Source.Segments[2] == "tags.xaml").FirstOrDefault().Values) + { + _togglesCategoryPanels.Add(tagValue.ToString(), MainWindow.panelTogglesCategoryContainer.Children.OfType().Where(p => p.Tag == tagValue).FirstOrDefault()); + } + } + + internal void SetActivePanel(HamburgerCategoryButton button) + { + _lastclickedbutton = button; + + foreach (KeyValuePair kvp in _togglesCategoryPanels) + { + kvp.Value.Visibility = kvp.Key == button.Tag as string ? Visibility.Visible : Visibility.Collapsed; + } + + MainWindow.textTogglesHeader.Text = MainWindow.Resources[button.Name] as string; + } + + internal void SetHamburgerWidth(string cultureName) + { + Storyboard storyboard = MainWindow.TryFindResource("animationHamburgerOpen") as Storyboard; + DoubleAnimation animation = storyboard.Children[0] as DoubleAnimation; + animation.To = cultureName == "ru" + ? Convert.ToDouble(MainWindow.TryFindResource("panelHamburgerRuMaxWidth")) + : Convert.ToDouble(MainWindow.TryFindResource("panelHamburgerEnMaxWidth")); + } + } +} \ No newline at end of file diff --git a/W10SS_GUI/Classes/Tags.cs b/W10SS_GUI/Classes/Tags.cs new file mode 100644 index 00000000..c7151ca7 --- /dev/null +++ b/W10SS_GUI/Classes/Tags.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace W10SS_GUI +{ + internal static class Tags + { + internal static readonly string Privacy = string.Format("{0}", Application.Current.Resources["tagCategoryPrivacy"]); + internal static readonly string Ui = string.Format("{0}", Application.Current.Resources["tagCategoryUi"]); + internal static readonly string OneDrive = string.Format("{0}", Application.Current.Resources["tagCategoryOneDrive"]); + internal static readonly string System = string.Format("{0}", Application.Current.Resources["tagCategorySystem"]); + internal static readonly string StartMenu = string.Format("{0}", Application.Current.Resources["tagCategoryStartMenu"]); + internal static readonly string Uwp = string.Format("{0}", Application.Current.Resources["tagCategoryUwp"]); + internal static readonly string WinGame = string.Format("{0}", Application.Current.Resources["tagCategoryWinGame"]); + internal static readonly string TaskScheduler = string.Format("{0}", Application.Current.Resources["tagCategoryTaskScheduler"]); + internal static readonly string Defender = string.Format("{0}", Application.Current.Resources["tagCategoryDefender"]); + internal static readonly string ContextMenu = string.Format("{0}", Application.Current.Resources["tagCategoryContextMenu"]); + } +} diff --git a/W10SS_GUI/Localized/EN.xaml b/W10SS_GUI/Localized/EN.xaml index 0ba86ab8..8270f892 100644 --- a/W10SS_GUI/Localized/EN.xaml +++ b/W10SS_GUI/Localized/EN.xaml @@ -2,22 +2,22 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> Windows 10 Setup Script - - Privacy & Telemetry - UI & Personalization - OneDrive - System - Start Menu - UWP Apps - Game Mode - Task Scheduler - Microsoft Defender - Context Menu - Apply Settings - Save Settings - Import Settings - Русский - GitHub + Privacy & Telemetry + UI & Personalization + OneDrive + System + Start Menu + UWP Apps + Game Mode + Task Scheduler + Microsoft Defender + Context Menu + Apply + Save + Import + Русский + GitHub + \ No newline at end of file diff --git a/W10SS_GUI/Localized/RU.xaml b/W10SS_GUI/Localized/RU.xaml index 7f26e344..32a44792 100644 --- a/W10SS_GUI/Localized/RU.xaml +++ b/W10SS_GUI/Localized/RU.xaml @@ -3,22 +3,22 @@ xmlns:local="clr-namespace:W10SS_GUI.Localized" xmlns:system="clr-namespace:System;assembly=mscorlib"> Windows 10 Setup Script - - Телеметрия - Персонализация - OneDrive - Система - Меню "Пуск" - UWP Приложения - Игровой режим - Планировщик - Microsoft Defender - Контекстное меню + + Безопасность и телеметрия + UI & персонализация + OneDrive + Система + Меню "Пуск" + UWP-приложения + Игровой режим + Планировщик задач + Microsoft Defender + Контекстное меню Применить Сохранить Импортировать English - GitHub + GitHub \ No newline at end of file diff --git a/W10SS_GUI/MainWindow.xaml b/W10SS_GUI/MainWindow.xaml index e38fdbdf..8d0021ba 100644 --- a/W10SS_GUI/MainWindow.xaml +++ b/W10SS_GUI/MainWindow.xaml @@ -20,7 +20,7 @@ ShowInTaskbar="True" Background="{DynamicResource colorWindowBackground}" Foreground="{DynamicResource colorWindowForeground}" - SizeToContent="Manual"> + SizeToContent="Manual" Initialized="Window_Initialized">