mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[ColorPicker] Accessibility: announce color format for "Copy to clipboard" button (#13558)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<UserControl x:Class="ColorPicker.Controls.ColorFormatControl"
|
<UserControl x:Class="ColorPicker.Controls.ColorFormatControl"
|
||||||
|
xmlns:local="clr-namespace:ColorPicker"
|
||||||
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"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
@@ -50,7 +51,8 @@
|
|||||||
Width="36"
|
Width="36"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
AutomationProperties.Name="{x:Static p:Resources.Copy_to_clipboard}"
|
AutomationProperties.Name="{x:Static p:Resources.Copy_to_clipboard}"
|
||||||
AutomationProperties.HelpText="{Binding ElementName=ColorTextRepresentationTextBlock, Path=Text}"
|
AutomationProperties.HelpText="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Controls.ColorFormatControl}}, Path=SelectedColorCopyHelperText}"
|
||||||
|
|
||||||
FontSize="12"
|
FontSize="12"
|
||||||
Style="{StaticResource DefaultButtonStyle}"
|
Style="{StaticResource DefaultButtonStyle}"
|
||||||
FontFamily="Segoe MDL2 Assets">
|
FontFamily="Segoe MDL2 Assets">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Automation.Peers;
|
using System.Windows.Automation.Peers;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -23,6 +24,8 @@ namespace ColorPicker.Controls
|
|||||||
|
|
||||||
public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorFormatControl), new PropertyMetadata(SelectedColorPropertyChanged));
|
public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorFormatControl), new PropertyMetadata(SelectedColorPropertyChanged));
|
||||||
|
|
||||||
|
public static readonly DependencyProperty SelectedColorCopyHelperTextProperty = DependencyProperty.Register("SelectedColorCopyHelperText", typeof(string), typeof(ColorFormatControl));
|
||||||
|
|
||||||
public static readonly DependencyProperty ColorCopiedNotificationBorderProperty = DependencyProperty.Register("ColorCopiedNotificationBorder", typeof(FrameworkElement), typeof(ColorFormatControl), new PropertyMetadata(ColorCopiedBorderPropertyChanged));
|
public static readonly DependencyProperty ColorCopiedNotificationBorderProperty = DependencyProperty.Register("ColorCopiedNotificationBorder", typeof(FrameworkElement), typeof(ColorFormatControl), new PropertyMetadata(ColorCopiedBorderPropertyChanged));
|
||||||
|
|
||||||
private const int CopyIndicatorStayTimeInMs = 3000;
|
private const int CopyIndicatorStayTimeInMs = 3000;
|
||||||
@@ -47,6 +50,12 @@ namespace ColorPicker.Controls
|
|||||||
set { SetValue(ColorCopiedNotificationBorderProperty, value); }
|
set { SetValue(ColorCopiedNotificationBorderProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string SelectedColorCopyHelperText
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(SelectedColorCopyHelperTextProperty); }
|
||||||
|
set { SetValue(SelectedColorCopyHelperTextProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public ColorFormatControl()
|
public ColorFormatControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -68,7 +77,10 @@ namespace ColorPicker.Controls
|
|||||||
|
|
||||||
private static void SelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void SelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
((ColorFormatControl)d).ColorTextRepresentationTextBlock.Text = ((ColorFormatControl)d).ColorFormatModel.Convert((Color)e.NewValue);
|
var self = (ColorFormatControl)d;
|
||||||
|
var colorText = self.ColorFormatModel.Convert((Color)e.NewValue);
|
||||||
|
self.ColorTextRepresentationTextBlock.Text = colorText;
|
||||||
|
self.SelectedColorCopyHelperText = string.Format(CultureInfo.InvariantCulture, "{0} {1}", self.ColorFormatModel.FormatName, colorText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ColorFormatModelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void ColorFormatModelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user