[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">
|
||||
<Button
|
||||
Padding="4"
|
||||
AutomationProperties.LabeledBy="{x:Bind ThumbsUpFeedback}"
|
||||
Click="ThumbUpDown_Click"
|
||||
CommandParameter="True"
|
||||
Content="{ui:FontIcon Glyph=,
|
||||
|
@ -417,11 +418,12 @@
|
|||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource SubtleButtonStyle}">
|
||||
<ToolTipService.ToolTip>
|
||||
<TextBlock x:Uid="ThumbsUpFeedback" />
|
||||
<TextBlock x:Name="ThumbsUpFeedback" x:Uid="ThumbsUpFeedback" />
|
||||
</ToolTipService.ToolTip>
|
||||
</Button>
|
||||
<Button
|
||||
Padding="4"
|
||||
AutomationProperties.LabeledBy="{x:Bind ThumbsDownFeedback}"
|
||||
Click="ThumbUpDown_Click"
|
||||
CommandParameter="False"
|
||||
Content="{ui:FontIcon Glyph=,
|
||||
|
@ -429,7 +431,7 @@
|
|||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource SubtleButtonStyle}">
|
||||
<ToolTipService.ToolTip>
|
||||
<TextBlock x:Uid="ThumbsDownFeedback" />
|
||||
<TextBlock x:Name="ThumbsDownFeedback" x:Uid="ThumbsDownFeedback" />
|
||||
</ToolTipService.ToolTip>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
@ -537,6 +539,7 @@
|
|||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ui:VisualExtensions.NormalizedCenterPoint="0.5,0.5"
|
||||
AutomationProperties.HelpText="{x:Bind ViewModel.CustomAIUnavailableErrorText, Mode=OneWay}"
|
||||
Command="{x:Bind GenerateCustomAICommand}"
|
||||
Content="{ui:FontIcon Glyph=,
|
||||
FontSize=16}"
|
||||
|
|
|
@ -21,39 +21,24 @@
|
|||
x:Name="customActionsToMinHeightConverter"
|
||||
ValueIfNonZero="40"
|
||||
ValueIfZero="0" />
|
||||
<Style
|
||||
x:Key="PaddingLessFlyoutPresenterStyle"
|
||||
BasedOn="{StaticResource DefaultFlyoutPresenterStyle}"
|
||||
TargetType="FlyoutPresenter">
|
||||
<Style.Setters>
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style.Setters>
|
||||
</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
|
||||
<controls:PasteFormatTemplateSelector x:Key="PasteFormatTemplateSelector">
|
||||
<controls:PasteFormatTemplateSelector.ItemTemplate>
|
||||
<DataTemplate x:DataType="local:PasteFormat">
|
||||
<Grid
|
||||
Margin="0"
|
||||
Padding="5,0,5,0"
|
||||
Padding="-9,0,0,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}">
|
||||
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>
|
||||
|
@ -75,11 +60,46 @@
|
|||
VerticalAlignment="Center"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind ShortcutText, Mode=OneWay}"
|
||||
Visibility="{x:Bind ShortcutText.Length, Mode=OneWay, Converter={StaticResource countToVisibilityConverter}}" />
|
||||
Text="{x:Bind ShortcutText, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Button>
|
||||
</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
|
||||
x:Key="PaddingLessFlyoutPresenterStyle"
|
||||
BasedOn="{StaticResource DefaultFlyoutPresenterStyle}"
|
||||
TargetType="FlyoutPresenter">
|
||||
<Style.Setters>
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
<Page.KeyboardAccelerators>
|
||||
<KeyboardAccelerator Key="Escape" Invoked="KeyboardAccelerator_Invoked" />
|
||||
|
@ -196,10 +216,10 @@
|
|||
x:Name="PasteOptionsListView"
|
||||
Grid.Row="0"
|
||||
VerticalAlignment="Bottom"
|
||||
IsItemClickEnabled="False"
|
||||
ItemContainerStyle="{StaticResource PasteFormatListViewItemStyle}"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="PasteFormat_ItemClick"
|
||||
ItemContainerTransitions="{x:Null}"
|
||||
ItemTemplate="{StaticResource PasteFormatTemplate}"
|
||||
ItemTemplateSelector="{StaticResource PasteFormatTemplateSelector}"
|
||||
ItemsSource="{x:Bind ViewModel.StandardPasteFormats, Mode=OneWay}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
ScrollViewer.VerticalScrollMode="Auto"
|
||||
|
@ -217,10 +237,10 @@
|
|||
x:Name="CustomActionsListView"
|
||||
Grid.Row="2"
|
||||
VerticalAlignment="Top"
|
||||
IsItemClickEnabled="False"
|
||||
ItemContainerStyle="{StaticResource PasteFormatListViewItemStyle}"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="PasteFormat_ItemClick"
|
||||
ItemContainerTransitions="{x:Null}"
|
||||
ItemTemplate="{StaticResource PasteFormatTemplate}"
|
||||
ItemTemplateSelector="{StaticResource PasteFormatTemplateSelector}"
|
||||
ItemsSource="{x:Bind ViewModel.CustomActionPasteFormats, Mode=OneWay}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
ScrollViewer.VerticalScrollMode="Auto"
|
||||
|
@ -232,7 +252,6 @@
|
|||
Height="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Fill="{ThemeResource DividerStrokeColorDefaultBrush}" />
|
||||
<!-- x:Uid="ClipboardHistoryButton" -->
|
||||
<Button
|
||||
Grid.Row="4"
|
||||
Height="32"
|
||||
|
@ -241,6 +260,7 @@
|
|||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
AutomationProperties.LabeledBy="{x:Bind ClipboardHistoryButton}"
|
||||
IsEnabled="{x:Bind ViewModel.ClipboardHistoryEnabled, Mode=TwoWay}"
|
||||
Style="{StaticResource SubtleButtonStyle}">
|
||||
<Grid
|
||||
|
@ -259,6 +279,7 @@
|
|||
FontSize="16"
|
||||
Glyph="" />
|
||||
<TextBlock
|
||||
x:Name="ClipboardHistoryButton"
|
||||
x:Uid="ClipboardHistoryButton"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center" />
|
||||
|
@ -287,6 +308,7 @@
|
|||
<Grid
|
||||
Height="40"
|
||||
HorizontalAlignment="Stretch"
|
||||
AutomationProperties.Name="{x:Bind Description, Mode=OneWay}"
|
||||
ColumnSpacing="8"
|
||||
ToolTipService.ToolTip="{x:Bind Content}">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -308,7 +330,8 @@
|
|||
TextTrimming="CharacterEllipsis"
|
||||
Visibility="Visible" />
|
||||
<Button
|
||||
x:Name="moreInfo"
|
||||
x:Name="ClipboardHistoryItemMoreOptionsButton"
|
||||
x:Uid="ClipboardHistoryItemMoreOptionsButton"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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.Helpers;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
|
||||
|
@ -14,4 +15,8 @@ public class ClipboardItem
|
|||
public ClipboardHistoryItem Item { 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 double Opacity => IsEnabled ? 1 : 0.5;
|
||||
public string AccessibleName => $"{Name} ({ShortcutText})";
|
||||
|
||||
public string ToolTip => string.IsNullOrEmpty(Prompt) ? $"{Name} ({ShortcutText})" : Prompt;
|
||||
|
||||
|
|
|
@ -144,6 +144,15 @@
|
|||
<data name="ClipboardHistoryButton.Text" xml:space="preserve">
|
||||
<value>Clipboard history</value>
|
||||
</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">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
|
|
Загрузка…
Ссылка в новой задаче