Browse Source

Accessibility imporvemnts for lazy people

CPKreuz 2 years ago
parent
commit
69519247e9

+ 6 - 3
src/PixiEditor/Views/Dialogs/ExportFilePopup.xaml

@@ -24,7 +24,7 @@
         <CommandBinding Command="{x:Static SystemCommands.CloseWindowCommand}" CanExecute="CommandBinding_CanExecute"
         <CommandBinding Command="{x:Static SystemCommands.CloseWindowCommand}" CanExecute="CommandBinding_CanExecute"
                         Executed="CommandBinding_Executed_Close" />
                         Executed="CommandBinding_Executed_Close" />
     </Window.CommandBindings>
     </Window.CommandBindings>
-
+    
     <DockPanel Background="{StaticResource AccentColor}" Focusable="True">
     <DockPanel Background="{StaticResource AccentColor}" Focusable="True">
         <i:Interaction.Behaviors>
         <i:Interaction.Behaviors>
             <behaviours:ClearFocusOnClickBehavior/>
             <behaviours:ClearFocusOnClickBehavior/>
@@ -52,8 +52,11 @@
                                              ChosenHeight="{Binding Path=SaveHeight, Mode=TwoWay, ElementName=saveFilePopup}"
                                              ChosenHeight="{Binding Path=SaveHeight, Mode=TwoWay, ElementName=saveFilePopup}"
                                              ChosenWidth="{Binding Path=SaveWidth, Mode=TwoWay, ElementName=saveFilePopup}" />
                                              ChosenWidth="{Binding Path=SaveWidth, Mode=TwoWay, ElementName=saveFilePopup}" />
             <TextBlock Grid.Row="1" Foreground="Snow" Margin="5,0,5,10" TextWrapping="Wrap" VerticalAlignment="Bottom" TextAlignment="Center" 
             <TextBlock Grid.Row="1" Foreground="Snow" Margin="5,0,5,10" TextWrapping="Wrap" VerticalAlignment="Bottom" TextAlignment="Center" 
-                       Width="200"
-                       d:Text="If you want to share the image, try 400% for the best clarity" Text="{Binding SizeHint, ElementName=saveFilePopup}"/>
+                       Width="200">
+                <Hyperlink Command="{Binding SetBestPercentageCommand, ElementName=saveFilePopup}">
+                    <Run Text="{Binding SizeHint, Mode=OneTime, ElementName=saveFilePopup}" d:Text="If you want to share the image, try 400% for the best clarity" />
+                </Hyperlink>
+            </TextBlock>
             </Grid>
             </Grid>
         </Border>
         </Border>
 
 

+ 19 - 0
src/PixiEditor/Views/Dialogs/ExportFilePopup.xaml.cs

@@ -1,5 +1,6 @@
 using System.Windows;
 using System.Windows;
 using System.Windows.Input;
 using System.Windows.Input;
+using PixiEditor.Helpers;
 using PixiEditor.Localization;
 using PixiEditor.Localization;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
@@ -15,8 +16,17 @@ internal partial class ExportFilePopup : Window
     public static readonly DependencyProperty SaveWidthProperty =
     public static readonly DependencyProperty SaveWidthProperty =
         DependencyProperty.Register(nameof(SaveWidth), typeof(int), typeof(ExportFilePopup), new PropertyMetadata(32));
         DependencyProperty.Register(nameof(SaveWidth), typeof(int), typeof(ExportFilePopup), new PropertyMetadata(32));
 
 
+    public static readonly DependencyProperty SetBestPercentageCommandProperty =
+        DependencyProperty.Register(nameof(SetBestPercentageCommand), typeof(RelayCommand), typeof(ExportFilePopup));
+
     private readonly SaveFilePopupViewModel dataContext = new SaveFilePopupViewModel();
     private readonly SaveFilePopupViewModel dataContext = new SaveFilePopupViewModel();
 
 
+    public RelayCommand SetBestPercentageCommand
+    {
+        get => (RelayCommand)GetValue(SetBestPercentageCommandProperty);
+        set => SetValue(SetBestPercentageCommandProperty, value);
+    }
+
     private int imageWidth;
     private int imageWidth;
     private int imageHeight;
     private int imageHeight;
     public string SizeHint => new LocalizedString("EXPORT_SIZE_HINT", GetBestPercentage());
     public string SizeHint => new LocalizedString("EXPORT_SIZE_HINT", GetBestPercentage());
@@ -43,6 +53,8 @@ internal partial class ExportFilePopup : Window
 
 
         SaveWidth = imageWidth;
         SaveWidth = imageWidth;
         SaveHeight = imageHeight;
         SaveHeight = imageHeight;
+
+        SetBestPercentageCommand = new RelayCommand(SetBestPercentage);
     }
     }
 
 
     private int GetBestPercentage()
     private int GetBestPercentage()
@@ -56,6 +68,13 @@ internal partial class ExportFilePopup : Window
         return 100;
         return 100;
     }
     }
 
 
+    private void SetBestPercentage(object parameter)
+    {
+        sizePicker.ChosenPercentageSize = GetBestPercentage();
+        sizePicker.PercentageRb.IsChecked = true;
+        sizePicker.PercentageLostFocus(null);
+    }
+
     public int SaveWidth
     public int SaveWidth
     {
     {
         get => (int)GetValue(SaveWidthProperty);
         get => (int)GetValue(SaveWidthProperty);

+ 4 - 2
src/PixiEditor/Views/UserControls/SizePicker.xaml

@@ -48,7 +48,8 @@
                              IsChecked="{Binding Path=SelectedUnit,  
                              IsChecked="{Binding Path=SelectedUnit,  
                                               ElementName=uc, 
                                               ElementName=uc, 
                                               Converter={converters:EnumBooleanConverter}, 
                                               Converter={converters:EnumBooleanConverter}, 
-                                              ConverterParameter=Percentage
+                                              ConverterParameter=Percentage,
+                                              Mode=TwoWay
                                               }" local:Translator.Key="PERCENTAGE"/>
                                               }" local:Translator.Key="PERCENTAGE"/>
                 <userControls:SizeInput Grid.Row="0" 
                 <userControls:SizeInput Grid.Row="0" 
                                      VerticalAlignment="Center"
                                      VerticalAlignment="Center"
@@ -77,7 +78,8 @@
                              VerticalAlignment="Center"
                              VerticalAlignment="Center"
                              IsChecked="{Binding Path=SelectedUnit,  
                              IsChecked="{Binding Path=SelectedUnit,  
                                               ElementName=uc, 
                                               ElementName=uc, 
-                                              Converter={converters:EnumBooleanConverter}, 
+                                              Converter={converters:EnumBooleanConverter},
+                                              Mode=TwoWay,
                                               ConverterParameter=Pixel}" local:Translator.Key="ABSOLUTE"/>
                                               ConverterParameter=Pixel}" local:Translator.Key="ABSOLUTE"/>
 
 
             </Grid>
             </Grid>

+ 1 - 1
src/PixiEditor/Views/UserControls/SizePicker.xaml.cs

@@ -106,7 +106,7 @@ internal partial class SizePicker : UserControl
     private void WidthLostFocus(object param) => OnSizeUpdate(true);
     private void WidthLostFocus(object param) => OnSizeUpdate(true);
     private void HeightLostFocus(object param) => OnSizeUpdate(false);
     private void HeightLostFocus(object param) => OnSizeUpdate(false);
 
 
-    private void PercentageLostFocus(object param)
+    public void PercentageLostFocus(object param)
     {
     {
         if (!initSize.HasValue)
         if (!initSize.HasValue)
             return;
             return;