From 8cea22aaf1c9b7ca5c9c105b2e02d8783fcb2137 Mon Sep 17 00:00:00 2001 From: Seraphima Zykova Date: Tue, 23 Aug 2022 22:41:22 +0300 Subject: [PATCH] [FZEditor]Highlight distance range: slider and fix narrator (#19840) * announce corrected value * tooltip * slider * announce value * custom slider announce * slider slyle * announce range * show current value --- .../Controls/CustomSlider.xaml | 5 +++ .../Controls/CustomSlider.xaml.cs | 26 ++++++++++++ .../Controls/CustomSliderAutomationPeer.cs | 41 ++++++++++++++++++ .../editor/FancyZonesEditor/MainWindow.xaml | 42 ++++++++++++------- .../FancyZonesEditor/MainWindow.xaml.cs | 22 ++++++++++ .../FancyZonesEditor/Models/LayoutModel.cs | 16 +++++++ .../Properties/Resources.Designer.cs | 29 ++++++++++++- .../Properties/Resources.resx | 6 +++ 8 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml create mode 100644 src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml.cs create mode 100644 src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSliderAutomationPeer.cs diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml b/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml new file mode 100644 index 00000000000..494b1819ef9 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml @@ -0,0 +1,5 @@ + + diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml.cs new file mode 100644 index 00000000000..61f5d5b34e1 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSlider.xaml.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace FancyZonesEditor.Controls +{ + using System.Windows; + using System.Windows.Automation.Peers; + using System.Windows.Controls; + + /// + /// Interaction logic for CustomSlider.xaml + /// + public partial class CustomSlider : Slider + { + public CustomSlider() + { + InitializeComponent(); + } + + protected override AutomationPeer OnCreateAutomationPeer() + { + return new CustomSliderAutomationPeer(this); + } + } +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSliderAutomationPeer.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSliderAutomationPeer.cs new file mode 100644 index 00000000000..1e1ab70eb7d --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Controls/CustomSliderAutomationPeer.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace FancyZonesEditor.Controls +{ + using System.Globalization; + using System.Windows.Automation.Peers; + using System.Windows.Controls; + + internal class CustomSliderAutomationPeer : SliderAutomationPeer + { + public CustomSliderAutomationPeer(Slider owner) + : base(owner) + { + } + + protected override string GetNameCore() + { + var element = this.Owner as Slider; + if (element == null) + { + return string.Empty; + } + + string announce = string.Format( + CultureInfo.CurrentCulture, + Properties.Resources.Distance_adjacent_zones_slider_announce, + element.Minimum, + element.Maximum, + element.Value); + + return announce; + } + + protected override AutomationControlType GetAutomationControlTypeCore() + { + return AutomationControlType.Custom; + } + } +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml index 4cc8f1e94ad..6e66c48b4b1 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml +++ b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml @@ -11,7 +11,8 @@ xmlns:props="clr-namespace:FancyZonesEditor.Properties" xmlns:local1="clr-namespace:FancyZonesEditor.ViewModels" xmlns:controls="clr-namespace:ModernWpf.Controls;assembly=ModernWpf" - xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:fancyZonesControls="clr-namespace:FancyZonesEditor.Controls" mc:Ignorable="d" Title="{x:Static props:Resources.Fancy_Zones_Editor_App_Title}" ui:WindowHelper.UseModernWindowStyle="True" @@ -174,6 +175,8 @@ + + @@ -599,21 +602,32 @@ VerticalAlignment="Center" FontSize="16" ToolTip="{x:Static props:Resources.Distance_adjacent_zones}" - AutomationProperties.Name="{x:Static props:Resources.Distance_adjacent_zones}" Text="" /> - - + + + + e) + { + if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged)) + { + SliderAutomationPeer peer = + FrameworkElementAutomationPeer.FromElement(SensitivityInput) as SliderAutomationPeer; + string activityId = "sliderValueChanged"; + + string value = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Slider_Value, SensitivityInput.Value); + + if (peer != null && value != null) + { + peer.RaiseNotificationEvent( + AutomationNotificationKind.ActionCompleted, + AutomationNotificationProcessing.ImportantMostRecent, + value, + activityId); + } + } + } } } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs index f196ef80e0f..2ff50b4b212 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs @@ -163,6 +163,22 @@ public int SensitivityRadius private int _sensitivityRadius = LayoutSettings.DefaultSensitivityRadius; + public int SensitivityRadiusMinimum + { + get + { + return 0; + } + } + + public int SensitivityRadiusMaximum + { + get + { + return 1000; + } + } + public List QuickKeysAvailable { get diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.Designer.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.Designer.cs index 991da47b964..b1f9693b8bc 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.Designer.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 @@ -298,6 +298,15 @@ public class Resources { } } + /// + /// Looks up a localized string similar to Highlight distance slider. Possible range is from {0} to {1}. Value is {2}.. + /// + public static string Distance_adjacent_zones_slider_announce { + get { + return ResourceManager.GetString("Distance_adjacent_zones_slider_announce", resourceCulture); + } + } + /// /// Looks up a localized string similar to Duplicate. /// @@ -717,6 +726,15 @@ public class Resources { } } + /// + /// Looks up a localized string similar to Range is from {0} to {1}. + /// + public static string Ranged_Input_Tooltip { + get { + return ResourceManager.GetString("Ranged_Input_Tooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Reset layout. /// @@ -762,6 +780,15 @@ public class Resources { } } + /// + /// Looks up a localized string similar to {0} pixels. + /// + public static string Slider_Value { + get { + return ResourceManager.GetString("Slider_Value", resourceCulture); + } + } + /// /// Looks up a localized string similar to Space around zones. /// diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.resx b/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.resx index 1a678737f9d..b63dc06e16a 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.resx +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Properties/Resources.resx @@ -408,4 +408,10 @@ An error occurred while parsing custom layouts. + + Highlight distance slider. Possible range is from {0} to {1}. Value is {2}. + + + {0} pixels + \ No newline at end of file