Browse Source

Added shared toolbar setting

flabbet 3 years ago
parent
commit
d80bdcd03a

+ 18 - 22
PixiEditor/Models/Tools/ToolSettings/Toolbars/Toolbar.cs

@@ -45,19 +45,17 @@ namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
         /// </summary>
         /// </summary>
         public void SaveToolbarSettings()
         public void SaveToolbarSettings()
         {
         {
-            //TODO: Setting
-
-            //for (int i = 0; i < Settings.Count; i++)
-            //{
-            //    if (SharedSettings.Any(x => x.Name == Settings[i].Name))
-            //    {
-            //        SharedSettings.First(x => x.Name == Settings[i].Name).Value = Settings[i].Value;
-            //    }
-            //    else
-            //    {
-            //        SharedSettings.Add(Settings[i]);
-            //    }
-            //}
+            for (int i = 0; i < Settings.Count; i++)
+            {
+                if (SharedSettings.Any(x => x.Name == Settings[i].Name))
+                {
+                    SharedSettings.First(x => x.Name == Settings[i].Name).Value = Settings[i].Value;
+                }
+                else
+                {
+                    SharedSettings.Add(Settings[i]);
+                }
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -65,15 +63,13 @@ namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
         /// </summary>
         /// </summary>
         public void LoadSharedSettings()
         public void LoadSharedSettings()
         {
         {
-            //TODO: Setting
-
-            //for (int i = 0; i < SharedSettings.Count; i++)
-            //{
-            //    if (Settings.Any(x => x.Name == SharedSettings[i].Name))
-            //    {
-            //        Settings.First(x => x.Name == SharedSettings[i].Name).Value = SharedSettings[i].Value;
-            //    }
-            //}
+            for (int i = 0; i < SharedSettings.Count; i++)
+            {
+                if (Settings.Any(x => x.Name == SharedSettings[i].Name))
+                {
+                    Settings.First(x => x.Name == SharedSettings[i].Name).Value = SharedSettings[i].Value;
+                }
+            }
         }
         }
     }
     }
 }
 }

+ 5 - 1
PixiEditor/ViewModels/SubViewModels/Main/ToolsViewModel.cs

@@ -5,6 +5,7 @@ using PixiEditor.Models.Events;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.Tools.ToolSettings.Settings;
 using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.Models.UserPreferences;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -104,7 +105,10 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
 
             ActiveTool = tool;
             ActiveTool = tool;
 
 
-            ActiveTool.Toolbar.LoadSharedSettings();
+            if (IPreferences.Current.GetPreference<bool>("EnableSharedToolbar"))
+            {
+                ActiveTool.Toolbar.LoadSharedSettings();
+            }
 
 
             if (LastActionTool != ActiveTool)
             if (LastActionTool != ActiveTool)
                 SelectedToolChanged?.Invoke(this, new SelectedToolEventArgs(LastActionTool, ActiveTool));
                 SelectedToolChanged?.Invoke(this, new SelectedToolEventArgs(LastActionTool, ActiveTool));

+ 23 - 0
PixiEditor/ViewModels/SubViewModels/UserPreferences/Settings/ToolsSettings.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PixiEditor.ViewModels.SubViewModels.UserPreferences.Settings
+{
+    public class ToolsSettings : SettingsGroup
+    {
+        private bool enableSharedToolbar = GetPreference(nameof(EnableSharedToolbar), false);
+
+        public bool EnableSharedToolbar
+        {
+            get => enableSharedToolbar;
+            set
+            {
+                enableSharedToolbar = value;
+                RaiseAndUpdatePreference(nameof(EnableSharedToolbar), value);
+            }
+        }
+    }
+}

+ 2 - 0
PixiEditor/ViewModels/SubViewModels/UserPreferences/SettingsViewModel.cs

@@ -6,6 +6,8 @@ namespace PixiEditor.ViewModels.SubViewModels.UserPreferences
     {
     {
         public GeneralSettings General { get; set; } = new GeneralSettings();
         public GeneralSettings General { get; set; } = new GeneralSettings();
 
 
+        public ToolsSettings Tools { get; set; } = new ToolsSettings();
+
         public FileSettings File { get; set; } = new FileSettings();
         public FileSettings File { get; set; } = new FileSettings();
 
 
         public UpdateSettings Update { get; set; } = new UpdateSettings();
         public UpdateSettings Update { get; set; } = new UpdateSettings();

+ 10 - 3
PixiEditor/Views/Dialogs/SettingsWindow.xaml

@@ -76,6 +76,8 @@
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
+                    <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
+                    <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                 </Grid.RowDefinitions>
                 </Grid.RowDefinitions>
 
 
                 <Label Grid.Row="0" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Misc</Label>
                 <Label Grid.Row="0" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Misc</Label>
@@ -106,13 +108,18 @@
                                  Size="{Binding SettingsSubViewModel.File.DefaultNewFileHeight, Mode=TwoWay}" 
                                  Size="{Binding SettingsSubViewModel.File.DefaultNewFileHeight, Mode=TwoWay}" 
                                  Width="70" Height="21" MaxSize="9999" HorizontalAlignment="Left"/>
                                  Width="70" Height="21" MaxSize="9999" HorizontalAlignment="Left"/>
 
 
-                <Label Grid.Row="7" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Automatic updates</Label>
+                <Label Grid.Row="7" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Tools</Label>
 
 
                 <CheckBox Grid.Row="8" Grid.Column="1" VerticalAlignment="Center"
                 <CheckBox Grid.Row="8" Grid.Column="1" VerticalAlignment="Center"
+                    IsChecked="{Binding SettingsSubViewModel.Tools.EnableSharedToolbar}">Enable shared toolbar</CheckBox>
+                
+                <Label Grid.Row="9" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Automatic updates</Label>
+
+                <CheckBox Grid.Row="10" Grid.Column="1" VerticalAlignment="Center"
                     IsChecked="{Binding SettingsSubViewModel.Update.CheckUpdatesOnStartup}">Check updates on startup</CheckBox>
                     IsChecked="{Binding SettingsSubViewModel.Update.CheckUpdatesOnStartup}">Check updates on startup</CheckBox>
 
 
-                <Label Grid.Row="9" Grid.Column="1" Style="{StaticResource SettingsText}">Update stream</Label>
-                <ComboBox Grid.Row="9" Grid.Column="2" VerticalAlignment="Center"
+                <Label Grid.Row="11" Grid.Column="1" Style="{StaticResource SettingsText}">Update stream</Label>
+                <ComboBox Grid.Row="11" Grid.Column="2" VerticalAlignment="Center"
                     Width="110" Height="22" HorizontalAlignment="Left"
                     Width="110" Height="22" HorizontalAlignment="Left"
                     ItemsSource="{Binding SettingsSubViewModel.Update.UpdateChannels}"
                     ItemsSource="{Binding SettingsSubViewModel.Update.UpdateChannels}"
                     SelectedValue="{Binding SettingsSubViewModel.Update.UpdateChannelName}"/>
                     SelectedValue="{Binding SettingsSubViewModel.Update.UpdateChannelName}"/>