Browse Source

Introduced the Setting<T>

ArtemK123 4 years ago
parent
commit
33c7096b45

+ 1 - 0
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -13,6 +13,7 @@ using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools.ToolSettings;
 using PixiEditor.Models.Tools.ToolSettings;
+using PixiEditor.Models.Tools.ToolSettings.Settings;
 
 
 namespace PixiEditor.Models.Controllers
 namespace PixiEditor.Models.Controllers
 {
 {

+ 17 - 6
PixiEditor/Models/Tools/ToolSettings/Settings/Setting.cs

@@ -1,15 +1,17 @@
 using System.Windows.Controls;
 using System.Windows.Controls;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
 
 
-namespace PixiEditor.Models.Tools.ToolSettings
+namespace PixiEditor.Models.Tools.ToolSettings.Settings
 {
 {
-    public abstract class Setting : NotifyableObject
+    public abstract class Setting<T> : NotifyableObject
     {
     {
-        public string Name { get; protected set; }
+        public string Name { get; }
+
         public string Label { get; set; }
         public string Label { get; set; }
+
         public bool HasLabel => !string.IsNullOrEmpty(Label);
         public bool HasLabel => !string.IsNullOrEmpty(Label);
 
 
-        public object Value
+        public T Value
         {
         {
             get => value;
             get => value;
             set
             set
@@ -20,11 +22,20 @@ namespace PixiEditor.Models.Tools.ToolSettings
         }
         }
 
 
         public Control SettingControl { get; set; }
         public Control SettingControl { get; set; }
-        private object value;
 
 
-        public Setting(string name)
+        private T value;
+
+        protected Setting(string name)
         {
         {
             Name = name;
             Name = name;
         }
         }
     }
     }
+
+    public abstract class Setting : Setting<object>
+    {
+        protected Setting(string name)
+            : base(name)
+        {
+        }
+    }
 }
 }

+ 1 - 0
PixiEditor/Models/Tools/ToolSettings/Toolbars/Toolbar.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Collections.ObjectModel;
 using System.Linq;
 using System.Linq;
+using PixiEditor.Models.Tools.ToolSettings.Settings;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
 namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
 {
 {

+ 1 - 0
PixiEditorTests/ModelsTests/ToolsTests/ToolbarTests/ToolbarBaseTests.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 using PixiEditor.Models.Tools.ToolSettings;
 using PixiEditor.Models.Tools.ToolSettings;
+using PixiEditor.Models.Tools.ToolSettings.Settings;
 using PixiEditor.Models.Tools.ToolSettings.Toolbars;
 using PixiEditor.Models.Tools.ToolSettings.Toolbars;
 using Xunit;
 using Xunit;