[Settings] Move title bar shutdown button to navigation view (#40714)
Some checks failed
Spell checking / Check Spelling (push) Has been cancelled
Spell checking / Report (Push) (push) Has been cancelled
Spell checking / Report (PR) (push) Has been cancelled
Spell checking / Update PR (push) Has been cancelled

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

Based on
https://github.com/microsoft/PowerToys/pull/40260#issuecomment-3085099815
feedback, this PR remove the title bar shutdown button in favor of a
menu item in the navigation view footer.

- Menu item is visible only when tray icon is hidden
- A confirm dialog has been added

<img width="848" height="448" alt="image"
src="https://github.com/user-attachments/assets/529bcfa9-94ed-48b1-b2bb-ca6993d12e0f"
/>

<img width="848" height="448" alt="image"
src="https://github.com/user-attachments/assets/febafbb4-3a5b-4b04-8065-28f0d269ab6c"
/>

- Close is used in tray icon menu for closing app

<img alt="image"
src="https://github.com/user-attachments/assets/3ac79a8c-961f-4f95-8967-adef00aba77b"
/>

<img alt="image"
src="https://github.com/user-attachments/assets/c2800a77-c733-41a9-aa4f-fa4c2afd30a3"
/>

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] **Closes:** #40346 #40577
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

- Open settings with tray icon visible: close menu is hidden
- Open settings with tray icon hidden: close menu is visible
- Tested close menu visibility change when tray icon option is changed
- Tested cancel button of close dialog
- Tested close button of dialog

---------

Co-authored-by: Niels Laute <niels.laute@live.nl>
This commit is contained in:
Davide Giacometti 2025-08-21 10:40:37 +02:00 committed by GitHub
parent 75d85f80b9
commit db953bb325
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 90 additions and 67 deletions

View File

@ -92,7 +92,7 @@ internal sealed partial class TrayIconService
{ {
_popupMenu = PInvoke.CreatePopupMenu_SafeHandle(); _popupMenu = PInvoke.CreatePopupMenu_SafeHandle();
PInvoke.InsertMenu(_popupMenu, 0, MENU_ITEM_FLAGS.MF_BYPOSITION | MENU_ITEM_FLAGS.MF_STRING, PInvoke.WM_USER + 1, RS_.GetString("TrayMenu_Settings")); PInvoke.InsertMenu(_popupMenu, 0, MENU_ITEM_FLAGS.MF_BYPOSITION | MENU_ITEM_FLAGS.MF_STRING, PInvoke.WM_USER + 1, RS_.GetString("TrayMenu_Settings"));
PInvoke.InsertMenu(_popupMenu, 1, MENU_ITEM_FLAGS.MF_BYPOSITION | MENU_ITEM_FLAGS.MF_STRING, PInvoke.WM_USER + 2, RS_.GetString("TrayMenu_Exit")); PInvoke.InsertMenu(_popupMenu, 1, MENU_ITEM_FLAGS.MF_BYPOSITION | MENU_ITEM_FLAGS.MF_STRING, PInvoke.WM_USER + 2, RS_.GetString("TrayMenu_Close"));
} }
} }
else else

View File

@ -419,8 +419,9 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
<data name="TrayMenu_Settings" xml:space="preserve"> <data name="TrayMenu_Settings" xml:space="preserve">
<value>Settings</value> <value>Settings</value>
</data> </data>
<data name="TrayMenu_Exit" xml:space="preserve"> <data name="TrayMenu_Close" xml:space="preserve">
<value>Exit</value> <value>Close</value>
<comment>Close as a verb, as in Close the application</comment>
</data> </data>
<data name="Settings_ExtensionPage_Alias_ToggleSwitch.OnContent" xml:space="preserve"> <data name="Settings_ExtensionPage_Alias_ToggleSwitch.OnContent" xml:space="preserve">
<value>Direct</value> <value>Direct</value>

View File

