Kaynağa Gözat

Settings window shortcuts page wip

Equbuxu 1 yıl önce
ebeveyn
işleme
1013bc5c2c

+ 6 - 3
src/PixiEditor.AvaloniaUI/PixiEditor.AvaloniaUI.csproj

@@ -64,12 +64,15 @@
     </ItemGroup>
   
     <ItemGroup>
-      <Folder Include="Views\Buttons\" />
+      <AvaloniaResource Include="Images\**" />
+      <AvaloniaResource Include="Fonts\**" />
     </ItemGroup>
   
     <ItemGroup>
-      <AvaloniaResource Include="Images\**" />
-      <AvaloniaResource Include="Fonts\**" />
+      <AvaloniaXaml Remove="Views\Buttons\**" />
+      <Compile Remove="Views\Buttons\**" />
+      <EmbeddedResource Remove="Views\Buttons\**" />
+      <None Remove="Views\Buttons\**" />
     </ItemGroup>
   
     <ItemGroup>

+ 28 - 46
src/PixiEditor.AvaloniaUI/ViewModels/SettingsWindowViewModel.cs

@@ -38,10 +38,14 @@ internal class SettingsPage : ObservableObject
     }
 }
 
-internal class SettingsWindowViewModel : ViewModelBase
+internal partial class SettingsWindowViewModel : ViewModelBase
 {
     private string searchTerm;
+    
+    [ObservableProperty]
     private int visibleGroups;
+    
+    [ObservableProperty]
     private int currentPage;
 
     public bool ShowUpdateTab
@@ -71,18 +75,6 @@ internal class SettingsWindowViewModel : ViewModelBase
         }
     }
 
-    public int CurrentPage
-    {
-        get => currentPage;
-        set => SetProperty(ref currentPage, value);
-    }
-
-    public int VisibleGroups
-    {
-        get => visibleGroups;
-        private set => SetProperty(ref visibleGroups, value);
-    }
-
     public SettingsViewModel SettingsSubViewModel { get; set; }
 
     public List<GroupSearchResult> Commands { get; }
@@ -275,9 +267,9 @@ internal class SettingsWindowViewModel : ViewModelBase
     {
         Pages = new ObservableCollection<SettingsPage>
         {
-            new SettingsPage("GENERAL"),
-            new SettingsPage("DISCORD"),
-            new SettingsPage("KEY_BINDINGS"),
+            new("GENERAL"),
+            new("DISCORD"),
+            new("KEY_BINDINGS"),
         };
 
         ILocalizationProvider.Current.OnLanguageChanged += OnLanguageChanged;
@@ -349,43 +341,33 @@ internal class SettingsWindowViewModel : ViewModelBase
             group.IsVisible = visibleCommands > 0;
         }
     }
+}
 
-    internal class GroupSearchResult : ObservableObject
-    {
-        private bool isVisible;
-
-        public LocalizedString DisplayName { get; set; }
-
-        public List<CommandSearchResult> Commands { get; set; }
+internal partial class GroupSearchResult : ObservableObject
+{
+    [ObservableProperty]
+    private bool isVisible;
 
-        public bool IsVisible
-        {
-            get => isVisible;
-            set => SetProperty(ref isVisible, value);
-        }
+    public LocalizedString DisplayName { get; set; }
 
-        public GroupSearchResult(CommandGroup group)
-        {
-            DisplayName = group.DisplayName;
-            Commands = new(group.VisibleCommands.Select(x => new CommandSearchResult(x)));
-        }
-    }
+    public List<CommandSearchResult> Commands { get; set; }
 
-    internal class CommandSearchResult : ObservableObject
+    public GroupSearchResult(CommandGroup group)
     {
-        private bool isVisible;
+        DisplayName = group.DisplayName;
+        Commands = new(group.VisibleCommands.Select(x => new CommandSearchResult(x)));
+    }
+}
 
-        public Models.Commands.Commands.Command Command { get; set; }
+internal partial class CommandSearchResult : ObservableObject
+{
+    [ObservableProperty]
+    private bool isVisible;
 
-        public bool IsVisible
-        {
-            get => isVisible;
-            set => SetProperty(ref isVisible, value);
-        }
+    public Models.Commands.Commands.Command Command { get; set; }
 
-        public CommandSearchResult(Models.Commands.Commands.Command command)
-        {
-            Command = command;
-        }
+    public CommandSearchResult(Models.Commands.Commands.Command command)
+    {
+        Command = command;
     }
 }

+ 28 - 53
src/PixiEditor.AvaloniaUI/Views/Windows/Settings/SettingsWindow.axaml

@@ -28,11 +28,11 @@
     Background="{DynamicResource AccentColor}"
     FlowDirection="{markupExtensions:Localization FlowDirection}"
     ui:Translator.Key="SETTINGS">
-    
+
     <Window.Resources>
         <vm:SettingsWindowViewModel x:Key="SettingsWindowViewModel"/>
     </Window.Resources>
-    
+
     <!-- TODO
     <WindowChrome.WindowChrome>
         <WindowChrome CaptionHeight="32"  GlassFrameThickness="0.1"
@@ -44,7 +44,7 @@
                         Executed="CommandBinding_Executed_Close" />
     </Window.CommandBindings>
     -->
-    
+
     <DockPanel Focusable="True" Background="{DynamicResource ThemeBackgroundBrush1}">
         <!--Background="{StaticResource MainColor}"-->
         <i:Interaction.Behaviors>
@@ -75,7 +75,9 @@
             <controls:FixedSizeStackPanel Orientation="Vertical" ChildSize="32" VerticalChildrenAlignment="Center">
                 <controls:FixedSizeStackPanel.IsVisible>
                     <Binding Path="CurrentPage" Converter="{converters:IsEqualConverter}">
-                        <Binding.ConverterParameter><sys:Int32>0</sys:Int32></Binding.ConverterParameter>
+                        <Binding.ConverterParameter>
+                            <sys:Int32>0</sys:Int32>
+                        </Binding.ConverterParameter>
                     </Binding>
                 </controls:FixedSizeStackPanel.IsVisible>
                 <TextBlock ui:Translator.Key="LANGUAGE" Classes="h5"/>
@@ -94,33 +96,6 @@
                             </StackPanel>
                         </DataTemplate>
                     </ComboBox.ItemTemplate>
-                    <!--<ComboBox.ItemContainerStyle>
-                        <Style TargetType="{x:Type ComboBoxItem}">
-                            <Setter Property="Template">
-                                <Setter.Value>
-                                    <ControlTemplate TargetType="{x:Type ComboBoxItem}">
-                                        <Border Height="25" Padding="5,0" BorderThickness="0,1">
-                                            <ContentPresenter/>
-                                            <Border.Style>
-                                                <Style TargetType="{x:Type Border}">
-                                                    <Style.Triggers>
-                                                        <Trigger Property="IsMouseOver" Value="False">
-                                                            <Setter Property="Background" Value="Transparent"/>
-                                                            <Setter Property="BorderBrush" Value="Transparent"/>
-                                                        </Trigger>
-                                                        <Trigger Property="IsMouseOver" Value="True">
-                                                            <Setter Property="Background" Value="{StaticResource MainColor}"/>
-                                                            <Setter Property="BorderBrush" Value="{StaticResource AlmostLightModeAccentColor}"/>
-                                                        </Trigger>
-                                                    </Style.Triggers>
-                                                </Style>
-                                            </Border.Style>
-                                        </Border>
-                                    </ControlTemplate>
-                                </Setter.Value>
-                            </Setter>
-                        </Style>
-                    </ComboBox.ItemContainerStyle>-->
                 </ComboBox>
 
                 <TextBlock ui:Translator.Key="MISC" Classes="h5"/>
@@ -135,32 +110,32 @@
                           IsChecked="{Binding SettingsSubViewModel.General.ImagePreviewInTaskbar}"/>
 
                 <StackPanel Classes="leftOffset" Orientation="Horizontal">
-                <Label 
-                    ui:Translator.Key="RECENT_FILE_LENGTH"
-                    ui:Translator.TooltipKey="RECENT_FILE_LENGTH_TOOLTIP"/>
+                    <Label
+                        ui:Translator.Key="RECENT_FILE_LENGTH"
+                        ui:Translator.TooltipKey="RECENT_FILE_LENGTH_TOOLTIP"/>
                     <input:NumberInput Min="0" FontSize="12" HorizontalAlignment="Left"
                                    Value="{Binding SettingsSubViewModel.File.MaxOpenedRecently, Mode=TwoWay}" Width="40"/>
                 </StackPanel>
 
                 <TextBlock
                     Classes="h5"
-                    d:Content="Default new file size" 
+                    d:Content="Default new file size"
                     ui:Translator.Key="DEFAULT_NEW_SIZE"/>
 
                 <StackPanel Orientation="Horizontal"  Classes="leftOffset">
                     <Label d:Content="Width" ui:Translator.Key="WIDTH"/>
-                    <input:SizeInput 
+                    <input:SizeInput
                                  Size="{Binding SettingsSubViewModel.File.DefaultNewFileWidth, Mode=TwoWay}" MaxSize="9999" HorizontalAlignment="Left"/>
                 </StackPanel>
 
                 <StackPanel Orientation="Horizontal" Classes="leftOffset">
-                    <Label d:Content="Height" ui:Translator.Key="HEIGHT"/> 
+                    <Label d:Content="Height" ui:Translator.Key="HEIGHT"/>
                     <input:SizeInput
                                  Size="{Binding SettingsSubViewModel.File.DefaultNewFileHeight, Mode=TwoWay}" MaxSize="9999" HorizontalAlignment="Left"/>
                 </StackPanel>
 
                 <TextBlock d:Content="Tools" ui:Translator.Key="TOOLS" Classes="h5" />
-                
+
                 <StackPanel Orientation="Horizontal" Classes="leftOffset">
                     <Label Target="rightClickModeComboBox" ui:Translator.Key="RIGHT_CLICK_MODE" VerticalAlignment="Center"/>
                     <ComboBox SelectedItem="{Binding RightClickMode, Source={vm:MainVM ToolsSVM}, Mode=TwoWay}"
@@ -177,10 +152,10 @@
 
                 <TextBlock ui:Translator.Key="AUTOMATIC_UPDATES" Classes="h5"/>
 
-                <CheckBox 
-                    VerticalAlignment="Center" 
+                <CheckBox
+                    VerticalAlignment="Center"
                     IsEnabled="{Binding Path=ShowUpdateTab}"
-                    IsChecked="{Binding SettingsSubViewModel.Update.CheckUpdatesOnStartup}" 
+                    IsChecked="{Binding SettingsSubViewModel.Update.CheckUpdatesOnStartup}"
                     ui:Translator.Key="CHECK_FOR_UPDATES"
                     Classes="leftOffset"/>
 
@@ -197,7 +172,7 @@
                                VerticalAlignment="Center"
                                IsVisible="{Binding !ShowUpdateTab}"
                                ui:Translator.TooltipKey="UPDATE_CHANNEL_HELP_TOOLTIP"/>
-                               <!-- ToolTipService.InitialShowDelay="0"-->
+                        <!-- ToolTipService.InitialShowDelay="0"-->
                     </StackPanel>
                 </StackPanel>
 
@@ -220,28 +195,28 @@
                         </Binding.ConverterParameter>
                     </Binding>
                 </StackPanel.IsVisible>
-            
+
                 <controls:FixedSizeStackPanel ChildSize="32" Orientation="Vertical" VerticalChildrenAlignment="Center">
                     <TextBlock ui:Translator.Key="DISCORD_RICH_PRESENCE" Classes="h5"/>
 
-                    <CheckBox IsChecked="{Binding SettingsSubViewModel.Discord.EnableRichPresence}" 
+                    <CheckBox IsChecked="{Binding SettingsSubViewModel.Discord.EnableRichPresence}"
                               ui:Translator.Key="ENABLED"/>
-                    <CheckBox IsEnabled="{Binding SettingsSubViewModel.Discord.EnableRichPresence}" 
-                              IsChecked="{Binding SettingsSubViewModel.Discord.ShowDocumentName}" 
+                    <CheckBox IsEnabled="{Binding SettingsSubViewModel.Discord.EnableRichPresence}"
+                              IsChecked="{Binding SettingsSubViewModel.Discord.ShowDocumentName}"
                               ui:Translator.Key="SHOW_IMAGE_NAME"/>
-                    <CheckBox IsEnabled="{Binding SettingsSubViewModel.Discord.EnableRichPresence}" 
+                    <CheckBox IsEnabled="{Binding SettingsSubViewModel.Discord.EnableRichPresence}"
                               IsChecked="{Binding SettingsSubViewModel.Discord.ShowDocumentSize}"
                               ui:Translator.Key="SHOW_IMAGE_SIZE"/>
-                    <CheckBox IsEnabled="{Binding SettingsSubViewModel.Discord.EnableRichPresence}" 
+                    <CheckBox IsEnabled="{Binding SettingsSubViewModel.Discord.EnableRichPresence}"
                               IsChecked="{Binding SettingsSubViewModel.Discord.ShowLayerCount}"
                               ui:Translator.Key="SHOW_LAYER_COUNT" d:Content="Show layer count"/>
                 </controls:FixedSizeStackPanel>
-                
+
                 <settings:DiscordRichPresencePreview
                     HorizontalAlignment="Center"
                     Width="280"
-                    State="{Binding SettingsSubViewModel.Discord.StatePreview}" 
-                    Detail="{Binding SettingsSubViewModel.Discord.DetailPreview}" 
+                    State="{Binding SettingsSubViewModel.Discord.StatePreview}"
+                    Detail="{Binding SettingsSubViewModel.Discord.DetailPreview}"
                     IsPlaying="{Binding SettingsSubViewModel.Discord.EnableRichPresence}"/>
             </StackPanel>
 
@@ -279,7 +254,7 @@
                 </StackPanel>
                 <TextBox Grid.Row="1"
                          Text="{Binding SearchTerm, Mode=TwoWay}">
-                        <!--Styles="{StaticResource DarkTextBoxStyle}"-->
+                    <!--Styles="{StaticResource DarkTextBoxStyle}"-->
                     <i:Interaction.Behaviors>
                         <behaviours:GlobalShortcutFocusBehavior/>
                     </i:Interaction.Behaviors>
@@ -289,5 +264,5 @@
             </Grid>
         </StackPanel>
     </DockPanel>
-    
+
 </Window>

+ 18 - 16
src/PixiEditor.AvaloniaUI/Views/Windows/Settings/ShortcutsBinder.axaml

@@ -6,14 +6,16 @@
     xmlns:converters="clr-namespace:PixiEditor.AvaloniaUI.Helpers.Converters"
     xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
     xmlns:commands="clr-namespace:PixiEditor.AvaloniaUI.Models.Commands"
+    xmlns:commands1="clr-namespace:PixiEditor.AvaloniaUI.Models.Commands.Commands"
+    xmlns:viewModels="clr-namespace:PixiEditor.AvaloniaUI.ViewModels"
     mc:Ignorable="d"
     d:DesignHeight="600" d:DesignWidth="400"
     x:Class="PixiEditor.AvaloniaUI.Views.Windows.Settings.ShortcutsBinder">
     
     <Grid>
