diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Icons/Advanced.png b/src/settings-ui/Settings.UI/Assets/Settings/Icons/Advanced.png new file mode 100644 index 0000000000..da8abaded6 Binary files /dev/null and b/src/settings-ui/Settings.UI/Assets/Settings/Icons/Advanced.png differ diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Icons/FileManagement.png b/src/settings-ui/Settings.UI/Assets/Settings/Icons/FileManagement.png new file mode 100644 index 0000000000..22ad25a090 Binary files /dev/null and b/src/settings-ui/Settings.UI/Assets/Settings/Icons/FileManagement.png differ diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Icons/InputOutput.png b/src/settings-ui/Settings.UI/Assets/Settings/Icons/InputOutput.png new file mode 100644 index 0000000000..07fb177d14 Binary files /dev/null and b/src/settings-ui/Settings.UI/Assets/Settings/Icons/InputOutput.png differ diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Icons/SystemTools.png b/src/settings-ui/Settings.UI/Assets/Settings/Icons/SystemTools.png new file mode 100644 index 0000000000..2db25f1278 Binary files /dev/null and b/src/settings-ui/Settings.UI/Assets/Settings/Icons/SystemTools.png differ diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Icons/WindowingAndLayouts.png b/src/settings-ui/Settings.UI/Assets/Settings/Icons/WindowingAndLayouts.png new file mode 100644 index 0000000000..9e0bd706f9 Binary files /dev/null and b/src/settings-ui/Settings.UI/Assets/Settings/Icons/WindowingAndLayouts.png differ diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml index 4a3735c7cf..16cc46bf4f 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml @@ -105,135 +105,159 @@ + + x:Uid="Shell_TopLevelSystemTools" + Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/SystemTools.png}" + SelectsOnInvoked="False"> + + + + + + + + + + + + x:Uid="Shell_TopLevelWindowsAndLayouts " + Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/WindowingAndLayouts.png}" + SelectsOnInvoked="False"> + + + + + + + + + x:Uid="Shell_TopLevelInputOutput" + Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/InputOutput.png}" + SelectsOnInvoked="False"> + + + + + + + + + + + + + x:Uid="Shell_TopLevelFileManagement" + Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FileManagement.png}" + SelectsOnInvoked="False"> + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + x:Uid="Shell_TopLevelAdvanced" + Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Advanced.png}" + SelectsOnInvoked="False"> + + + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs index eac8029b2e..9ff088b787 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; - +using System.Linq; using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Services; @@ -122,6 +122,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views public static bool IsUserAnAdmin { get; set; } + private Dictionary _navViewParentLookup = new Dictionary(); + /// /// Initializes a new instance of the class. /// Shell page constructor. @@ -138,6 +140,21 @@ namespace Microsoft.PowerToys.Settings.UI.Views // shellFrame.Navigate(typeof(GeneralPage)); IPCResponseHandleList.Add(ReceiveMessage); SetTitleBar(); + + if (_navViewParentLookup.Count > 0) + { + _navViewParentLookup.Clear(); + } + + var topLevelItems = navigationView.MenuItems.OfType().ToArray(); + + foreach (var parent in topLevelItems) + { + foreach (var child in parent.MenuItems.OfType()) + { + _navViewParentLookup.TryAdd(child.GetValue(NavHelper.NavigateToProperty) as Type, parent); + } + } } public static int SendDefaultIPCMessage(string msg) @@ -277,7 +294,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views private bool navigationViewInitialStateProcessed; // avoid announcing initial state of the navigation pane. - private void NavigationView_PaneOpened(Microsoft.UI.Xaml.Controls.NavigationView sender, object args) + private void NavigationView_PaneOpened(NavigationView sender, object args) { if (!navigationViewInitialStateProcessed) { @@ -293,7 +310,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views if (AutomationPeer.ListenerExists(AutomationEvents.MenuOpened)) { - var loader = Helpers.ResourceLoaderInstance.ResourceLoader; + var loader = ResourceLoaderInstance.ResourceLoader; peer.RaiseNotificationEvent( AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, @@ -302,7 +319,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views } } - private void NavigationView_PaneClosed(Microsoft.UI.Xaml.Controls.NavigationView sender, object args) + private void NavigationView_PaneClosed(NavigationView sender, object args) { if (!navigationViewInitialStateProcessed) { @@ -318,7 +335,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views if (AutomationPeer.ListenerExists(AutomationEvents.MenuClosed)) { - var loader = Helpers.ResourceLoaderInstance.ResourceLoader; + var loader = ResourceLoaderInstance.ResourceLoader; peer.RaiseNotificationEvent( AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, @@ -348,6 +365,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views if (selectedItem != null) { Type pageType = selectedItem.GetValue(NavHelper.NavigateToProperty) as Type; + + if (_navViewParentLookup.TryGetValue(pageType, out var parentItem) && !parentItem.IsExpanded) + { + parentItem.IsExpanded = true; + } + NavigationService.Navigate(pageType); } } diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw index cb7d064579..85e5a8a986 100644 --- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw @@ -59,10 +59,7 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - + @@ -4563,4 +4560,19 @@ Activate by holding the key for the character you want to add an accent to, then Restart - + + Advanced + + + File Management + + + Input / Output + + + Windowing & Layouts + + + System Tools + + \ No newline at end of file diff --git a/src/settings-ui/Settings.UI/ViewModels/ShellViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/ShellViewModel.cs index f02127ea38..0779293204 100644 --- a/src/settings-ui/Settings.UI/ViewModels/ShellViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/ShellViewModel.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.IO.Abstractions; using System.Linq; using System.Threading.Tasks; using System.Windows.Input; @@ -32,6 +31,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private NavigationViewItem selected; private ICommand loadedCommand; private ICommand itemInvokedCommand; + private NavigationViewItem[] _fullListOfNavViewItems; public bool IsBackEnabled { @@ -76,6 +76,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels NavigationService.NavigationFailed += Frame_NavigationFailed; NavigationService.Navigated += Frame_Navigated; this.navigationView.BackRequested += OnBackRequested; + var topLevelItems = navigationView.MenuItems.OfType(); + _fullListOfNavViewItems = topLevelItems.Union(topLevelItems.SelectMany(menuItem => menuItem.MenuItems.OfType())).ToArray(); } private static KeyboardAccelerator BuildKeyboardAccelerator(VirtualKey key, VirtualKeyModifiers? modifiers = null) @@ -107,11 +109,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private void OnItemInvoked(NavigationViewItemInvokedEventArgs args) { - var item = navigationView.MenuItems - .OfType() - .First(menuItem => (string)menuItem.Content == (string)args.InvokedItem); - var pageType = item.GetValue(NavHelper.NavigateToProperty) as Type; - NavigationService.Navigate(pageType); + var pageType = args.InvokedItemContainer.GetValue(NavHelper.NavigateToProperty) as Type; + + if (pageType != null) + { + NavigationService.Navigate(pageType); + } } private void OnBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) @@ -127,9 +130,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private void Frame_Navigated(object sender, NavigationEventArgs e) { IsBackEnabled = NavigationService.CanGoBack; - Selected = navigationView.MenuItems - .OfType() - .FirstOrDefault(menuItem => IsMenuItemForPageType(menuItem, e.SourcePageType)); + Selected = _fullListOfNavViewItems.FirstOrDefault(menuItem => IsMenuItemForPageType(menuItem, e.SourcePageType)); } private static bool IsMenuItemForPageType(NavigationViewItem menuItem, Type sourcePageType)