@ -176,10 +176,6 @@
<data name="DOCUMENTATION_MENU_TEXT" xml:space="preserve"> <data name="DOCUMENTATION_MENU_TEXT" xml:space="preserve">
<value>Documentation</value> <value>Documentation</value>
</data> </data>
<data name="EXIT_MENU_TEXT" xml:space="preserve">
<value>Exit</value>
<comment>Exit as a verb, as in Exit the application</comment>
</data>
<data name="SUBMIT_BUG_TEXT" xml:space="preserve"> <data name="SUBMIT_BUG_TEXT" xml:space="preserve">
<value>Report bug</value> <value>Report bug</value>
</data> </data>
@ -193,4 +189,8 @@
<data name="TRAY_ICON_ADMIN_TOOLTIP" xml:space="preserve"> <data name="TRAY_ICON_ADMIN_TOOLTIP" xml:space="preserve">
<value>Administrator</value> <value>Administrator</value>
</data> </data>
<data name="CLOSE_MENU_TEXT" xml:space="preserve">
<value>Close</value>
<comment>Close as a verb, as in Close the application</comment>
</data>
</root> </root>

View File

@ -15,7 +15,7 @@
#define APPICON 101 #define APPICON 101
#define ID_TRAY_MENU 102 #define ID_TRAY_MENU 102
#define ID_EXIT_MENU_COMMAND 40001 #define ID_CLOSE_MENU_COMMAND 40001
#define ID_SETTINGS_MENU_COMMAND 40002 #define ID_SETTINGS_MENU_COMMAND 40002
#define ID_ABOUT_MENU_COMMAND 40003 #define ID_ABOUT_MENU_COMMAND 40003
#define ID_REPORT_BUG_COMMAND 40004 #define ID_REPORT_BUG_COMMAND 40004

Binary file not shown.

View File

@ -84,7 +84,7 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
open_settings_window(settings_window, false); open_settings_window(settings_window, false);
} }
break; break;
case ID_EXIT_MENU_COMMAND: case ID_CLOSE_MENU_COMMAND:
if (h_menu) if (h_menu)
{ {
DestroyMenu(h_menu); DestroyMenu(h_menu);
@ -191,12 +191,12 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
if (h_menu) if (h_menu)
{ {
static std::wstring settings_menuitem_label = GET_RESOURCE_STRING(IDS_SETTINGS_MENU_TEXT); static std::wstring settings_menuitem_label = GET_RESOURCE_STRING(IDS_SETTINGS_MENU_TEXT);
static std::wstring exit_menuitem_label = GET_RESOURCE_STRING(IDS_EXIT_MENU_TEXT); static std::wstring close_menuitem_label = GET_RESOURCE_STRING(IDS_CLOSE_MENU_TEXT);
static std::wstring submit_bug_menuitem_label = GET_RESOURCE_STRING(IDS_SUBMIT_BUG_TEXT); static std::wstring submit_bug_menuitem_label = GET_RESOURCE_STRING(IDS_SUBMIT_BUG_TEXT);
static std::wstring documentation_menuitem_label = GET_RESOURCE_STRING(IDS_DOCUMENTATION_MENU_TEXT); static std::wstring documentation_menuitem_label = GET_RESOURCE_STRING(IDS_DOCUMENTATION_MENU_TEXT);
static std::wstring quick_access_menuitem_label = GET_RESOURCE_STRING(IDS_QUICK_ACCESS_MENU_TEXT); static std::wstring quick_access_menuitem_label = GET_RESOURCE_STRING(IDS_QUICK_ACCESS_MENU_TEXT);
change_menu_item_text(ID_SETTINGS_MENU_COMMAND, settings_menuitem_label.data()); change_menu_item_text(ID_SETTINGS_MENU_COMMAND, settings_menuitem_label.data());
change_menu_item_text(ID_EXIT_MENU_COMMAND, exit_menuitem_label.data()); change_menu_item_text(ID_CLOSE_MENU_COMMAND, close_menuitem_label.data());
change_menu_item_text(ID_REPORT_BUG_COMMAND, submit_bug_menuitem_label.data()); change_menu_item_text(ID_REPORT_BUG_COMMAND, submit_bug_menuitem_label.data());
bool bug_report_disabled = is_bug_report_running(); bool bug_report_disabled = is_bug_report_running();
EnableMenuItem(h_sub_menu, ID_REPORT_BUG_COMMAND, MF_BYCOMMAND | (bug_report_disabled ? MF_GRAYED : MF_ENABLED)); EnableMenuItem(h_sub_menu, ID_REPORT_BUG_COMMAND, MF_BYCOMMAND | (bug_report_disabled ? MF_GRAYED : MF_ENABLED));

View File

@ -267,7 +267,10 @@
</tkcontrols:SettingsCard> </tkcontrols:SettingsCard>
<tkcontrols:SettingsCard x:Uid="ShowSystemTrayIcon"> <tkcontrols:SettingsCard x:Uid="ShowSystemTrayIcon">
<ToggleSwitch x:Uid="ShowSystemTrayIcon_ToggleSwitch" IsOn="{x:Bind ViewModel.ShowSysTrayIcon, Mode=TwoWay}" /> <ToggleSwitch
x:Uid="ShowSystemTrayIcon_ToggleSwitch"
IsOn="{x:Bind ViewModel.ShowSysTrayIcon, Mode=TwoWay}"
Toggled="ShowSystemTrayIcon_Toggled" />
</tkcontrols:SettingsCard> </tkcontrols:SettingsCard>
<InfoBar <InfoBar
x:Uid="GPO_SettingIsManaged" x:Uid="GPO_SettingIsManaged"

View File

@ -10,7 +10,6 @@ using Microsoft.PowerToys.Settings.UI.Flyout;
using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.ViewModels; using Microsoft.PowerToys.Settings.UI.ViewModels;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Windows.Data.Json; using Windows.Data.Json;
@ -174,19 +173,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
await Task.Run(ViewModel.ViewDiagnosticData); await Task.Run(ViewModel.ViewDiagnosticData);
} }
private void ExitPTItem_Tapped(object sender, RoutedEventArgs e)
{
const string ptTrayIconWindowClass = "PToyTrayIconWindow"; // Defined in runner/tray_icon.h
const nuint ID_EXIT_MENU_COMMAND = 40001; // Generated resource from runner/runner.base.rc
// Exit the XAML application
Application.Current.Exit();
// Invoke the exit command from the tray icon
IntPtr hWnd = NativeMethods.FindWindow(ptTrayIconWindowClass, ptTrayIconWindowClass);
NativeMethods.SendMessage(hWnd, NativeMethods.WM_COMMAND, ID_EXIT_MENU_COMMAND, 0);
}
private void BugReportToolClicked(object sender, RoutedEventArgs e) private void BugReportToolClicked(object sender, RoutedEventArgs e)
{ {
// Start bug report // Start bug report
@ -232,5 +218,17 @@ namespace Microsoft.PowerToys.Settings.UI.Views
ShellPage.ShellHandler.IPCResponseHandleList.Remove(HandleBugReportStatusResponse); ShellPage.ShellHandler.IPCResponseHandleList.Remove(HandleBugReportStatusResponse);
} }
} }
private void ShowSystemTrayIcon_Toggled(object sender, RoutedEventArgs e)
{
if (sender is ToggleSwitch toggleSwitch)
{
var shellViewModel = ShellPage.ShellHandler?.ViewModel;
if (shellViewModel != null)
{
shellViewModel.ShowCloseMenu = !toggleSwitch.IsOn;
}
}
}
} }
} }

