From 14ef0a2b2a47c1ed1e12e00c537639c2173bfbc6 Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Tue, 8 Nov 2022 11:02:56 +0100 Subject: [PATCH] work on accessibility --- .../Controls/ActionCenter/ApplicationButton.xaml.cs | 4 +++- .../Controls/ActionCenter/AudioControl.xaml.cs | 9 +++++++-- .../Controls/Taskbar/ApplicationControl.xaml.cs | 1 + .../Controls/Taskbar/AudioControl.xaml.cs | 9 +++++++-- .../Controls/ActionCenter/ApplicationButton.xaml.cs | 4 +++- .../Controls/ActionCenter/AudioControl.xaml.cs | 9 +++++++-- .../Controls/Taskbar/ApplicationControl.xaml.cs | 1 + .../Controls/Taskbar/AudioControl.xaml.cs | 9 +++++++-- 8 files changed, 36 insertions(+), 10 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs index db252715..3ecd0db4 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs @@ -35,7 +35,9 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter Icon.Content = IconResourceLoader.Load(window?.Icon ?? application.Icon); Text.Text = window?.Title ?? application.Name; Button.Click += (o, args) => Clicked?.Invoke(this, EventArgs.Empty); - Button.ToolTip = window?.Title ?? application.Tooltip; + var tooltip = window?.Title ?? application.Tooltip; + Button.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, tooltip); if (window != null) { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs index 55f7992c..293491fb 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs @@ -114,6 +114,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Text.Text = info; Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); @@ -121,14 +122,18 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter if (muted) { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); } else { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = LoadIcon(volume); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); PopupIcon.Content = LoadIcon(volume); } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs index eb3c1a31..33f5ec03 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs @@ -44,6 +44,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar Button.MouseEnter += (o, args) => WindowPopup.IsOpen = WindowStackPanel.Children.Count > 0; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver || ActiveBar.IsMouseOver)); Button.ToolTip = application.Tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, application.Tooltip); WindowPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(WindowPopup_PlacementCallback); WindowPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = IsMouseOver)); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs index 541416ad..8ca165dd 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs @@ -132,19 +132,24 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); Volume.ValueChanged += Volume_ValueChanged; if (muted) { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); } else { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = LoadIcon(volume); ButtonIcon.Content = LoadIcon(volume); } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs index aa80dde3..a821822b 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs @@ -35,7 +35,9 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter Icon.Content = IconResourceLoader.Load(window?.Icon ?? application.Icon); Text.Text = window?.Title ?? application.Name; Button.Click += (o, args) => Clicked?.Invoke(this, EventArgs.Empty); - Button.ToolTip = window?.Title ?? application.Tooltip; + var tooltip = window?.Title ?? application.Tooltip; + Button.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, tooltip); if (window != null) { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs index a8e57a3e..13806e13 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs @@ -113,6 +113,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Text.Text = info; Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); @@ -120,14 +121,18 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter if (muted) { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); } else { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = LoadIcon(volume); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); PopupIcon.Content = LoadIcon(volume); } } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs index 195043af..aa85c490 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs @@ -44,6 +44,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar Button.MouseEnter += (o, args) => WindowPopup.IsOpen = WindowStackPanel.Children.Count > 0; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver || ActiveBar.IsMouseOver)); Button.ToolTip = application.Tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, application.Tooltip); WindowPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(WindowPopup_PlacementCallback); WindowPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = IsMouseOver)); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs index 350f94d5..56aa2475 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs @@ -132,19 +132,24 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); Volume.ValueChanged += Volume_ValueChanged; if (muted) { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); } else { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = LoadIcon(volume); ButtonIcon.Content = LoadIcon(volume); }