mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-21 00:14:15 +08:00
[Settings] Announces open/close navigation pane (#12648)
* [Settings] Announces open/close navigation pane * Add localization support
This commit is contained in:
parent
f6645b04ed
commit
7278d62307
@ -249,6 +249,14 @@ Disabling this module or closing PowerToys will unmute the microphone and camera
|
|||||||
<value>Keyboard Manager</value>
|
<value>Keyboard Manager</value>
|
||||||
<comment>Product name: Navigation view item name for Keyboard Manager</comment>
|
<comment>Product name: Navigation view item name for Keyboard Manager</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Shell_NavigationMenu_Announce_Collapse" xml:space="preserve">
|
||||||
|
<value>Navigation closed</value>
|
||||||
|
<comment>Accessibility announcement when the navigation pane collapses</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Shell_NavigationMenu_Announce_Open" xml:space="preserve">
|
||||||
|
<value>Navigation opened</value>
|
||||||
|
<comment>Accessibility announcement when the navigation pane opens</comment>
|
||||||
|
</data>
|
||||||
<data name="KeyboardManager_ConfigHeader.Text" xml:space="preserve">
|
<data name="KeyboardManager_ConfigHeader.Text" xml:space="preserve">
|
||||||
<value>Current configuration</value>
|
<value>Current configuration</value>
|
||||||
<comment>Keyboard Manager current configuration header</comment>
|
<comment>Keyboard Manager current configuration header</comment>
|
||||||
@ -1376,14 +1384,14 @@ From there, simply click on a Markdown file or SVG icon in the File Explorer and
|
|||||||
<data name="Delete_Dialog_Description" xml:space="preserve">
|
<data name="Delete_Dialog_Description" xml:space="preserve">
|
||||||
<value>Are you sure you want to delete this item?</value>
|
<value>Are you sure you want to delete this item?</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Yes" xml:space="preserve">
|
<data name="Yes" xml:space="preserve">
|
||||||
<value>Yes</value>
|
<value>Yes</value>
|
||||||
<comment>Label of a confirmation button</comment>
|
<comment>Label of a confirmation button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Learn_More_Description.AutomationProperties.Name" xml:space="preserve">
|
<data name="Learn_More_Description.AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Learn more</value>
|
<value>Learn more</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ColorPicker_ColorFormat_ToggleSwitch.AutomationProperties.Name" xml:space="preserve">
|
<data name="ColorPicker_ColorFormat_ToggleSwitch.AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Show format in editor</value>
|
<value>Show format in editor</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
@ -28,6 +28,8 @@
|
|||||||
OpenPaneLength="296"
|
OpenPaneLength="296"
|
||||||
CompactModeThresholdWidth="0"
|
CompactModeThresholdWidth="0"
|
||||||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
||||||
|
PaneOpened="NavigationView_PaneOpened"
|
||||||
|
PaneClosed="NavigationView_PaneClosed"
|
||||||
SelectionChanged="NavigationView_SelectionChanged">
|
SelectionChanged="NavigationView_SelectionChanged">
|
||||||
<winui:NavigationView.MenuItems>
|
<winui:NavigationView.MenuItems>
|
||||||
<winui:NavigationViewItem x:Uid="Shell_General" helpers:NavHelper.NavigateTo="views:GeneralPage">
|
<winui:NavigationViewItem x:Uid="Shell_General" helpers:NavHelper.NavigateTo="views:GeneralPage">
|
||||||
|
@ -7,7 +7,9 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
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 Windows.ApplicationModel.Resources;
|
||||||
using Windows.Data.Json;
|
using Windows.Data.Json;
|
||||||
|
using Windows.UI.Xaml.Automation.Peers;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Views
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
||||||
@ -161,5 +163,61 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
{
|
{
|
||||||
scrollViewer.ChangeView(null, 0, null, true);
|
scrollViewer.ChangeView(null, 0, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool navigationViewInitialStateProcessed; // avoid announcing initial state of the navigation pane.
|
||||||
|
|
||||||
|
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
|
||||||
|
#pragma warning disable CA1822 // Mark members as static
|
||||||
|
private void NavigationView_PaneOpened(Microsoft.UI.Xaml.Controls.NavigationView sender, object args)
|
||||||
|
{
|
||||||
|
if (!navigationViewInitialStateProcessed)
|
||||||
|
{
|
||||||
|
navigationViewInitialStateProcessed = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var peer = FrameworkElementAutomationPeer.FromElement(sender);
|
||||||
|
if (peer == null)
|
||||||
|
{
|
||||||
|
peer = FrameworkElementAutomationPeer.CreatePeerForElement(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AutomationPeer.ListenerExists(AutomationEvents.MenuOpened))
|
||||||
|
{
|
||||||
|
var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
|
||||||
|
peer.RaiseNotificationEvent(
|
||||||
|
AutomationNotificationKind.ActionCompleted,
|
||||||
|
AutomationNotificationProcessing.ImportantMostRecent,
|
||||||
|
loader.GetString("Shell_NavigationMenu_Announce_Open"),
|
||||||
|
"navigationMenuPaneOpened");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
|
||||||
|
private void NavigationView_PaneClosed(Microsoft.UI.Xaml.Controls.NavigationView sender, object args)
|
||||||
|
{
|
||||||
|
if (!navigationViewInitialStateProcessed)
|
||||||
|
{
|
||||||
|
navigationViewInitialStateProcessed = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var peer = FrameworkElementAutomationPeer.FromElement(sender);
|
||||||
|
if (peer == null)
|
||||||
|
{
|
||||||
|
peer = FrameworkElementAutomationPeer.CreatePeerForElement(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AutomationPeer.ListenerExists(AutomationEvents.MenuClosed))
|
||||||
|
{
|
||||||
|
var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
|
||||||
|
peer.RaiseNotificationEvent(
|
||||||
|
AutomationNotificationKind.ActionCompleted,
|
||||||
|
AutomationNotificationProcessing.ImportantMostRecent,
|
||||||
|
loader.GetString("Shell_NavigationMenu_Announce_Collapse"),
|
||||||
|
"navigationMenuPaneClosed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore CA1822 // Mark members as static
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user