View File

@ -1,4 +1,4 @@
<UserControl <UserControl
x:Class="Microsoft.PowerToys.Settings.UI.Views.ShellPage" x:Class="Microsoft.PowerToys.Settings.UI.Views.ShellPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -39,17 +39,10 @@
Margin="48,0,0,0" Margin="48,0,0,0"
VerticalAlignment="Top" VerticalAlignment="Top"
IsHitTestVisible="True"> IsHitTestVisible="True">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftTitleBarColumn" Width="*" />
<ColumnDefinition x:Name="RightTitleBarColumn" Width="Auto" />
</Grid.ColumnDefinitions>
<animations:Implicit.Animations> <animations:Implicit.Animations>
<animations:OffsetAnimation Duration="0:0:0.3" /> <animations:OffsetAnimation Duration="0:0:0.3" />
</animations:Implicit.Animations> </animations:Implicit.Animations>
<StackPanel <StackPanel Orientation="Horizontal">
Grid.Column="0"
HorizontalAlignment="Left"
Orientation="Horizontal">
<Image <Image
Width="16" Width="16"
Height="16" Height="16"
@ -71,24 +64,6 @@
TextWrapping="NoWrap" TextWrapping="NoWrap"
Visibility="Collapsed" /> Visibility="Collapsed" />
</StackPanel> </StackPanel>
<StackPanel
Grid.Column="1"
Margin="0,0,148,0"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
x:Name="ShutDownBtn"
Height="48"
Click="ExitPTItem_Tapped"
Style="{StaticResource SubtleButtonStyle}">
<FontIcon FontSize="16" Glyph="&#xE7E8;" />
<ToolTipService.ToolTip>
<ToolTip>
<TextBlock x:Uid="AppTitleBarShutDown_Tooltip" />
</ToolTip>
</ToolTipService.ToolTip>
</Button>
</StackPanel>
</Grid> </Grid>
<NavigationView <NavigationView
x:Name="navigationView" x:Name="navigationView"
@ -300,6 +275,11 @@
x:Uid="Feedback_NavViewItem" x:Uid="Feedback_NavViewItem"
Icon="{ui:FontIcon Glyph=&#xED15;}" Icon="{ui:FontIcon Glyph=&#xED15;}"
Tapped="FeedbackItem_Tapped" /> Tapped="FeedbackItem_Tapped" />
<NavigationViewItem
x:Uid="Close_NavViewItem"
Icon="{ui:FontIcon Glyph=&#xE7E8;}"
Tapped="Close_Tapped"
Visibility="{x:Bind ViewModel.ShowCloseMenu, Mode=OneWay}" />
</StackPanel> </StackPanel>
</NavigationView.PaneFooter> </NavigationView.PaneFooter>
<i:Interaction.Behaviors> <i:Interaction.Behaviors>
@ -309,5 +289,12 @@
</i:Interaction.Behaviors> </i:Interaction.Behaviors>
<Frame x:Name="shellFrame" /> <Frame x:Name="shellFrame" />
</NavigationView> </NavigationView>
<ContentDialog
x:Name="CloseDialog"
x:Uid="CloseDialog"
IsPrimaryButtonEnabled="True"
IsSecondaryButtonEnabled="True"
PrimaryButtonClick="CloseDialog_Click"
PrimaryButtonStyle="{StaticResource AccentButtonStyle}" />
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using ManagedCommon; using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Services; using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.PowerToys.Settings.UI.ViewModels; using Microsoft.PowerToys.Settings.UI.ViewModels;
using Microsoft.UI.Windowing; using Microsoft.UI.Windowing;
@ -113,7 +114,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// <summary> /// <summary>
/// Gets view model. /// Gets view model.
/// </summary> /// </summary>
public ShellViewModel ViewModel { get; } = new ShellViewModel(); public ShellViewModel ViewModel { get; }
/// <summary> /// <summary>
/// Gets a collection of functions that handle IPC responses. /// Gets a collection of functions that handle IPC responses.
@ -134,6 +135,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{ {
InitializeComponent(); InitializeComponent();
var settingsUtils = new SettingsUtils();
ViewModel = new ShellViewModel(SettingsRepository<GeneralSettings>.GetInstance(settingsUtils));
DataContext = ViewModel; DataContext = ViewModel;
ShellHandler = this; ShellHandler = this;
ViewModel.Initialize(shellFrame, navigationView, KeyboardAccelerators); ViewModel.Initialize(shellFrame, navigationView, KeyboardAccelerators);
@ -461,17 +464,22 @@ namespace Microsoft.PowerToys.Settings.UI.Views
navigationView.IsPaneOpen = !navigationView.IsPaneOpen; navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
} }
private void ExitPTItem_Tapped(object sender, RoutedEventArgs e) private async void Close_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
await CloseDialog.ShowAsync();
}
private void CloseDialog_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{ {
const string ptTrayIconWindowClass = "PToyTrayIconWindow"; // Defined in runner/tray_icon.h const string ptTrayIconWindowClass = "PToyTrayIconWindow"; // Defined in runner/tray_icon.h
const nuint ID_EXIT_MENU_COMMAND = 40001; // Generated resource from runner/runner.base.rc const nuint ID_CLOSE_MENU_COMMAND = 40001; // Generated resource from runner/runner.base.rc
// Exit the XAML application // Exit the XAML application
Application.Current.Exit(); Application.Current.Exit();
// Invoke the exit command from the tray icon // Invoke the exit command from the tray icon
IntPtr hWnd = NativeMethods.FindWindow(ptTrayIconWindowClass, ptTrayIconWindowClass); IntPtr hWnd = NativeMethods.FindWindow(ptTrayIconWindowClass, ptTrayIconWindowClass);
NativeMethods.SendMessage(hWnd, NativeMethods.WM_COMMAND, ID_EXIT_MENU_COMMAND, 0); NativeMethods.SendMessage(hWnd, NativeMethods.WM_COMMAND, ID_CLOSE_MENU_COMMAND, 0);
} }
} }
} }

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
@ -5055,9 +5055,6 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m
<data name="GeneralPageReportBugPackage.Content" xml:space="preserve"> <data name="GeneralPageReportBugPackage.Content" xml:space="preserve">
<value>Generate package</value> <value>Generate package</value>
</data> </data>
<data name="AppTitleBarShutDown_Tooltip.Text" xml:space="preserve">
<value>Shut down</value>
</data>
<data name="BugReportUnderConstruction" xml:space="preserve"> <data name="BugReportUnderConstruction" xml:space="preserve">
<value>Bug report package is being created</value> <value>Bug report package is being created</value>
</data> </data>
@ -5152,6 +5149,23 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m
<data name="GeneralPage_EnableViewDiagnosticDataText.Text" xml:space="preserve"> <data name="GeneralPage_EnableViewDiagnosticDataText.Text" xml:space="preserve">
<value>Stores diagnostic data locally in .xml format; folder may include .etl files as well. May use up 1GB or more of disk space.</value> <value>Stores diagnostic data locally in .xml format; folder may include .etl files as well. May use up 1GB or more of disk space.</value>
</data> </data>
<data name="Close_NavViewItem.Content" xml:space="preserve">
<value>Close PowerToys</value>
<comment>Don't loc "PowerToys"</comment>
</data>
<data name="CloseDialog.Content" xml:space="preserve">
<value>Closing PowerToys will stop all active utilities.</value>
<comment>Don't loc "PowerToys"</comment>
</data>
<data name="CloseDialog.Title" xml:space="preserve">
<value>Are you sure?</value>
</data>
<data name="CloseDialog.PrimaryButtonText" xml:space="preserve">
<value>Yes</value>
</data>
<data name="CloseDialog.SecondaryButtonText" xml:space="preserve">
<value>No</value>
</data>
<data name="KeyBack" xml:space="preserve"> <data name="KeyBack" xml:space="preserve">
<value>Back key</value> <value>Back key</value>
</data> </data>

