-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Baka632/230803-AddAccessibilitySupport
添加辅助功能支持
- Loading branch information
Showing
21 changed files
with
489 additions
and
472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<UserControl | ||
x:Class="ArknightsStoryText.UWP.Controls.StoryTextExpander" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:converter="using:ArknightsStoryText.UWP.Helpers.Converter" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:helper="using:ArknightsStoryText.UWP.Helpers" | ||
xmlns:local="using:ArknightsStoryText.UWP.Controls" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:models="using:ArknightsStoryText.UWP.Models" | ||
d:DataContext="{d:DesignInstance Type=local:StoryTextExpander}" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400" | ||
mc:Ignorable="d"> | ||
|
||
<StackPanel> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid | ||
Grid.Column="0" | ||
HorizontalAlignment="Stretch" | ||
Background="Transparent" | ||
Tapped="OnTitleGridTapped"> | ||
<TextBlock | ||
HorizontalAlignment="Left" | ||
AutomationProperties.AccessibilityView="Raw" | ||
Style="{StaticResource TitleTextBlockStyle}" | ||
Text="{x:Bind Title, Mode=OneWay}" /> | ||
</Grid> | ||
|
||
<ToggleButton | ||
Grid.Column="1" | ||
Width="40" | ||
Height="40" | ||
HorizontalAlignment="Right" | ||
AutomationProperties.Name="{x:Bind StoryTextViewableToggleButtonAutomationName, Mode=OneWay}" | ||
Background="Transparent" | ||
BorderThickness="0" | ||
Click="OnStoryTextViewableToggleButtonClicked" | ||
IsChecked="{x:Bind helper:XamlHelper.ReverseBoolean(IsExpanded), Mode=OneWay}" | ||
IsTabStop="False" | ||
ToolTipService.ToolTip="{x:Bind StoryTextViewableToggleButtonAutomationName, Mode=OneWay}"> | ||
<FontIcon | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
FontFamily="{ThemeResource SymbolThemeFontFamily}" | ||
Glyph="{x:Bind ChevronIcon, Mode=OneWay}" /> | ||
</ToggleButton> | ||
</Grid> | ||
<StackPanel | ||
Height="2" | ||
Margin="0,5,0,5" | ||
HorizontalAlignment="Stretch" | ||
Background="{StaticResource AppBarSeparatorForegroundThemeBrush}" /> | ||
<Grid Grid.Column="0" HorizontalAlignment="Stretch"> | ||
<TextBlock | ||
x:Name="StoryTextBlock" | ||
Grid.Column="0" | ||
HorizontalAlignment="Stretch" | ||
FontFamily="{x:Bind FontFamily, Mode=OneWay}" | ||
FontSize="{x:Bind FontSize, Mode=OneWay}" | ||
IsTextSelectionEnabled="True" | ||
Style="{StaticResource BodyTextBlockStyle}" | ||
Text="{x:Bind Text, Mode=OneWay}" | ||
TextWrapping="Wrap" | ||
Visibility="{x:Bind StoryTextVisibility, Mode=OneWay}"> | ||
<TextBlock.RenderTransform> | ||
<CompositeTransform /> | ||
</TextBlock.RenderTransform> | ||
<TextBlock.Resources> | ||
<Storyboard x:Name="StoryTextBlockShow"> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="StoryTextBlock" Storyboard.TargetProperty="Visibility"> | ||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" /> | ||
</ObjectAnimationUsingKeyFrames> | ||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="StoryTextBlock" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)"> | ||
<DiscreteDoubleKeyFrame KeyTime="0" Value="-10" /> | ||
<SplineDoubleKeyFrame | ||
KeySpline="0.0, 0.0, 0.0, 1.0" | ||
KeyTime="0:0:0.333" | ||
Value="0" /> | ||
</DoubleAnimationUsingKeyFrames> | ||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="StoryTextBlock" Storyboard.TargetProperty="Opacity"> | ||
<DiscreteDoubleKeyFrame KeyTime="0" Value="0" /> | ||
<SplineDoubleKeyFrame | ||
KeySpline="0.0, 0.0, 0.0, 1.0" | ||
KeyTime="0:0:0.333" | ||
Value="1" /> | ||
</DoubleAnimationUsingKeyFrames> | ||
</Storyboard> | ||
|
||
<Storyboard x:Name="StoryTextBlockHide"> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="StoryTextBlock" Storyboard.TargetProperty="Visibility"> | ||
<DiscreteObjectKeyFrame KeyTime="0:0:0.1" Value="Collapsed" /> | ||
</ObjectAnimationUsingKeyFrames> | ||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="StoryTextBlock" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)"> | ||
<DiscreteDoubleKeyFrame KeyTime="0" Value="0" /> | ||
<SplineDoubleKeyFrame | ||
KeySpline="0.0, 0.0, 0.0, 1.0" | ||
KeyTime="0:0:0.1" | ||
Value="-10" /> | ||
</DoubleAnimationUsingKeyFrames> | ||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="StoryTextBlock" Storyboard.TargetProperty="Opacity"> | ||
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" /> | ||
<SplineDoubleKeyFrame | ||
KeySpline="0.0, 0.0, 0.0, 1.0" | ||
KeyTime="0:0:0.1" | ||
Value="0" /> | ||
</DoubleAnimationUsingKeyFrames> | ||
</Storyboard> | ||
</TextBlock.Resources> | ||
</TextBlock> | ||
</Grid> | ||
</StackPanel> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using ArknightsStoryText.UWP.Helpers; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
//https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 | ||
|
||
namespace ArknightsStoryText.UWP.Controls | ||
{ | ||
public sealed partial class StoryTextExpander : UserControl | ||
{ | ||
public StoryTextExpander() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置剧情文本的标题 | ||
/// </summary> | ||
public string Title | ||
{ | ||
get => (string)GetValue(TitleProperty); | ||
set => SetValue(TitleProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// 用以标识 <see cref="StoryTextTitle"/> 的依赖属性 | ||
/// </summary> | ||
public static readonly DependencyProperty TitleProperty = | ||
DependencyProperty.Register("Title", typeof(string), typeof(StoryTextExpander), new PropertyMetadata(null)); | ||
|
||
/// <summary> | ||
/// 获取或设置剧情文本 | ||
/// </summary> | ||
public string Text | ||
{ | ||
get => (string)GetValue(TextProperty); | ||
set => SetValue(TextProperty, value); | ||
} | ||
|
||
/// <summary> | ||
/// 用以标识 <see cref="StoryText"/> 的依赖属性 | ||
/// </summary> | ||
public static readonly DependencyProperty TextProperty = | ||
DependencyProperty.Register("Text", typeof(string), typeof(StoryTextExpander), new PropertyMetadata(null)); | ||
|
||
/// <summary> | ||
/// 获取或设置控件是否展开的值 | ||
/// </summary> | ||
public bool IsExpanded | ||
{ | ||
get => (bool)GetValue(IsExpandedProperty); | ||
set | ||
{ | ||
SetValue(IsExpandedProperty, value); | ||
OnIsExpandedChanged(value); | ||
} | ||
} | ||
|
||
private void OnIsExpandedChanged(bool value) | ||
{ | ||
if (value) | ||
{ | ||
//状态:展开 | ||
StoryTextBlockShow.Begin(); | ||
//StoryTextVisibility = Visibility.Visible; | ||
ChevronIcon = "\uE70E"; | ||
StoryTextViewableToggleButtonAutomationName = "ClickToCollapse".GetLocalized(); | ||
} | ||
else | ||
{ | ||
//状态:折叠 | ||
StoryTextBlockHide.Begin(); | ||
//StoryTextVisibility = Visibility.Collapsed; | ||
ChevronIcon = "\uE70D"; | ||
StoryTextViewableToggleButtonAutomationName = "ClickToExpand".GetLocalized(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 用以标识 <see cref="IsExpanded"/> 的依赖属性 | ||
/// </summary> | ||
public static readonly DependencyProperty IsExpandedProperty = | ||
DependencyProperty.Register("IsExpanded", typeof(bool), typeof(StoryTextExpander), new PropertyMetadata(true)); | ||
|
||
#region Private Dependency Property | ||
private string ChevronIcon | ||
{ | ||
get => (string)GetValue(ChevronIconProperty); | ||
set => SetValue(ChevronIconProperty, value); | ||
} | ||
|
||
private static readonly DependencyProperty ChevronIconProperty = | ||
DependencyProperty.Register("ChevronIcon", typeof(string), typeof(StoryTextExpander), new PropertyMetadata("\uE70E")); | ||
|
||
private Visibility StoryTextVisibility | ||
{ | ||
get => (Visibility)GetValue(StoryTextVisibilityProperty); | ||
set => SetValue(StoryTextVisibilityProperty, value); | ||
} | ||
|
||
private static readonly DependencyProperty StoryTextVisibilityProperty = | ||
DependencyProperty.Register("StoryTextVisibility", typeof(Visibility), typeof(StoryTextExpander), new PropertyMetadata(Visibility.Visible)); | ||
|
||
private string StoryTextViewableToggleButtonAutomationName | ||
{ | ||
get => (string)GetValue(StoryTextViewableToggleButtonAutomationNameProperty); | ||
set => SetValue(StoryTextViewableToggleButtonAutomationNameProperty, value); | ||
} | ||
|
||
// Using a DependencyProperty as the backing store for StoryTextViewableToggleButtonAutomationName. This enables animation, styling, binding, etc... | ||
private static readonly DependencyProperty StoryTextViewableToggleButtonAutomationNameProperty = | ||
DependencyProperty.Register("StoryTextViewableToggleButtonAutomationName", typeof(string), typeof(StoryTextExpander), new PropertyMetadata("ClickToCollapse".GetLocalized())); | ||
#endregion | ||
|
||
private void OnTitleGridTapped(object sender, TappedRoutedEventArgs e) | ||
{ | ||
IsExpanded = !IsExpanded; | ||
} | ||
|
||
private void OnStoryTextViewableToggleButtonClicked(object sender, RoutedEventArgs e) | ||
{ | ||
ToggleButton toggleButton = (ToggleButton)sender; | ||
IsExpanded = !toggleButton.IsChecked.Value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.