Browse Source

Fixed deselct generating new changes

CPKreuz 4 years ago
parent
commit
ab81c88f1b

+ 2 - 7
PixiEditor/Helpers/SelectionHelpers.cs

@@ -1,18 +1,13 @@
-using PixiEditor.Models.DataHolders;
+using System.Collections.Generic;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Undo;
 using PixiEditor.Models.Undo;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 
 namespace PixiEditor.Helpers
 namespace PixiEditor.Helpers
 {
 {
     public class SelectionHelpers
     public class SelectionHelpers
     {
     {
-
         public static void UndoSelect(object[] arguments)
         public static void UndoSelect(object[] arguments)
         {
         {
             Document document = (Document)arguments[0];
             Document document = (Document)arguments[0];

+ 2 - 8
PixiEditor/Models/Tools/ToolSettings/Settings/Setting.cs

@@ -2,12 +2,10 @@
 using System.Windows.Controls;
 using System.Windows.Controls;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
 
 
+#pragma warning disable SA1402 // File may only contain a single type, Justification: "Same class with generic value"
+
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 {
 {
-    [System.Diagnostics.CodeAnalysis.SuppressMessage(
-        "StyleCop.CSharp.MaintainabilityRules",
-        "SA1402:File may only contain a single type",
-        Justification = "Same class with generic value")]
     public abstract class Setting<T, TControl> : Setting<T>
     public abstract class Setting<T, TControl> : Setting<T>
         where TControl : Control
         where TControl : Control
     {
     {
@@ -23,10 +21,6 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
         }
         }
     }
     }
 
 
-    [System.Diagnostics.CodeAnalysis.SuppressMessage(
-        "StyleCop.CSharp.MaintainabilityRules",
-        "SA1402:File may only contain a single type",
-        Justification = "Same class with generic value")]
     public abstract class Setting<T> : Setting
     public abstract class Setting<T> : Setting
     {
     {
         protected Setting(string name)
         protected Setting(string name)

+ 0 - 1
PixiEditor/NotifyableObject.cs

@@ -30,6 +30,5 @@ namespace PixiEditor.Helpers
             PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
             PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
             return true;
             return true;
         }
         }
-
     }
     }
 }
 }

+ 9 - 1
PixiEditor/ViewModels/SubViewModels/Main/SelectionViewModel.cs

@@ -32,12 +32,20 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
         }
         }
 
 
         public void Deselect(object parameter)
         public void Deselect(object parameter)
+        {
+            Deselect();
+        }
+
+        public void Deselect(bool addUndo = true)
         {
         {
             var oldSelection = new List<Coordinates>(Owner.BitmapManager.ActiveDocument.ActiveSelection.SelectedPoints);
             var oldSelection = new List<Coordinates>(Owner.BitmapManager.ActiveDocument.ActiveSelection.SelectedPoints);
 
 
             Owner.BitmapManager.ActiveDocument.ActiveSelection?.Clear();
             Owner.BitmapManager.ActiveDocument.ActiveSelection?.Clear();
 
 
-            SelectionHelpers.AddSelectionUndoStep(Owner.BitmapManager.ActiveDocument, oldSelection, SelectionType.New);
+            if (addUndo)
+            {
+                SelectionHelpers.AddSelectionUndoStep(Owner.BitmapManager.ActiveDocument, oldSelection, SelectionType.New);
+            }
         }
         }
 
 
         public bool SelectionIsNotEmpty(object property)
         public bool SelectionIsNotEmpty(object property)

+ 1 - 1
PixiEditor/ViewModels/SubViewModels/Main/UndoViewModel.cs

@@ -75,7 +75,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
         /// <param name="parameter">CommandParameter.</param>
         /// <param name="parameter">CommandParameter.</param>
         public void Undo(object parameter)
         public void Undo(object parameter)
         {
         {
-            Owner.SelectionSubViewModel.Deselect(null);
+            Owner.SelectionSubViewModel.Deselect(false);
             Owner.BitmapManager.ActiveDocument.UndoManager.Undo();
             Owner.BitmapManager.ActiveDocument.UndoManager.Undo();
         }
         }