mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[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
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
<Slider x:Class="FancyZonesEditor.Controls.CustomSlider"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:FancyZonesEditor.Controls">
|
||||||
|
</Slider>
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for CustomSlider.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class CustomSlider : Slider
|
||||||
|
{
|
||||||
|
public CustomSlider()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override AutomationPeer OnCreateAutomationPeer()
|
||||||
|
{
|
||||||
|
return new CustomSliderAutomationPeer(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
xmlns:props="clr-namespace:FancyZonesEditor.Properties"
|
xmlns:props="clr-namespace:FancyZonesEditor.Properties"
|
||||||
xmlns:local1="clr-namespace:FancyZonesEditor.ViewModels"
|
xmlns:local1="clr-namespace:FancyZonesEditor.ViewModels"
|
||||||
xmlns:controls="clr-namespace:ModernWpf.Controls;assembly=ModernWpf"
|
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"
|
mc:Ignorable="d"
|
||||||
Title="{x:Static props:Resources.Fancy_Zones_Editor_App_Title}"
|
Title="{x:Static props:Resources.Fancy_Zones_Editor_App_Title}"
|
||||||
ui:WindowHelper.UseModernWindowStyle="True"
|
ui:WindowHelper.UseModernWindowStyle="True"
|
||||||
@@ -174,6 +175,8 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type fancyZonesControls:CustomSlider}" BasedOn="{StaticResource {x:Type Slider}}"></Style>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -599,21 +602,32 @@
|
|||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
ToolTip="{x:Static props:Resources.Distance_adjacent_zones}"
|
ToolTip="{x:Static props:Resources.Distance_adjacent_zones}"
|
||||||
AutomationProperties.Name="{x:Static props:Resources.Distance_adjacent_zones}"
|
|
||||||
Text="" />
|
Text="" />
|
||||||
|
|
||||||
<ui:NumberBox Text="{Binding SensitivityRadius}"
|
<fancyZonesControls:CustomSlider x:Name="SensitivityInput"
|
||||||
Width="216"
|
Value="{Binding SensitivityRadius}"
|
||||||
Minimum="0"
|
Minimum="{Binding SensitivityRadiusMinimum}"
|
||||||
Maximum="1000"
|
Maximum="{Binding SensitivityRadiusMaximum}"
|
||||||
KeyDown="EditDialogNumberBox_KeyDown"
|
IsMoveToPointEnabled="True"
|
||||||
Margin="12,0,0,0"
|
AutomationProperties.Name="{x:Static props:Resources.Distance_adjacent_zones}"
|
||||||
Loaded="NumberBox_Loaded"
|
AutomationProperties.HelpText="{Binding SensitivityRadius}"
|
||||||
AutomationProperties.Name="{x:Static props:Resources.Distance_adjacent_zones}"
|
ToolTip="{Binding SensitivityRadius}"
|
||||||
AutomationProperties.LabeledBy="{Binding ElementName=distanceTitle}"
|
ValueChanged="SensitivityInput_ValueChanged"
|
||||||
SpinButtonPlacementMode="Compact"
|
MinWidth="216"
|
||||||
HorizontalAlignment="Left" />
|
Margin="12,0,0,0"
|
||||||
<TextBlock Text="{x:Static props:Resources.Pixels}"
|
HorizontalAlignment="Left"
|
||||||
|
SmallChange="1"
|
||||||
|
LargeChange="10"
|
||||||
|
DockPanel.Dock="Top"/>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Text="{Binding SensitivityRadius}"
|
||||||
|
Margin="6,8,0,0"
|
||||||
|
FontSize="12"
|
||||||
|
Foreground="{DynamicResource SecondaryForegroundBrush}"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
|
<TextBlock Text="{x:Static props:Resources.Pixels}"
|
||||||
Margin="6,-4,0,0"
|
Margin="6,-4,0,0"
|
||||||
FontSize="12"
|
FontSize="12"
|
||||||
Foreground="{DynamicResource SecondaryForegroundBrush}"
|
Foreground="{DynamicResource SecondaryForegroundBrush}"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Common.UI;
|
|||||||
using FancyZonesEditor.Logs;
|
using FancyZonesEditor.Logs;
|
||||||
using FancyZonesEditor.Models;
|
using FancyZonesEditor.Models;
|
||||||
using FancyZonesEditor.Utils;
|
using FancyZonesEditor.Utils;
|
||||||
|
using ModernWpf.Automation.Peers;
|
||||||
using ModernWpf.Controls;
|
using ModernWpf.Controls;
|
||||||
|
|
||||||
namespace FancyZonesEditor
|
namespace FancyZonesEditor
|
||||||
@@ -562,5 +563,26 @@ namespace FancyZonesEditor
|
|||||||
EditLayoutDialogTitle.TextTrimming = TextTrimming.CharacterEllipsis;
|
EditLayoutDialogTitle.TextTrimming = TextTrimming.CharacterEllipsis;
|
||||||
EditLayoutDialogTitle.TextWrapping = TextWrapping.NoWrap;
|
EditLayoutDialogTitle.TextWrapping = TextWrapping.NoWrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SensitivityInput_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,22 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
private int _sensitivityRadius = LayoutSettings.DefaultSensitivityRadius;
|
private int _sensitivityRadius = LayoutSettings.DefaultSensitivityRadius;
|
||||||
|
|
||||||
|
public int SensitivityRadiusMinimum
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SensitivityRadiusMaximum
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<string> QuickKeysAvailable
|
public List<string> QuickKeysAvailable
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.42000
|
// Runtime Version:4.0.30319.42000
|
||||||
@@ -298,6 +298,15 @@ namespace FancyZonesEditor.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Highlight distance slider. Possible range is from {0} to {1}. Value is {2}..
|
||||||
|
/// </summary>
|
||||||
|
public static string Distance_adjacent_zones_slider_announce {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Distance_adjacent_zones_slider_announce", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Duplicate.
|
/// Looks up a localized string similar to Duplicate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -717,6 +726,15 @@ namespace FancyZonesEditor.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Range is from {0} to {1}.
|
||||||
|
/// </summary>
|
||||||
|
public static string Ranged_Input_Tooltip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Ranged_Input_Tooltip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Reset layout.
|
/// Looks up a localized string similar to Reset layout.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -762,6 +780,15 @@ namespace FancyZonesEditor.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to {0} pixels.
|
||||||
|
/// </summary>
|
||||||
|
public static string Slider_Value {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Slider_Value", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Space around zones.
|
/// Looks up a localized string similar to Space around zones.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -408,4 +408,10 @@
|
|||||||
<data name="Error_Parsing_Custom_Layouts_Message" xml:space="preserve">
|
<data name="Error_Parsing_Custom_Layouts_Message" xml:space="preserve">
|
||||||
<value>An error occurred while parsing custom layouts.</value>
|
<value>An error occurred while parsing custom layouts.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Distance_adjacent_zones_slider_announce" xml:space="preserve">
|
||||||
|
<value>Highlight distance slider. Possible range is from {0} to {1}. Value is {2}.</value>
|
||||||
|
</data>
|
||||||
|
<data name="Slider_Value" xml:space="preserve">
|
||||||
|
<value>{0} pixels</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user