View File

@ -10,7 +10,9 @@ using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Services; using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Input;
@ -26,31 +28,41 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private readonly KeyboardAccelerator backKeyboardAccelerator = BuildKeyboardAccelerator(VirtualKey.GoBack); private readonly KeyboardAccelerator backKeyboardAccelerator = BuildKeyboardAccelerator(VirtualKey.GoBack);
private bool isBackEnabled; private bool isBackEnabled;
private bool showCloseMenu;
private IList<KeyboardAccelerator> keyboardAccelerators; private IList<KeyboardAccelerator> keyboardAccelerators;
private NavigationView navigationView; private NavigationView navigationView;
private NavigationViewItem selected; private NavigationViewItem selected;
private ICommand loadedCommand; private ICommand loadedCommand;
private ICommand itemInvokedCommand; private ICommand itemInvokedCommand;
private NavigationViewItem[] _fullListOfNavViewItems; private NavigationViewItem[] _fullListOfNavViewItems;
private GeneralSettings _generalSettingsConfig;
public bool IsBackEnabled public bool IsBackEnabled
{ {
get { return isBackEnabled; } get => isBackEnabled;
set { Set(ref isBackEnabled, value); } set => Set(ref isBackEnabled, value);
}
public bool ShowCloseMenu
{
get => showCloseMenu;
set => Set(ref showCloseMenu, value);
} }
public NavigationViewItem Selected public NavigationViewItem Selected
{ {
get { return selected; } get => selected;
set { Set(ref selected, value); } set => Set(ref selected, value);
} }
public ICommand LoadedCommand => loadedCommand ?? (loadedCommand = new RelayCommand(OnLoaded)); public ICommand LoadedCommand => loadedCommand ?? (loadedCommand = new RelayCommand(OnLoaded));
public ICommand ItemInvokedCommand => itemInvokedCommand ?? (itemInvokedCommand = new RelayCommand<NavigationViewItemInvokedEventArgs>(OnItemInvoked)); public ICommand ItemInvokedCommand => itemInvokedCommand ?? (itemInvokedCommand = new RelayCommand<NavigationViewItemInvokedEventArgs>(OnItemInvoked));
public ShellViewModel() public ShellViewModel(ISettingsRepository<GeneralSettings> settingsRepository)
{ {
_generalSettingsConfig = settingsRepository.SettingsConfig;
ShowCloseMenu = !_generalSettingsConfig.ShowSysTrayIcon;
} }
public void Initialize(Frame frame, NavigationView navigationView, IList<KeyboardAccelerator> keyboardAccelerators) public void Initialize(Frame frame, NavigationView navigationView, IList<KeyboardAccelerator> keyboardAccelerators)