[AdvancedPaste]Fixed issues with Screen Reader integration (#36778)
This commit is contained in:
Родитель
5ef918750d
Коммит
7d8e4a766c
|
@ -0,0 +1,29 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
using AdvancedPaste.Models;
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||||
|
|
||||||
|
namespace AdvancedPaste.Controls;
|
||||||
|
|
||||||
|
public sealed partial class PasteFormatTemplateSelector : DataTemplateSelector
|
||||||
|
{
|
||||||
|
public DataTemplate ItemTemplate { get; set; }
|
||||||
|
|
||||||
|
public DataTemplate ItemTemplateDisabled { get; set; }
|
||||||
|
|
||||||
|
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
|
||||||
|
{
|
||||||
|
bool isEnabled = item is PasteFormat pasteFormat && pasteFormat.IsEnabled;
|
||||||
|
|
||||||
|
if (container is SelectorItem selector)
|
||||||
|
{
|
||||||
|
selector.IsEnabled = isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isEnabled ? ItemTemplate : ItemTemplateDisabled;
|
||||||
|
}
|
||||||
|
}
|
|
@ -410,6 +410,7 @@
|
||||||
Spacing="2">
|
Spacing="2">
|
||||||
<Button
|
<Button
|
||||||
Padding="4"
|
Padding="4"
|
||||||
|
AutomationProperties.LabeledBy="{x:Bind ThumbsUpFeedback}"
|
||||||
Click="ThumbUpDown_Click"
|
Click="ThumbUpDown_Click"
|
||||||
CommandParameter="True"
|
CommandParameter="True"
|
||||||
Content="{ui:FontIcon Glyph=,
|
Content="{ui:FontIcon Glyph=,
|
||||||
|
@ -417,11 +418,12 @@
|
||||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||||
Style="{StaticResource SubtleButtonStyle}">
|
Style="{StaticResource SubtleButtonStyle}">
|
||||||
<ToolTipService.ToolTip>
|
<ToolTipService.ToolTip>
|
||||||
<TextBlock x:Uid="ThumbsUpFeedback" />
|
<TextBlock x:Name="ThumbsUpFeedback" x:Uid="ThumbsUpFeedback" />
|
||||||
</ToolTipService.ToolTip>
|
</ToolTipService.ToolTip>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
Padding="4"
|
Padding="4"
|
||||||
|
AutomationProperties.LabeledBy="{x:Bind ThumbsDownFeedback}"
|
||||||
Click="ThumbUpDown_Click"
|
Click="ThumbUpDown_Click"
|
||||||
CommandParameter="False"
|
CommandParameter="False"
|
||||||
Content="{ui:FontIcon Glyph=,
|
Content="{ui:FontIcon Glyph=,
|
||||||
|
@ -429,7 +431,7 @@
|
||||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||||
Style="{StaticResource SubtleButtonStyle}">
|
Style="{StaticResource SubtleButtonStyle}">
|
||||||
<ToolTipService.ToolTip>
|
<ToolTipService.ToolTip>
|
||||||
<TextBlock x:Uid="ThumbsDownFeedback" />
|
<TextBlock x:Name="ThumbsDownFeedback" x:Uid="ThumbsDownFeedback" />
|
||||||
</ToolTipService.ToolTip>
|
</ToolTipService.ToolTip>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -537,6 +539,7 @@
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
ui:VisualExtensions.NormalizedCenterPoint="0.5,0.5"
|
ui:VisualExtensions.NormalizedCenterPoint="0.5,0.5"
|
||||||
|
AutomationProperties.HelpText="{x:Bind ViewModel.CustomAIUnavailableErrorText, Mode=OneWay}"
|
||||||
Command="{x:Bind GenerateCustomAICommand}"
|
Command="{x:Bind GenerateCustomAICommand}"
|
||||||
Content="{ui:FontIcon Glyph=,
|
Content="{ui:FontIcon Glyph=,
|
||||||
FontSize=16}"
|
FontSize=16}"
|
||||||
|
|
|
@ -21,6 +21,77 @@
|
||||||
x:Name="customActionsToMinHeightConverter"
|
x:Name="customActionsToMinHeightConverter"
|
||||||
ValueIfNonZero="40"
|
ValueIfNonZero="40"
|
||||||
ValueIfZero="0" />
|
ValueIfZero="0" />
|
||||||
|
<controls:PasteFormatTemplateSelector x:Key="PasteFormatTemplateSelector">
|
||||||
|
<controls:PasteFormatTemplateSelector.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="local:PasteFormat">
|
||||||
|
<Grid
|
||||||
|
Margin="0"
|
||||||
|
Padding="-9,0,0,0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
AutomationProperties.AcceleratorKey="{x:Bind ShortcutText, Mode=OneWay}"
|
||||||
|
AutomationProperties.AutomationControlType="ListItem"
|
||||||
|
AutomationProperties.FullDescription="{x:Bind ToolTip, Mode=OneWay}"
|
||||||
|
AutomationProperties.HelpText="{x:Bind Name, Mode=OneWay}"
|
||||||
|
AutomationProperties.Name="{x:Bind AccessibleName, Mode=OneWay}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="26" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ToolTipService.ToolTip>
|
||||||
|
<TextBlock Text="{x:Bind ToolTip, Mode=OneWay}" />
|
||||||
|
</ToolTipService.ToolTip>
|
||||||
|
<FontIcon
|
||||||
|
Margin="0,0,0,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
AutomationProperties.AccessibilityView="Raw"
|
||||||
|
FontSize="16"
|
||||||
|
Glyph="{x:Bind IconGlyph, Mode=OneWay}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
x:Phase="1"
|
||||||
|
Text="{x:Bind Name, Mode=OneWay}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="0,0,8,0"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="{x:Bind ShortcutText, Mode=OneWay}" />
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</controls:PasteFormatTemplateSelector.ItemTemplate>
|
||||||
|
<controls:PasteFormatTemplateSelector.ItemTemplateDisabled>
|
||||||
|
<DataTemplate x:DataType="local:PasteFormat" AutomationProperties.AccessibilityView="Raw">
|
||||||
|
<Grid
|
||||||
|
Margin="0"
|
||||||
|
Padding="-9,0,0,0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
AutomationProperties.AccessibilityView="Raw"
|
||||||
|
Opacity="0.5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="26" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<FontIcon
|
||||||
|
Margin="0,0,0,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="16"
|
||||||
|
Glyph="{x:Bind IconGlyph, Mode=OneWay}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
x:Phase="1"
|
||||||
|
Text="{x:Bind Name, Mode=OneWay}" />
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</controls:PasteFormatTemplateSelector.ItemTemplateDisabled>
|
||||||
|
</controls:PasteFormatTemplateSelector>
|
||||||
<Style
|
<Style
|
||||||
x:Key="PaddingLessFlyoutPresenterStyle"
|
x:Key="PaddingLessFlyoutPresenterStyle"
|
||||||
BasedOn="{StaticResource DefaultFlyoutPresenterStyle}"
|
BasedOn="{StaticResource DefaultFlyoutPresenterStyle}"
|
||||||
|
@ -29,57 +100,6 @@
|
||||||
<Setter Property="Padding" Value="0" />
|
<Setter Property="Padding" Value="0" />
|
||||||
</Style.Setters>
|
</Style.Setters>
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="PasteFormatListViewItemStyle" TargetType="ListViewItem">
|
|
||||||
<Setter Property="Padding" Value="0" />
|
|
||||||
<Setter Property="Margin" Value="0" />
|
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
||||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
|
||||||
</Style>
|
|
||||||
<DataTemplate x:Key="PasteFormatTemplate" x:DataType="local:PasteFormat">
|
|
||||||
<Button
|
|
||||||
Margin="0"
|
|
||||||
Padding="5,0,5,0"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Stretch"
|
|
||||||
VerticalContentAlignment="Stretch"
|
|
||||||
AllowFocusOnInteraction="False"
|
|
||||||
BorderThickness="0"
|
|
||||||
Click="ListView_Button_Click"
|
|
||||||
IsEnabled="{x:Bind IsEnabled, Mode=OneWay}">
|
|
||||||
<Grid Opacity="{x:Bind Opacity, Mode=OneWay}">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="26" />
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<ToolTipService.ToolTip>
|
|
||||||
<TextBlock Text="{x:Bind ToolTip, Mode=OneWay}" />
|
|
||||||
</ToolTipService.ToolTip>
|
|
||||||
<FontIcon
|
|
||||||
Margin="0,0,0,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
AutomationProperties.AccessibilityView="Raw"
|
|
||||||
FontSize="16"
|
|
||||||
Glyph="{x:Bind IconGlyph, Mode=OneWay}" />
|
|
||||||
<TextBlock
|
|
||||||
Grid.Column="1"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
x:Phase="1"
|
|
||||||
Text="{x:Bind Name, Mode=OneWay}" />
|
|
||||||
<TextBlock
|
|
||||||
Grid.Column="2"
|
|
||||||
Margin="0,0,8,0"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
|
||||||
Text="{x:Bind ShortcutText, Mode=OneWay}"
|
|
||||||
Visibility="{x:Bind ShortcutText.Length, Mode=OneWay, Converter={StaticResource countToVisibilityConverter}}" />
|
|
||||||
</Grid>
|
|
||||||
</Button>
|
|
||||||
</DataTemplate>
|
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.KeyboardAccelerators>
|
<Page.KeyboardAccelerators>
|
||||||
<KeyboardAccelerator Key="Escape" Invoked="KeyboardAccelerator_Invoked" />
|
<KeyboardAccelerator Key="Escape" Invoked="KeyboardAccelerator_Invoked" />
|
||||||
|
@ -196,10 +216,10 @@
|
||||||
x:Name="PasteOptionsListView"
|
x:Name="PasteOptionsListView"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
IsItemClickEnabled="False"
|
IsItemClickEnabled="True"
|
||||||
ItemContainerStyle="{StaticResource PasteFormatListViewItemStyle}"
|
ItemClick="PasteFormat_ItemClick"
|
||||||
ItemContainerTransitions="{x:Null}"
|
ItemContainerTransitions="{x:Null}"
|
||||||
ItemTemplate="{StaticResource PasteFormatTemplate}"
|
ItemTemplateSelector="{StaticResource PasteFormatTemplateSelector}"
|
||||||
ItemsSource="{x:Bind ViewModel.StandardPasteFormats, Mode=OneWay}"
|
ItemsSource="{x:Bind ViewModel.StandardPasteFormats, Mode=OneWay}"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||||
ScrollViewer.VerticalScrollMode="Auto"
|
ScrollViewer.VerticalScrollMode="Auto"
|
||||||
|
@ -217,10 +237,10 @@
|
||||||
x:Name="CustomActionsListView"
|
x:Name="CustomActionsListView"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
IsItemClickEnabled="False"
|
IsItemClickEnabled="True"
|
||||||
ItemContainerStyle="{StaticResource PasteFormatListViewItemStyle}"
|
ItemClick="PasteFormat_ItemClick"
|
||||||
ItemContainerTransitions="{x:Null}"
|
ItemContainerTransitions="{x:Null}"
|
||||||
ItemTemplate="{StaticResource PasteFormatTemplate}"
|
ItemTemplateSelector="{StaticResource PasteFormatTemplateSelector}"
|
||||||
ItemsSource="{x:Bind ViewModel.CustomActionPasteFormats, Mode=OneWay}"
|
ItemsSource="{x:Bind ViewModel.CustomActionPasteFormats, Mode=OneWay}"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||||
ScrollViewer.VerticalScrollMode="Auto"
|
ScrollViewer.VerticalScrollMode="Auto"
|
||||||
|
@ -232,7 +252,6 @@
|
||||||
Height="1"
|
Height="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Fill="{ThemeResource DividerStrokeColorDefaultBrush}" />
|
Fill="{ThemeResource DividerStrokeColorDefaultBrush}" />
|
||||||
<!-- x:Uid="ClipboardHistoryButton" -->
|
|
||||||
<Button
|
<Button
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
Height="32"
|
Height="32"
|
||||||
|
@ -241,6 +260,7 @@
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
VerticalContentAlignment="Stretch"
|
VerticalContentAlignment="Stretch"
|
||||||
|
AutomationProperties.LabeledBy="{x:Bind ClipboardHistoryButton}"
|
||||||
IsEnabled="{x:Bind ViewModel.ClipboardHistoryEnabled, Mode=TwoWay}"
|
IsEnabled="{x:Bind ViewModel.ClipboardHistoryEnabled, Mode=TwoWay}"
|
||||||
Style="{StaticResource SubtleButtonStyle}">
|
Style="{StaticResource SubtleButtonStyle}">
|
||||||
<Grid
|
<Grid
|
||||||
|
@ -259,6 +279,7 @@
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Glyph="" />
|
Glyph="" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
x:Name="ClipboardHistoryButton"
|
||||||
x:Uid="ClipboardHistoryButton"
|
x:Uid="ClipboardHistoryButton"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
|
@ -287,6 +308,7 @@
|
||||||
<Grid
|
<Grid
|
||||||
Height="40"
|
Height="40"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
|
AutomationProperties.Name="{x:Bind Description, Mode=OneWay}"
|
||||||
ColumnSpacing="8"
|
ColumnSpacing="8"
|
||||||
ToolTipService.ToolTip="{x:Bind Content}">
|
ToolTipService.ToolTip="{x:Bind Content}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
@ -308,7 +330,8 @@
|
||||||
TextTrimming="CharacterEllipsis"
|
TextTrimming="CharacterEllipsis"
|
||||||
Visibility="Visible" />
|
Visibility="Visible" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="moreInfo"
|
x:Name="ClipboardHistoryItemMoreOptionsButton"
|
||||||
|
x:Uid="ClipboardHistoryItemMoreOptionsButton"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||||
|
|
|
@ -130,9 +130,9 @@ namespace AdvancedPaste.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ListView_Button_Click(object sender, RoutedEventArgs e)
|
private async void PasteFormat_ItemClick(object sender, ItemClickEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Button { DataContext: PasteFormat format })
|
if (e.ClickedItem is PasteFormat format)
|
||||||
{
|
{
|
||||||
await ViewModel.ExecutePasteFormatAsync(format, PasteActionSource.ContextMenu);
|
await ViewModel.ExecutePasteFormatAsync(format, PasteActionSource.ContextMenu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using AdvancedPaste.Helpers;
|
||||||
using Microsoft.UI.Xaml.Media.Imaging;
|
using Microsoft.UI.Xaml.Media.Imaging;
|
||||||
using Windows.ApplicationModel.DataTransfer;
|
using Windows.ApplicationModel.DataTransfer;
|
||||||
|
|
||||||
|
@ -14,4 +15,8 @@ public class ClipboardItem
|
||||||
public ClipboardHistoryItem Item { get; set; }
|
public ClipboardHistoryItem Item { get; set; }
|
||||||
|
|
||||||
public BitmapImage Image { get; set; }
|
public BitmapImage Image { get; set; }
|
||||||
|
|
||||||
|
public string Description => !string.IsNullOrEmpty(Content) ? Content :
|
||||||
|
Image is not null ? ResourceLoaderInstance.ResourceLoader.GetString("ClipboardHistoryImage") :
|
||||||
|
string.Empty;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public sealed class PasteFormat
|
||||||
|
|
||||||
public bool IsEnabled { get; private init; }
|
public bool IsEnabled { get; private init; }
|
||||||
|
|
||||||
public double Opacity => IsEnabled ? 1 : 0.5;
|
public string AccessibleName => $"{Name} ({ShortcutText})";
|
||||||
|
|
||||||
public string ToolTip => string.IsNullOrEmpty(Prompt) ? $"{Name} ({ShortcutText})" : Prompt;
|
public string ToolTip => string.IsNullOrEmpty(Prompt) ? $"{Name} ({ShortcutText})" : Prompt;
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,15 @@
|
||||||
<data name="ClipboardHistoryButton.Text" xml:space="preserve">
|
<data name="ClipboardHistoryButton.Text" xml:space="preserve">
|
||||||
<value>Clipboard history</value>
|
<value>Clipboard history</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ClipboardHistoryButton.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
|
<value>Clipboard history</value>
|
||||||
|
</data>
|
||||||
|
<data name="ClipboardHistoryImage" xml:space="preserve">
|
||||||
|
<value>Image data</value>
|
||||||
|
</data>
|
||||||
|
<data name="ClipboardHistoryItemMoreOptionsButton.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
|
<value>More options</value>
|
||||||
|
</data>
|
||||||
<data name="ClipboardHistoryItemDeleteButton.Text" xml:space="preserve">
|
<data name="ClipboardHistoryItemDeleteButton.Text" xml:space="preserve">
|
||||||
<value>Delete</value>
|
<value>Delete</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче