瀏覽代碼

Final touches

Krzysztof Krysiński 2 年之前
父節點
當前提交
7fd12fbd70

+ 1 - 1
src/PixiEditor/Styles/PixiListBoxItemStyle.xaml

@@ -10,7 +10,7 @@
             <Setter.Value>
                 <ControlTemplate TargetType="ListBoxItem">
                     <Border x:Name="Border" Padding="15,7" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}">
-                        <ContentPresenter Content="{TemplateBinding Content}"/>
+                        <ContentPresenter/>
                     </Border>
                     <ControlTemplate.Triggers>
                         <Trigger Property="IsMouseOver" Value="True">

+ 44 - 0
src/PixiEditor/ViewModels/SettingsWindowViewModel.cs

@@ -15,6 +15,26 @@ using PixiEditor.Views.Dialogs;
 
 namespace PixiEditor.ViewModels;
 
+internal class SettingsPage : NotifyableObject
+{
+    private LocalizedString name;
+
+    public LocalizedString Name
+    {
+        get => name;
+        set => SetProperty(ref name, value);
+    }
+
+    public SettingsPage(string nameKey)
+    {
+        Name = new LocalizedString(nameKey);
+    }
+
+    public void UpdateName()
+    {
+        Name = new LocalizedString(Name.Key);
+    }
+}
 internal class SettingsWindowViewModel : ViewModelBase
 {
     private string searchTerm;
@@ -62,6 +82,7 @@ internal class SettingsWindowViewModel : ViewModelBase
     public SettingsViewModel SettingsSubViewModel { get; set; }
 
     public List<GroupSearchResult> Commands { get; }
+    public ObservableCollection<SettingsPage> Pages { get; }
 
     private static List<ICustomShortcutFormat> _customShortcutFormats;
 
@@ -189,6 +210,14 @@ internal class SettingsWindowViewModel : ViewModelBase
 
     public SettingsWindowViewModel()
     {
+        Pages = new ObservableCollection<SettingsPage>
+        {
+            new SettingsPage("GENERAL"),
+            new SettingsPage("DISCORD"),
+            new SettingsPage("KEY_BINDINGS"),
+        };
+
+        ILocalizationProvider.Current.OnLanguageChanged += OnLanguageChanged;
         Commands = new(CommandController.Current.CommandGroups.Select(x => new GroupSearchResult(x)));
         UpdateSearchResults();
         SettingsSubViewModel = new SettingsViewModel(this);
@@ -196,6 +225,21 @@ internal class SettingsWindowViewModel : ViewModelBase
         VisibleGroups = Commands.Count(x => x.Visibility == Visibility.Visible);
     }
 
+    private void UpdatePages()
+    {
+        foreach (var page in Pages)
+        {
+            page.UpdateName();
+        }
+
+        RaisePropertyChanged(nameof(Pages));
+    }
+
+    private void OnLanguageChanged(Language obj)
+    {
+        UpdatePages();
+    }
+
     public void UpdateSearchResults()
     {
         if (string.IsNullOrWhiteSpace(searchTerm))

+ 3 - 1
src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/EnumSetting.cs

@@ -4,6 +4,7 @@ using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.Localization;
+using PixiEditor.Views;
 
 namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
@@ -94,10 +95,11 @@ internal sealed class EnumSetting<TEnum> : Setting<TEnum, ComboBox>
         {
             var item = new ComboBoxItem
             {
-                Content = new LocalizedString(value.GetDescription().ToUpper()),
                 Tag = value
             };
 
+            Translator.SetKey(item, value.GetDescription().ToUpper());
+
             comboBox.Items.Add(item);
         }
     }

+ 2 - 3
src/PixiEditor/Views/Dialogs/ResizeCanvasPopup.xaml

@@ -35,13 +35,12 @@
         <dial:DialogTitleBar DockPanel.Dock="Top"
             TitleText="RESIZE_CANVAS" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}" />
 
-        <Button DockPanel.Dock="Bottom" Width="70" HorizontalAlignment="Center" Margin="15"
+        <Button DockPanel.Dock="Bottom" Padding="5 0" HorizontalAlignment="Center" Margin="15"
                 Style="{StaticResource DarkRoundButton}" local:Translator.Key="RESIZE" Click="Button_Click" IsDefault="True" />
 
         <Border HorizontalAlignment="Center" Margin="0,30,0,0" Background="{StaticResource MainColor}"
                  VerticalAlignment="Top" Grid.Row="1" Width="250" Height="290" CornerRadius="10">
-            <StackPanel
-                >
+            <StackPanel>
                 <userControls:SizePicker Margin="0,8,0,0" 
                                   Width="240"
                                   Height="170"

+ 1 - 1
src/PixiEditor/Views/Dialogs/ResizeDocumentPopup.xaml

@@ -33,7 +33,7 @@
         <dial:DialogTitleBar DockPanel.Dock="Top"
             TitleText="RESIZE_IMAGE" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}"/>
 
-        <Button DockPanel.Dock="Bottom" Width="70" HorizontalAlignment="Center" Margin="15"
+        <Button DockPanel.Dock="Bottom" Padding="5 0" HorizontalAlignment="Center" Margin="15"
                 Style="{StaticResource DarkRoundButton}" local:Translator.Key="RESIZE" Click="Button_Click" IsDefault="True" />
 
         <userControls:SizePicker HorizontalAlignment="Center" Width="240" Height="180" Margin="0,30,0,0"

+ 1 - 1
src/PixiEditor/Views/Dialogs/SettingGroups/ShortcutsBinder.xaml

@@ -38,7 +38,7 @@
                             <ItemsControl.ItemTemplate>
                                 <DataTemplate DataType="{x:Type commands:CommandGroup}">
                                     <StackPanel Margin="0,0,0,20" Visibility="{Binding Visibility}">
-                                        <TextBlock Text="{Binding DisplayName}" FontSize="22" FontWeight="SemiBold"/>
+                                        <TextBlock views:Translator.Key="{Binding DisplayName.Key}" FontSize="22" FontWeight="SemiBold"/>
                                         <ItemsControl ItemsSource="{Binding Commands}" Focusable="False">
                                             <ItemsControl.ItemTemplate>
                                                 <DataTemplate DataType="{x:Type commands1:Command}">

+ 2 - 9
src/PixiEditor/Views/Dialogs/SettingsWindow.xaml

@@ -48,21 +48,14 @@
         <dial:DialogTitleBar DockPanel.Dock="Top"
             TitleText="SETTINGS" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}"/>
 
-        <ListBox DockPanel.Dock="Left" x:Name="pages" 
+        <ListBox DockPanel.Dock="Left" x:Name="pages" ItemsSource="{Binding Pages}"
                  Background="Transparent" BorderThickness="0" Width="150" ItemContainerStyle="{StaticResource PixiListBoxItemStyle}"
                  SelectedIndex="{Binding CurrentPage}">
             <ListBox.ItemTemplate>
                 <DataTemplate>
-                    <TextBlock Margin="10 5 10 5" FontSize="15" Foreground="White" Text="{Binding Path=Value}"/>
+                    <TextBlock Margin="10 5 10 5" FontSize="15" Foreground="White" Text="{Binding Path=Name.Value}"/>
                 </DataTemplate>
             </ListBox.ItemTemplate>
-            <ListBox.ItemsSource>
-                <x:Array Type="{x:Type localization:LocalizedString}">
-                    <localization:LocalizedString Key="GENERAL"/>
-                    <localization:LocalizedString Key="DISCORD"/>
-                    <localization:LocalizedString Key="KEY_BINDINGS"/>
-                </x:Array>
-            </ListBox.ItemsSource>
         </ListBox>
         <StackPanel Orientation="Vertical" Background="{StaticResource AccentColor}">
             <StackPanel Orientation="Vertical" Margin="15,10" Tag="27">

+ 4 - 3
src/PixiEditor/Views/MainWindow.xaml

@@ -505,8 +505,9 @@
                 </ToggleButton>
                 <Grid Margin="5,5,10,5" Background="{StaticResource BrighterAccentColor}" Width="5"/>
                 <Label Style="{StaticResource BaseLabel}" FontSize="12"
-                   VerticalAlignment="Center" Content="{Binding ToolsSubViewModel.ActiveTool.DisplayName}"
-                   ToolTip="{Binding ToolsSubViewModel.ActiveTool.ActionDisplay}"/>
+                   VerticalAlignment="Center" views:Translator.Key="{Binding ToolsSubViewModel.ActiveTool.DisplayName.Key}"
+                   views:Translator.TooltipLocalizedString="{Binding ToolsSubViewModel.ActiveTool.ActionDisplay}"
+                   />
                 <ItemsControl ItemsSource="{Binding ToolsSubViewModel.ActiveTool.Toolbar.Settings}">
                     <ItemsControl.ItemsPanel>
                         <ItemsPanelTemplate>
@@ -518,7 +519,7 @@
                             <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,10,0">
                                 <Label
                                 Visibility="{Binding HasLabel, Converter={StaticResource BoolToVisibilityConverter}}"
-                                Foreground="White" Content="{Binding Label}" />
+                                Foreground="White" views:Translator.Key="{Binding Label.Key}" />
                                 <ContentControl Content="{Binding SettingControl}" />
                             </StackPanel>
                         </DataTemplate>