-    <ScrollViewer x:Name="commandScroll">
-        <!--FocusVisualStyle="{x:Null}"-->
-        <ScrollViewer.Template>
+        <ScrollViewer x:Name="commandScroll">
+            <!--FocusVisualStyle="{x:Null}"-->
+            <!--<ScrollViewer.Template>
                 <ControlTemplate TargetType="{x:Type ScrollViewer}">
                     <Grid x:Name="Grid" Background="{TemplateBinding Background}">
                         <Grid.ColumnDefinitions>
@@ -25,7 +27,7 @@
                             <RowDefinition Height="Auto"/>
                         </Grid.RowDefinitions>
                         <Rectangle x:Name="Corner" Grid.Column="1" Grid.Row="1"/>
-                        <!--Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"-->
+                       Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                         <ScrollContentPresenter
                             x:Name="PART_ScrollContentPresenter"
                             CanHorizontallyScroll="False"
@@ -35,8 +37,8 @@
                             Grid.Column="0"
                             Margin="{TemplateBinding Padding}"
                             Grid.Row="0" />
-                        <!--CanContentScroll="{TemplateBinding CanContentScroll}"-->
-                        <!--<ScrollBar
+                        CanContentScroll="{TemplateBinding CanContentScroll}"
+                        <ScrollBar
                             x:Name="PART_VerticalScrollBar"
                             AutomationProperties.AutomationId="VerticalScrollBar"
                             Cursor="Arrow"
@@ -59,32 +61,32 @@
                             Grid.Row="1"
                             Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                             Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
-                            ViewportSize="{TemplateBinding ViewportWidth}" />-->
+                            ViewportSize="{TemplateBinding ViewportWidth}" />
                     </Grid>
                 </ControlTemplate>
-            </ScrollViewer.Template>
+            </ScrollViewer.Template>-->
             <Grid>
                 <TextBlock Foreground="LightGray" HorizontalAlignment="Center" TextAlignment="Center"
                            IsVisible="{Binding !VisibleGroups, Mode=OneWay}"
                            ui:Translator.Key="NOTHING_FOUND"  d:Text="Nothing found."/>
                 <ItemsControl ItemsSource="{Binding Commands}" Foreground="White" Focusable="False">
-                    <!--<ItemsControl.ItemTemplate>
-                        <DataTemplate DataType="{x:Type commands:CommandGroup}">
-                            <StackPanel Margin="0,0,0,20" IsVisible="{Binding Visibility}">
+                    <ItemsControl.ItemTemplate>
+                        <DataTemplate DataType="{x:Type viewModels:GroupSearchResult}">
+                            <StackPanel Margin="0,0,0,20" IsVisible="{Binding IsVisible}">
                                 <TextBlock ui:Translator.Key="{Binding DisplayName.Key}" FontSize="22" FontWeight="SemiBold"/>
                                 <ItemsControl ItemsSource="{Binding Commands}" Focusable="False">
                                     <ItemsControl.ItemTemplate>
-                                        <DataTemplate DataType="{x:Type commands1:Command}">
-                                            <Grid Margin="0,5,5,0" Visibility="{Binding Visibility}">
-                                                <TextBlock Text="{Binding Command.DisplayName}" ToolTip="{Binding Command.Description}"/>
-                                                <userControls:ShortcutBox Width="120" Command="{Binding Command}" HorizontalAlignment="Right" Focusable="False"/>
+                                        <DataTemplate DataType="{x:Type viewModels:CommandSearchResult}">
+                                            <Grid Margin="0,5,5,0" IsVisible="{Binding IsVisible}">
+                                                <TextBlock Text="{Binding Command.DisplayName}" ToolTip.Tip="{Binding Command.Description}"/>
+                                                <!--<userControls:ShortcutBox Width="120" Command="{Binding Command}" HorizontalAlignment="Right" Focusable="False"/>-->
                                             </Grid>
                                         </DataTemplate>
                                     </ItemsControl.ItemTemplate>
                                 </ItemsControl>
                             </StackPanel>
                         </DataTemplate>
-                    </ItemsControl.ItemTemplate>-->
+                    </ItemsControl.ItemTemplate>
                 </ItemsControl>
             </Grid>
         </ScrollViewer>