Equbuxu 3 vuotta sitten
vanhempi
commit
43f4b8f56e
52 muutettua tiedostoa jossa 304 lisäystä ja 609 poistoa
  1. 15 15
      src/PixiEditor/Helpers/Extensions/ServiceCollectionHelpers.cs
  2. 2 2
      src/PixiEditor/Helpers/Extensions/ToolbarHelpers.cs
  3. 3 3
      src/PixiEditor/Models/Commands/CommandController.cs
  4. 0 14
      src/PixiEditor/Models/Controllers/ICanvasInputTarget.cs
  5. 0 13
      src/PixiEditor/Models/Controllers/MouseMovementEventArgs.cs
  6. 2 2
      src/PixiEditor/Models/Controllers/ShortcutController.cs
  7. 0 118
      src/PixiEditor/Models/Controllers/ToolSession.cs
  8. 18 22
      src/PixiEditor/Models/DocumentModels/ChangeExecutionController.cs
  9. 4 4
      src/PixiEditor/Models/Events/SelectedToolEventArgs.cs
  10. 0 20
      src/PixiEditor/Models/Tools/BitmapOperationTool.cs
  11. 0 8
      src/PixiEditor/Models/Tools/ReadonlyTool.cs
  12. 0 13
      src/PixiEditor/Models/Tools/ShapeTool.cs
  13. 0 5
      src/PixiEditor/Models/Tools/ToolSettings/Toolbars/EmptyToolbar.cs
  14. 0 29
      src/PixiEditor/Models/Tools/Tools/PenTool.cs
  15. 0 35
      src/PixiEditor/Models/Tools/Tools/SelectTool.cs
  16. 24 20
      src/PixiEditor/ViewModels/SubViewModels/Document/DocumentManagerViewModel.cs
  17. 7 38
      src/PixiEditor/ViewModels/SubViewModels/Main/IoViewModel.cs
  18. 5 5
      src/PixiEditor/ViewModels/SubViewModels/Main/StylusViewModel.cs
  19. 51 27
      src/PixiEditor/ViewModels/SubViewModels/Main/ToolsViewModel.cs
  20. 13 0
      src/PixiEditor/ViewModels/SubViewModels/Tools/ShapeTool.cs
  21. 8 29
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tool.cs
  22. 1 1
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/SettingValueChangedEventArgs.cs
  23. 3 3
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/BoolSetting.cs
  24. 6 7
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/ColorSetting.cs
  25. 5 5
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/DropdownSetting.cs
  26. 8 8
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/EnumSetting.cs
  27. 3 4
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/FloatSetting.cs
  28. 1 2
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/Setting.cs
  29. 3 4
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/SizeSetting.cs
  30. 2 2
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/BasicShapeToolbar.cs
  31. 2 2
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/BasicToolbar.cs
  32. 2 2
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/BrightnessToolToolbar.cs
  33. 5 0
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/EmptyToolbar.cs
  34. 2 2
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/MagicWandToolbar.cs
  35. 2 2
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/PenToolbar.cs
  36. 2 2
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/SelectToolToolbar.cs
  37. 5 5
      src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/Toolbar.cs
  38. 5 11
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/BrightnessToolViewModel.cs
  39. 3 9
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/CircleToolViewModel.cs
  40. 3 12
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/ColorPickerToolViewModel.cs
  41. 17 23
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/EraserToolViewModel.cs
  42. 3 9
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/FloodFillToolViewModel.cs
  43. 4 10
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/LineToolViewModel.cs
  44. 4 11
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/MagicWandToolViewModel.cs
  45. 3 9
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/MoveToolViewModel.cs
  46. 3 10
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/MoveViewportToolViewModel.cs
  47. 19 0
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/PenToolViewModel.cs
  48. 3 8
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/RectangleToolViewModel.cs
  49. 20 0
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/SelectToolViewModel.cs
  50. 6 17
      src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/ZoomToolViewModel.cs
  51. 4 4
      src/PixiEditor/ViewModels/ViewModelMain.cs
  52. 3 3
      src/PixiEditor/Views/MainWindow.xaml

+ 15 - 15
src/PixiEditor/Helpers/Extensions/ServiceCollectionHelpers.cs

@@ -5,12 +5,12 @@ using PixiEditor.Models.DataProviders;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.IO.ClsFile;
 using PixiEditor.Models.IO.JascPalFile;
-using PixiEditor.Models.Tools;
-using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.UserPreferences;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels.SubViewModels.Document;
 using PixiEditor.ViewModels.SubViewModels.Main;
+using PixiEditor.ViewModels.SubViewModels.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 namespace PixiEditor.Helpers.Extensions;
 
@@ -44,19 +44,19 @@ internal static class ServiceCollectionHelpers
         .AddSingleton<CommandController>()
         .AddSingleton<DocumentManagerViewModel>()
         // Tools
-        .AddSingleton<Tool, MoveViewportTool>()
-        .AddSingleton<Tool, MoveTool>()
-        .AddSingleton<Tool, PenTool>()
-        .AddSingleton<Tool, SelectTool>()
-        .AddSingleton<Tool, MagicWandTool>()
-        .AddSingleton<Tool, FloodFillTool>()
-        .AddSingleton<Tool, LineTool>()
-        .AddSingleton<Tool, CircleTool>()
-        .AddSingleton<Tool, RectangleTool>()
-        .AddSingleton<Tool, EraserTool>()
-        .AddSingleton<Tool, ColorPickerTool>()
-        .AddSingleton<Tool, BrightnessTool>()
-        .AddSingleton<Tool, ZoomTool>()
+        .AddSingleton<ToolViewModel, MoveViewportToolViewModel>()
+        .AddSingleton<ToolViewModel, MoveToolViewModel>()
+        .AddSingleton<ToolViewModel, PenToolViewModel>()
+        .AddSingleton<ToolViewModel, SelectToolViewModel>()
+        .AddSingleton<ToolViewModel, MagicWandToolViewModel>()
+        .AddSingleton<ToolViewModel, FloodFillToolViewModel>()
+        .AddSingleton<ToolViewModel, LineToolViewModel>()
+        .AddSingleton<ToolViewModel, CircleToolViewModel>()
+        .AddSingleton<ToolViewModel, RectangleToolViewModel>()
+        .AddSingleton<ToolViewModel, EraserToolViewModel>()
+        .AddSingleton<ToolViewModel, ColorPickerToolViewModel>()
+        .AddSingleton<ToolViewModel, BrightnessToolViewModel>()
+        .AddSingleton<ToolViewModel, ZoomToolViewModel>()
         // Palette Parsers
         .AddSingleton<PaletteFileParser, JascFileParser>()
         .AddSingleton<PaletteFileParser, ClsFileParser>()

+ 2 - 2
src/PixiEditor/Helpers/Extensions/ToolbarHelpers.cs

@@ -1,5 +1,5 @@
-using PixiEditor.Models.Tools.ToolSettings.Settings;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 namespace PixiEditor.Helpers.Extensions;
 

+ 3 - 3
src/PixiEditor/Models/Commands/CommandController.cs

@@ -7,7 +7,7 @@ using PixiEditor.Models.Commands.Attributes.Evaluators;
 using PixiEditor.Models.Commands.Commands;
 using PixiEditor.Models.Commands.Evaluators;
 using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools;
 using CommandAttribute = PixiEditor.Models.Commands.Attributes.Commands.Command;
 
 namespace PixiEditor.Models.Commands;
@@ -164,14 +164,14 @@ internal class CommandController
         // Find tool commands
         foreach (var type in allTypesInPixiEditorAssembly)
         {
-            if (!type.IsAssignableTo(typeof(Tool)))
+            if (!type.IsAssignableTo(typeof(ToolViewModel)))
                 continue;
 
             var toolAttr = type.GetCustomAttribute<CommandAttribute.ToolAttribute>();
             if (toolAttr is null)
                 continue;
 
-            Tool toolInstance = serviceProvider.GetServices<Tool>().First(x => x.GetType() == type);
+            ToolViewModel toolInstance = serviceProvider.GetServices<ToolViewModel>().First(x => x.GetType() == type);
             string internalName = $"PixiEditor.Tools.Select.{type.Name}";
 
             var command = new Command.ToolCommand()

+ 0 - 14
src/PixiEditor/Models/Controllers/ICanvasInputTarget.cs

@@ -1,14 +0,0 @@
-using System.Windows.Input;
-using PixiEditor.Models.Tools;
-
-namespace PixiEditor.Models.Controllers;
-
-internal interface ICanvasInputTarget
-{
-    void OnToolChange(Tool tool);
-    void OnKeyDown(Key key);
-    void OnKeyUp(Key key);
-    void OnLeftMouseButtonDown(double canvasPosX, double canvasPosY);
-    void OnLeftMouseButtonUp();
-    void OnMouseMove(double newCanvasX, double newCanvasY);
-}

+ 0 - 13
src/PixiEditor/Models/Controllers/MouseMovementEventArgs.cs

@@ -1,13 +0,0 @@
-using ChunkyImageLib.DataHolders;
-
-namespace PixiEditor.Models.Controllers;
-
-internal class MouseMovementEventArgs : EventArgs
-{
-    public MouseMovementEventArgs(VecI mousePosition)
-    {
-        NewPosition = mousePosition;
-    }
-
-    public VecI NewPosition { get; set; }
-}

+ 2 - 2
src/PixiEditor/Models/Controllers/ShortcutController.cs

@@ -2,7 +2,7 @@
 using PixiEditor.Models.Commands;
 using PixiEditor.Models.Commands.Commands;
 using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools;
 
 namespace PixiEditor.Models.Controllers;
 
@@ -14,7 +14,7 @@ internal class ShortcutController
 
     public IEnumerable<Command> LastCommands { get; private set; }
 
-    public Dictionary<KeyCombination, Tool> TransientShortcuts { get; set; } = new();
+    public Dictionary<KeyCombination, ToolViewModel> TransientShortcuts { get; set; } = new();
 
     public static void BlockShortcutExection(string blocker)
     {

+ 0 - 118
src/PixiEditor/Models/Controllers/ToolSession.cs

@@ -1,118 +0,0 @@
-using System.Windows.Input;
-using ChunkyImageLib.DataHolders;
-using PixiEditor.Models.Tools;
-using SkiaSharp;
-
-namespace PixiEditor.Models.Controllers;
-
-internal class ToolSession
-{
-    private List<VecI> mouseMovement = new();
-    private bool ended = false;
-
-    public IReadOnlyList<VecI> MouseMovement => mouseMovement;
-    public Tool Tool { get; }
-
-    public bool IsCtrlDown { get; private set; }
-    public bool IsShiftDown { get; private set; }
-    public bool IsAltDown { get; private set; }
-
-    private int _smallestX = int.MaxValue;
-    private int _smallestY = int.MaxValue;
-    private int _biggestX = int.MinValue;
-    private int _biggestY = int.MinValue;
-
-    public ToolSession(
-        Tool tool,
-        double mouseXOnCanvas,
-        double mouseYOnCanvas,
-        IReadOnlyDictionary<Key, KeyStates> keyboardStates)
-    {
-        if (tool == null)
-            throw new ArgumentNullException(nameof(tool));
-        Tool = tool;
-
-        Tool.Session = this;
-        InvokeKeyboardEvents(keyboardStates);
-        int x = (int)Math.Floor(mouseXOnCanvas);
-        int y = (int)Math.Floor(mouseYOnCanvas);
-        mouseMovement.Add(new(x, y));
-
-        UpdateMinMax(x, y);
-
-        Tool.BeforeUse();
-    }
-
-    private void InvokeKeyboardEvents(IReadOnlyDictionary<Key, KeyStates> keyboardStates)
-    {
-        foreach (var pair in keyboardStates)
-        {
-            if (pair.Value == KeyStates.None)
-                OnKeyUp(pair.Key);
-            else if (pair.Value == KeyStates.Down)
-                OnKeyDown(pair.Key);
-        }
-    }
-
-    public void EndSession(IReadOnlyDictionary<Key, KeyStates> keyboardStates)
-    {
-        if (ended)
-            throw new Exception("Session has ended already");
-        ended = true;
-
-        Tool.AfterUse(SKRectI.Create(
-            _smallestX,
-            _smallestY,
-            _biggestX - _smallestX + 1,
-            _biggestY - _smallestY + 1));
-        InvokeReleaseKeyboardEvents(keyboardStates);
-        Tool.Session = null;
-    }
-
-    private void InvokeReleaseKeyboardEvents(IReadOnlyDictionary<Key, KeyStates> keyboardStates)
-    {
-        foreach (var pair in keyboardStates)
-        {
-            if (pair.Value == KeyStates.Down)
-                OnKeyUp(pair.Key);
-        }
-    }
-
-    public void OnKeyDown(Key key)
-    {
-        if (key == Key.LeftCtrl)
-            IsCtrlDown = true;
-        else if (key == Key.LeftShift)
-            IsShiftDown = true;
-        else if (key == Key.LeftAlt)
-            IsAltDown = true;
-
-        Tool.OnKeyDown(key);
-    }
-
-    public void OnKeyUp(Key key)
-    {
-        if (key == Key.LeftCtrl)
-            IsCtrlDown = false;
-        else if (key == Key.LeftShift)
-            IsShiftDown = false;
-        else if (key == Key.LeftAlt)
-            IsAltDown = false;
-
-        Tool.OnKeyUp(key);
-    }
-
-    public void OnPixelPositionChange(VecI pos)
-    {
-        UpdateMinMax(pos.X, pos.Y);
-        mouseMovement.Add(pos);
-    }
-
-    private void UpdateMinMax(int x, int y)
-    {
-        _smallestX = Math.Min(_smallestX, x);
-        _smallestY = Math.Min(_smallestY, y);
-        _biggestX = Math.Max(_biggestX, x);
-        _biggestY = Math.Max(_biggestY, y);
-    }
-}

+ 18 - 22
src/PixiEditor/Models/Controllers/ToolSessionController.cs → src/PixiEditor/Models/DocumentModels/ChangeExecutionController.cs

@@ -1,17 +1,13 @@
 using System.Windows.Input;
 using ChunkyImageLib.DataHolders;
-using PixiEditor.Models.Tools;
 
-namespace PixiEditor.Models.Controllers;
-
-internal class ToolSessionController : ICanvasInputTarget
+namespace PixiEditor.Models.DocumentModels;
+#nullable enable
+internal class ChangeExecutionController
 {
-    public event EventHandler<MouseMovementEventArgs> PixelMousePositionChanged;
-    public event EventHandler<(double, double)> PreciseMousePositionChanged;
-    public event EventHandler<(Key, KeyStates)> KeyStateChanged;
-
-    public event EventHandler<ToolSession> SessionStarted;
-    public event EventHandler<ToolSession> SessionEnded;
+    public event EventHandler<VecI>? PixelMousePositionChanged;
+    public event EventHandler<(double, double)>? PreciseMousePositionChanged;
+    public event EventHandler<(Key, KeyStates)>? KeyStateChanged;
 
     public MouseButtonState LeftMouseState { get; private set; }
 
@@ -25,12 +21,12 @@ internal class ToolSessionController : ICanvasInputTarget
     private int lastPixelY;
 
     private Dictionary<Key, KeyStates> keyboardState = new();
-    private Tool currentTool = null;
-    private ToolSession currentSession = null;
-
-    private void TryStartToolSession(Tool tool, double mouseXOnCanvas, double mouseYOnCanvas)
+    //private ToolViewModel? currentTool = null;
+    //private UpdateableChangeSession? currentSession = null;
+    /*
+    private void TryStartToolSession(ToolViewModel tool, double mouseXOnCanvas, double mouseYOnCanvas)
     {
-        if (currentSession != null)
+        if (currentSession is not null)
             return;
         currentSession = new(tool, mouseXOnCanvas, mouseYOnCanvas, keyboardState);
         SessionStarted?.Invoke(this, currentSession);
@@ -38,7 +34,7 @@ internal class ToolSessionController : ICanvasInputTarget
 
     private void TryStopToolSession()
     {
-        if (currentSession == null)
+        if (currentSession is null)
             return;
         currentSession.EndSession(keyboardState);
         SessionEnded?.Invoke(this, currentSession);
@@ -82,8 +78,8 @@ internal class ToolSessionController : ICanvasInputTarget
     }
 
     public void ForceStopActiveSessionIfAny() => TryStopToolSession();
-
-    public void OnToolChange(Tool tool)
+    
+    public void OnToolChange(ToolViewModel tool)
     {
         currentTool = tool;
         TryStopToolSession();
@@ -93,9 +89,9 @@ internal class ToolSessionController : ICanvasInputTarget
     {
         //update internal state
 
-        int newX = (int)Math.Floor(newCanvasX);
-        int newY = (int)Math.Floor(newCanvasY);
-        bool pixelPosChanged = false;
+        var newX = (int)Math.Floor(newCanvasX);
+        var newY = (int)Math.Floor(newCanvasY);
+        var pixelPosChanged = false;
         if (lastPixelX != newX || lastPixelY != newY)
         {
             lastPixelX = newX;
@@ -133,5 +129,5 @@ internal class ToolSessionController : ICanvasInputTarget
 
         //call session events
         TryStopToolSession();
-    }
+    }*/
 }

+ 4 - 4
src/PixiEditor/Models/Events/SelectedToolEventArgs.cs

@@ -1,16 +1,16 @@
-using PixiEditor.Models.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools;
 
 namespace PixiEditor.Models.Events;
 
 internal class SelectedToolEventArgs
 {
-    public SelectedToolEventArgs(Tool oldTool, Tool newTool)
+    public SelectedToolEventArgs(ToolViewModel oldTool, ToolViewModel newTool)
     {
         OldTool = oldTool;
         NewTool = newTool;
     }
 
-    public Tool OldTool { get; set; }
+    public ToolViewModel OldTool { get; set; }
 
-    public Tool NewTool { get; set; }
+    public ToolViewModel NewTool { get; set; }
 }

+ 0 - 20
src/PixiEditor/Models/Tools/BitmapOperationTool.cs

@@ -1,20 +0,0 @@
-using SkiaSharp;
-
-namespace PixiEditor.Models.Tools;
-
-internal abstract class BitmapOperationTool : Tool
-{
-    public abstract void Use();
-
-    public override void BeforeUse()
-    {
-    }
-
-    /// <summary>
-    /// Executes undo adding procedure.
-    /// </summary>
-    /// <remarks>When overriding, set UseDefaultUndoMethod to false.</remarks>
-    public override void AfterUse(SKRectI sessionRect)
-    {
-    }
-}

+ 0 - 8
src/PixiEditor/Models/Tools/ReadonlyTool.cs

@@ -1,8 +0,0 @@
-using ChunkyImageLib.DataHolders;
-
-namespace PixiEditor.Models.Tools;
-
-internal abstract class ReadonlyTool : Tool
-{
-    public abstract void Use(VecD position);
-}

+ 0 - 13
src/PixiEditor/Models/Tools/ShapeTool.cs

@@ -1,13 +0,0 @@
-using System.Windows.Input;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
-
-namespace PixiEditor.Models.Tools;
-
-internal abstract class ShapeTool : BitmapOperationTool
-{
-    public ShapeTool()
-    {
-        Cursor = Cursors.Cross;
-        Toolbar = new BasicShapeToolbar();
-    }
-}

+ 0 - 5
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/EmptyToolbar.cs

@@ -1,5 +0,0 @@
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
-
-internal class EmptyToolbar : Toolbar
-{
-}

+ 0 - 29
src/PixiEditor/Models/Tools/Tools/PenTool.cs

@@ -1,29 +0,0 @@
-using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
-using PixiEditor.Models.Commands.Attributes.Commands;
-using PixiEditor.Models.Tools.ToolSettings.Settings;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
-
-namespace PixiEditor.Models.Tools.Tools;
-
-[Command.Tool(Key = Key.B)]
-internal class PenTool : ShapeTool
-{
-    private readonly SizeSetting toolSizeSetting;
-    private readonly BoolSetting pixelPerfectSetting;
-
-    public PenTool()
-    {
-        Cursor = Cursors.Pen;
-        ActionDisplay = "Click and move to draw.";
-        Toolbar = new PenToolbar();
-        toolSizeSetting = Toolbar.GetSetting<SizeSetting>("ToolSize");
-        pixelPerfectSetting = Toolbar.GetSetting<BoolSetting>("PixelPerfectEnabled");
-    }
-
-    public override string Tooltip => $"Standard brush. ({Shortcut})";
-
-    public override void Use()
-    {
-    }
-}

+ 0 - 35
src/PixiEditor/Models/Tools/Tools/SelectTool.cs

@@ -1,35 +0,0 @@
-using System.Windows.Input;
-using ChunkyImageLib.DataHolders;
-using PixiEditor.ChangeableDocument.Enums;
-using PixiEditor.Models.Commands.Attributes;
-using PixiEditor.Models.Commands.Attributes.Commands;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
-using SkiaSharp;
-
-namespace PixiEditor.Models.Tools.Tools;
-
-[Command.Tool(Key = Key.M)]
-internal class SelectTool : ReadonlyTool
-{
-    public SelectTool()
-    {
-        ActionDisplay = "Click and move to select an area.";
-        Toolbar = new SelectToolToolbar();
-    }
-
-    public SelectionMode SelectionType { get; set; } = SelectionMode.Add;
-
-    public override string Tooltip => $"Selects area. ({Shortcut})";
-
-    public override void BeforeUse()
-    {
-    }
-
-    public override void AfterUse(SKRectI sessionRect)
-    {
-    }
-
-    public override void Use(VecD pos)
-    {
-    }
-}

+ 24 - 20
src/PixiEditor/ViewModels/SubViewModels/Document/DocumentManagerViewModel.cs

@@ -1,12 +1,10 @@
 using System.Collections.ObjectModel;
 using System.Windows.Input;
 using ChunkyImageLib.DataHolders;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 using PixiEditor.Models.Commands.Attributes.Evaluators;
-using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Events;
-using PixiEditor.Models.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools;
 
 namespace PixiEditor.ViewModels.SubViewModels.Document;
 #nullable enable
@@ -67,7 +65,7 @@ internal class DocumentManagerViewModel : SubViewModel<ViewModelMain>
 
     //private readonly ToolsViewModel _tools;
 
-    private ToolSession? activeSession = null;
+    //private UpdateableChangeSession? activeSession = null;
 
     [Evaluator.CanExecute("PixiEditor.HasDocument")]
     public bool DocumentNotNull() => ActiveDocument != null;
@@ -87,19 +85,19 @@ internal class DocumentManagerViewModel : SubViewModel<ViewModelMain>
         */
     }
 
-    public void UpdateActionDisplay(Tool tool)
+    public void UpdateActionDisplay(ToolViewModel tool)
     {
         //tool?.UpdateActionDisplay(ToolSessionController.IsCtrlDown, ToolSessionController.IsShiftDown, ToolSessionController.IsAltDown);
     }
-
-    private void OnSessionStart(object sender, ToolSession e)
+    /*
+    private void OnSessionStart(object sender, UpdateableChangeSession e)
     {
         activeSession = e;
 
         ExecuteTool();
     }
 
-    private void OnSessionEnd(object sender, ToolSession e)
+    private void OnSessionEnd(object sender, UpdateableChangeSession e)
     {
         activeSession = null;
 
@@ -109,28 +107,33 @@ internal class DocumentManagerViewModel : SubViewModel<ViewModelMain>
 
     private void OnPreciseMousePositionChange(object sender, (double, double) e)
     {
+        /*
         if (activeSession == null || !activeSession.Tool.RequiresPreciseMouseData)
             return;
         ExecuteTool();
+        
     }
 
     private void OnPixelMousePositionChange(object sender, MouseMovementEventArgs e)
+    {*/
+    /*
+    if (activeSession != null)
     {
-        if (activeSession != null)
-        {
-            if (activeSession.Tool.RequiresPreciseMouseData)
-                return;
-            ExecuteTool();
+        if (activeSession.Tool.RequiresPreciseMouseData)
             return;
-        }
-        else
-        {
-            HighlightPixels(e.NewPosition);
-        }
+        ExecuteTool();
+        return;
+    }
+    else
+    {
+        HighlightPixels(e.NewPosition);
     }
 
+}*/
+
     private void ExecuteTool()
     {
+        /*
         if (activeSession == null)
             throw new Exception("Can't execute tool's Use outside a session");
 
@@ -146,6 +149,7 @@ internal class DocumentManagerViewModel : SubViewModel<ViewModelMain>
         {
             throw new InvalidOperationException($"'{activeSession.Tool.GetType().Name}' is either not a Tool or can't inherit '{nameof(Tool)}' directly.\nChanges the base type to either '{nameof(BitmapOperationTool)}' or '{nameof(ReadonlyTool)}'");
         }
+        */
     }
 
     private void BitmapManager_DocumentChanged(object sender)
@@ -158,8 +162,8 @@ internal class DocumentManagerViewModel : SubViewModel<ViewModelMain>
 
     public void UpdateHighlightIfNecessary(bool forceHide = false)
     {
-        if (activeSession != null)
-            return;
+        //if (activeSession != null)
+        //return;
 
         //HighlightPixels(forceHide ? new(-1, -1) : ToolSessionController.LastPixelPosition);
     }

+ 7 - 38
src/PixiEditor/ViewModels/SubViewModels/Main/IoViewModel.cs

@@ -7,9 +7,9 @@ using PixiEditor.Models.Commands.Commands;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Events;
-using PixiEditor.Models.Tools;
-using PixiEditor.Models.Tools.Tools;
 using PixiEditor.ViewModels.SubViewModels.Document;
+using PixiEditor.ViewModels.SubViewModels.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 using PixiEditor.Views;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main;
@@ -69,7 +69,6 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
 
     private void OnKeyDown(KeyEventArgs args)
     {
-
         var key = args.Key;
         if (key == Key.System)
             key = args.SystemKey;
@@ -77,13 +76,10 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
         ProcessShortcutDown(args.IsRepeat, key);
 
         if (Owner.DocumentManagerSubViewModel.ActiveDocument != null)
-        {
-            //Owner.DocumentManagerSubViewModel.InputTarget.OnKeyDown(key);
             Owner.DocumentManagerSubViewModel.ActiveDocument.OnKeyDown(key);
-        }
+        Owner.ToolsSubViewModel.OnKeyDown(key);
 
         HandleTransientKey(args, true);
-
     }
 
     private void HandleTransientKey(KeyEventArgs args, bool state)
@@ -121,30 +117,6 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
         }
 
         Owner.ShortcutController.KeyPressed(key, Keyboard.Modifiers);
-
-        // this was commented out before prototype integration
-        //public void KeyPressed(Key key, ModifierKeys modifiers)
-        //{
-        //    if (!ShortcutExecutionBlocked)
-        //    {
-        //        Shortcut[] shortcuts = ShortcutGroups.SelectMany(x => x.Shortcuts).ToList().FindAll(x => x.ShortcutKey == key).ToArray();
-        //        if (shortcuts.Length < 1)
-        //        {
-        //            return;
-        //        }
-
-        //        shortcuts = shortcuts.OrderByDescending(x => x.Modifier).ToArray();
-        //        for (int i = 0; i < shortcuts.Length; i++)
-        //        {
-        //            if (modifiers.HasFlag(shortcuts[i].Modifier))
-        //            {
-        //                shortcuts[i].Execute();
-        //                LastShortcut = shortcuts[i];
-        //                break;
-        //            }
-        //        }
-        //    }
-        //}
     }
 
     private void OnKeyUp(KeyEventArgs args)
@@ -156,11 +128,8 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
         ProcessShortcutUp(new(key, args.KeyboardDevice.Modifiers));
 
         if (Owner.DocumentManagerSubViewModel.ActiveDocument is not null)
-        {
             Owner.DocumentManagerSubViewModel.ActiveDocument.OnKeyUp(key);
-            //Owner.BitmapManager.InputTarget.OnKeyUp(key);
-        }
-
+        Owner.ToolsSubViewModel.OnKeyUp(key);
 
         HandleTransientKey(args, false);
     }
@@ -192,11 +161,11 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
 
     private void OnPreviewMiddleMouseButton(object sender)
     {
-        ChangeToolState<MoveViewportTool>(true);
+        ChangeToolState<MoveViewportToolViewModel>(true);
     }
 
     private void ChangeToolState<T>(bool setOn)
-        where T : Tool
+        where T : ToolViewModel
     {
         ChangeToolState(typeof(T), setOn);
     }
@@ -240,7 +209,7 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
         }
         else if (button == MouseButton.Middle)
         {
-            ChangeToolState<MoveViewportTool>(false);
+            ChangeToolState<MoveViewportToolViewModel>(false);
         }
     }
 }

+ 5 - 5
src/PixiEditor/ViewModels/SubViewModels/Main/StylusViewModel.cs

@@ -2,9 +2,9 @@
 using GalaSoft.MvvmLight.CommandWpf;
 using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
-using PixiEditor.Models.Tools;
-using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.UserPreferences;
+using PixiEditor.ViewModels.SubViewModels.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main;
 
@@ -37,7 +37,7 @@ internal class StylusViewModel : SubViewModel<ViewModelMain>
         set => SetProperty(ref useTouchGestures, value);
     }
 
-    private Tool PreviousTool { get; set; }
+    private ToolViewModel PreviousTool { get; set; }
 
     public RelayCommand<StylusButtonEventArgs> StylusDownCommand { get; }
 
@@ -69,7 +69,7 @@ internal class StylusViewModel : SubViewModel<ViewModelMain>
 
     private void UpdateUseTouchGesture()
     {
-        if (Owner.ToolsSubViewModel.ActiveTool is not (MoveViewportTool or ZoomTool))
+        if (Owner.ToolsSubViewModel.ActiveTool is not (MoveViewportToolViewModel or ZoomToolViewModel))
         {
             UseTouchGestures = IsPenModeEnabled;
         }
@@ -101,7 +101,7 @@ internal class StylusViewModel : SubViewModel<ViewModelMain>
         if (e.StylusButton.Guid == StylusPointProperties.TipButton.Id && e.Inverted)
         {
             PreviousTool = Owner.ToolsSubViewModel.ActiveTool;
-            Owner.ToolsSubViewModel.SetActiveTool<EraserTool>();
+            Owner.ToolsSubViewModel.SetActiveTool<EraserToolViewModel>();
             ToolSetByStylus = true;
         }
     }

+ 51 - 27
src/PixiEditor/ViewModels/SubViewModels/Main/ToolsViewModel.cs

@@ -1,32 +1,30 @@
 using System.Windows.Input;
 using Microsoft.Extensions.DependencyInjection;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 using PixiEditor.Models.Events;
-using PixiEditor.Models.Tools;
-using PixiEditor.Models.Tools.Tools;
-using PixiEditor.Models.Tools.ToolSettings.Settings;
 using PixiEditor.Models.UserPreferences;
+using PixiEditor.ViewModels.SubViewModels.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools.Tools;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main;
 
 [Command.Group("PixiEditor.Tools", "Tools")]
 internal class ToolsViewModel : SubViewModel<ViewModelMain>
 {
-    private Cursor toolCursor;
-    private Tool activeTool;
-
-    public Tool LastActionTool { get; private set; }
+    public ToolViewModel LastActionTool { get; private set; }
 
     public bool ActiveToolIsTransient { get; set; }
 
+    private Cursor toolCursor;
     public Cursor ToolCursor
     {
         get => toolCursor;
         set => SetProperty(ref toolCursor, value);
     }
 
-    public Tool ActiveTool
+    private ToolViewModel activeTool;
+    public ToolViewModel ActiveTool
     {
         get => activeTool;
         private set => SetProperty(ref activeTool, value);
@@ -42,23 +40,26 @@ internal class ToolsViewModel : SubViewModel<ViewModelMain>
             if (ActiveTool.Toolbar.GetSetting<SizeSetting>("ToolSize") is SizeSetting toolSize)
             {
                 toolSize.Value = value;
-                //Owner.BitmapManager.UpdateHighlightIfNecessary();
             }
         }
     }
 
-    public List<Tool> ToolSet { get; private set; }
+    public List<ToolViewModel> ToolSet { get; private set; }
 
     public event EventHandler<SelectedToolEventArgs> SelectedToolChanged;
 
+    private bool shiftIsDown;
+    private bool ctrlIsDown;
+    private bool altIsDown;
+
     public ToolsViewModel(ViewModelMain owner)
         : base(owner)
     { }
 
     public void SetupTools(IServiceProvider services)
     {
-        ToolSet = services.GetServices<Tool>().ToList();
-        SetActiveTool<PenTool>();
+        ToolSet = services.GetServices<ToolViewModel>().ToList();
+        SetActiveTool<PenToolViewModel>();
     }
 
     public void SetupToolsTooltipShortcuts(IServiceProvider services)
@@ -70,20 +71,18 @@ internal class ToolsViewModel : SubViewModel<ViewModelMain>
     }
 
     public void SetActiveTool<T>()
-        where T : Tool
+        where T : ToolViewModel
     {
         SetActiveTool(typeof(T));
     }
 
     [Command.Internal("PixiEditor.Tools.SelectTool", CanExecute = "PixiEditor.HasDocument")]
-    public void SetActiveTool(Tool tool)
+    public void SetActiveTool(ToolViewModel tool)
     {
         if (ActiveTool == tool) return;
 
         if (!tool.Toolbar.SettingsGenerated)
-        {
             tool.Toolbar.GenerateSettings();
-        }
 
         ActiveToolIsTransient = false;
         bool shareToolbar = IPreferences.Current.GetPreference<bool>("EnableSharedToolbar");
@@ -91,14 +90,10 @@ internal class ToolsViewModel : SubViewModel<ViewModelMain>
         {
             activeTool.IsActive = false;
             if (shareToolbar)
-            {
                 ActiveTool.Toolbar.SaveToolbarSettings();
-            }
         }
 
         LastActionTool = ActiveTool;
-
-
         ActiveTool = tool;
 
         if (shareToolbar)
@@ -110,10 +105,9 @@ internal class ToolsViewModel : SubViewModel<ViewModelMain>
             SelectedToolChanged?.Invoke(this, new SelectedToolEventArgs(LastActionTool, ActiveTool));
 
         //update old tool
-        //Owner.BitmapManager.UpdateActionDisplay(LastActionTool);
+        LastActionTool?.UpdateActionDisplay(false, false, false);
         //update new tool
-        //Owner.BitmapManager.UpdateActionDisplay(ActiveTool);
-        //Owner.BitmapManager.UpdateHighlightIfNecessary();
+        ActiveTool.UpdateActionDisplay(ctrlIsDown, shiftIsDown, altIsDown);
 
         tool.IsActive = true;
         SetToolCursor(tool.GetType());
@@ -132,7 +126,7 @@ internal class ToolsViewModel : SubViewModel<ViewModelMain>
             return;
         }
 
-        Tool tool = (Tool)parameter;
+        ToolViewModel tool = (ToolViewModel)parameter;
         SetActiveTool(tool.GetType());
     }
 
@@ -149,8 +143,8 @@ internal class ToolsViewModel : SubViewModel<ViewModelMain>
 
     public void SetActiveTool(Type toolType)
     {
-        if (!typeof(Tool).IsAssignableFrom(toolType)) { throw new ArgumentException($"'{toolType}' does not inherit from {typeof(Tool)}"); }
-        Tool foundTool = ToolSet.First(x => x.GetType() == toolType);
+        if (!typeof(ToolViewModel).IsAssignableFrom(toolType)) { throw new ArgumentException($"'{toolType}' does not inherit from {typeof(ToolViewModel)}"); }
+        ToolViewModel foundTool = ToolSet.First(x => x.GetType() == toolType);
         SetActiveTool(foundTool);
     }
 
@@ -165,4 +159,34 @@ internal class ToolsViewModel : SubViewModel<ViewModelMain>
             ToolCursor = Cursors.Arrow;
         }
     }
+
+    public void OnKeyDown(Key key)
+    {
+        bool shiftIsDown = key is Key.LeftShift or Key.RightShift;
+        bool ctrlIsDown = key is Key.LeftCtrl or Key.RightCtrl;
+        bool altIsDown = key is Key.LeftAlt or Key.RightAlt;
+        if (!shiftIsDown && !ctrlIsDown && !altIsDown)
+            return;
+        this.shiftIsDown |= shiftIsDown;
+        this.ctrlIsDown |= ctrlIsDown;
+        this.altIsDown |= altIsDown;
+
+        ActiveTool.UpdateActionDisplay(this.ctrlIsDown, this.shiftIsDown, this.altIsDown);
+    }
+
+    public void OnKeyUp(Key key)
+    {
+        bool shiftIsUp = key is Key.LeftShift or Key.RightShift;
+        bool ctrlIsUp = key is Key.LeftCtrl or Key.RightCtrl;
+        bool altIsUp = key is Key.LeftAlt or Key.RightAlt;
+        if (!shiftIsUp && !ctrlIsUp && !altIsUp)
+            return;
+        if (shiftIsUp)
+            this.shiftIsDown = false;
+        if (ctrlIsUp)
+            this.ctrlIsDown = false;
+        if (altIsUp)
+            this.altIsDown = false;
+        ActiveTool.UpdateActionDisplay(ctrlIsDown, shiftIsDown, altIsDown);
+    }
 }

+ 13 - 0
src/PixiEditor/ViewModels/SubViewModels/Tools/ShapeTool.cs

@@ -0,0 +1,13 @@
+using System.Windows.Input;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
+
+namespace PixiEditor.ViewModels.SubViewModels.Tools;
+
+internal abstract class ShapeTool : ToolViewModel
+{
+    public ShapeTool()
+    {
+        Cursor = Cursors.Cross;
+        Toolbar = new BasicShapeToolbar();
+    }
+}

+ 8 - 29
src/PixiEditor/Models/Tools/Tool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tool.cs

@@ -1,19 +1,15 @@
 using System.Windows.Input;
-using PixiEditor.Helpers;
 using PixiEditor.Helpers.Extensions;
-using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Tools.ToolSettings;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
-using SkiaSharp;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
-namespace PixiEditor.Models.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools;
 
-internal abstract class Tool : NotifyableObject
+internal abstract class ToolViewModel : NotifyableObject
 {
     public KeyCombination Shortcut { get; set; }
 
-    public virtual string ToolName => GetType().Name.Replace("Tool", string.Empty);
+    public virtual string ToolName => GetType().Name.Replace("Tool", string.Empty).Replace("ViewModel", string.Empty);
 
     public virtual string DisplayName => ToolName.AddSpacesBeforeUppercaseLetters();
 
@@ -21,27 +17,27 @@ internal abstract class Tool : NotifyableObject
 
     public virtual bool HideHighlight { get; }
 
-    public virtual bool RequiresPreciseMouseData { get; }
-
     public abstract string Tooltip { get; }
 
+    private string actionDisplay = string.Empty;
     public string ActionDisplay
     {
         get => actionDisplay;
         set
         {
             actionDisplay = value;
-            RaisePropertyChanged("ActionDisplay");
+            RaisePropertyChanged(nameof(ActionDisplay));
         }
     }
 
+    private bool isActive;
     public bool IsActive
     {
         get => isActive;
         set
         {
             isActive = value;
-            RaisePropertyChanged("IsActive");
+            RaisePropertyChanged(nameof(IsActive));
         }
     }
 
@@ -49,22 +45,5 @@ internal abstract class Tool : NotifyableObject
 
     public Toolbar Toolbar { get; set; } = new EmptyToolbar();
 
-    public ToolSession Session { get; set; }
-
-    private bool isActive;
-    private string actionDisplay = string.Empty;
-
-    public virtual void OnKeyDown(Key key) { }
-
-    public virtual void OnKeyUp(Key key) { }
-
-    public virtual void BeforeUse() { }
-
-    /// <summary>
-    ///     Called when the tool finished executing
-    /// </summary>
-    /// <param name="sessionRect">A rectangle which was created during session</param>
-    public virtual void AfterUse(SKRectI sessionRect) { }
-
     public virtual void UpdateActionDisplay(bool ctrlIsDown, bool shiftIsDown, bool altIsDown) { }
 }

+ 1 - 1
src/PixiEditor/Models/Tools/ToolSettings/SettingValueChangedEventArgs.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/SettingValueChangedEventArgs.cs

@@ -1,4 +1,4 @@
-namespace PixiEditor.Models.Tools.ToolSettings;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings;
 
 internal class SettingValueChangedEventArgs<T> : EventArgs
 {

+ 3 - 3
src/PixiEditor/Models/Tools/ToolSettings/Settings/BoolSetting.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/BoolSetting.cs

@@ -3,7 +3,7 @@ using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Settings;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 internal class BoolSetting : Setting<bool>
 {
@@ -21,13 +21,13 @@ internal class BoolSetting : Setting<bool>
 
     private Control GenerateCheckBox()
     {
-        CheckBox checkBox = new CheckBox
+        var checkBox = new CheckBox
         {
             IsChecked = Value,
             VerticalAlignment = VerticalAlignment.Center
         };
 
-        Binding binding = new Binding("Value")
+        var binding = new Binding("Value")
         {
             Mode = BindingMode.TwoWay
         };

+ 6 - 7
src/PixiEditor/Models/Tools/ToolSettings/Settings/ColorSetting.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/ColorSetting.cs

@@ -4,10 +4,9 @@ using System.Windows.Data;
 using System.Windows.Interactivity;
 using System.Windows.Media;
 using PixiEditor.Helpers.Behaviours;
-using PixiEditor.Views;
 using PixiEditor.Views.UserControls;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Settings;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 internal class ColorSetting : Setting<Color>
 {
@@ -21,20 +20,20 @@ internal class ColorSetting : Setting<Color>
     private ToolSettingColorPicker GenerateColorPicker()
     {
         var resourceDictionary = new ResourceDictionary();
-        resourceDictionary.Source = new System.Uri(
+        resourceDictionary.Source = new Uri(
             "pack://application:,,,/ColorPicker;component/Styles/DefaultColorPickerStyle.xaml",
-            System.UriKind.RelativeOrAbsolute);
-        ToolSettingColorPicker picker = new ToolSettingColorPicker
+            UriKind.RelativeOrAbsolute);
+        var picker = new ToolSettingColorPicker
         {
             Style = (Style)resourceDictionary["DefaultColorPickerStyle"]
         };
 
-        Binding selectedColorBinding = new Binding("Value")
+        var selectedColorBinding = new Binding("Value")
         {
             Mode = BindingMode.TwoWay
         };
 
-        GlobalShortcutFocusBehavior behavior = new GlobalShortcutFocusBehavior();
+        var behavior = new GlobalShortcutFocusBehavior();
         Interaction.GetBehaviors(picker).Add(behavior);
         picker.SetBinding(ToolSettingColorPicker.SelectedColorProperty, selectedColorBinding);
         return picker;

+ 5 - 5
src/PixiEditor/Models/Tools/ToolSettings/Settings/DropdownSetting.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/DropdownSetting.cs

@@ -3,7 +3,7 @@ using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Settings;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 internal class DropdownSetting : Setting<object>
 {
@@ -19,13 +19,13 @@ internal class DropdownSetting : Setting<object>
 
     private ComboBox GenerateDropdown()
     {
-        ComboBox combobox = new ComboBox
+        var combobox = new ComboBox
         {
             VerticalAlignment = VerticalAlignment.Center
         };
         GenerateItems(combobox);
 
-        Binding binding = new Binding("Value")
+        var binding = new Binding("Value")
         {
             Mode = BindingMode.TwoWay
         };
@@ -35,9 +35,9 @@ internal class DropdownSetting : Setting<object>
 
     private void GenerateItems(ComboBox comboBox)
     {
-        for (int i = 0; i < Values.Length; i++)
+        for (var i = 0; i < Values.Length; i++)
         {
-            ComboBoxItem item = new ComboBoxItem
+            var item = new ComboBoxItem
             {
                 Content = Values[i]
             };

+ 8 - 8
src/PixiEditor/Models/Tools/ToolSettings/Settings/EnumSetting.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/EnumSetting.cs

@@ -4,7 +4,7 @@ using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using PixiEditor.Helpers.Extensions;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Settings;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 internal class EnumSetting<TEnum> : Setting<TEnum, ComboBox>
     where TEnum : struct, Enum
@@ -34,9 +34,9 @@ internal class EnumSetting<TEnum> : Setting<TEnum, ComboBox>
         get => (TEnum)(SettingControl.SelectedItem as ComboBoxItem).Tag;
         set
         {
-            for (int i = 0; i < SettingControl.Items.Count; i++)
+            for (var i = 0; i < SettingControl.Items.Count; i++)
             {
-                ComboBoxItem item = SettingControl.Items[i] as ComboBoxItem;
+                var item = SettingControl.Items[i] as ComboBoxItem;
 
                 if (item.Tag.Equals(value))
                 {
@@ -65,14 +65,14 @@ internal class EnumSetting<TEnum> : Setting<TEnum, ComboBox>
 
     private static ComboBox GenerateDropdown()
     {
-        ComboBox combobox = new ComboBox
+        var combobox = new ComboBox
         {
             VerticalAlignment = VerticalAlignment.Center
         };
 
         GenerateItems(combobox);
 
-        Binding binding = new Binding(nameof(SelectedIndex))
+        var binding = new Binding(nameof(SelectedIndex))
         {
             Mode = BindingMode.TwoWay
         };
@@ -84,11 +84,11 @@ internal class EnumSetting<TEnum> : Setting<TEnum, ComboBox>
 
     private static void GenerateItems(ComboBox comboBox)
     {
-        TEnum[] values = Enum.GetValues<TEnum>();
+        var values = Enum.GetValues<TEnum>();
 
-        foreach (TEnum value in values)
+        foreach (var value in values)
         {
-            ComboBoxItem item = new ComboBoxItem
+            var item = new ComboBoxItem
             {
                 Content = value.GetDescription(),
                 Tag = value

+ 3 - 4
src/PixiEditor/Models/Tools/ToolSettings/Settings/FloatSetting.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/FloatSetting.cs

@@ -1,9 +1,8 @@
 using System.Windows.Controls;
 using System.Windows.Data;
-using PixiEditor.Views;
 using PixiEditor.Views.UserControls;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Settings;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 internal class FloatSetting : Setting<float>
 {
@@ -27,14 +26,14 @@ internal class FloatSetting : Setting<float>
 
     private NumberInput GenerateNumberInput()
     {
-        NumberInput numbrInput = new NumberInput
+        var numbrInput = new NumberInput
         {
             Width = 40,
             Height = 20,
             Min = Min,
             Max = Max
         };
-        Binding binding = new Binding("Value")
+        var binding = new Binding("Value")
         {
             Mode = BindingMode.TwoWay
         };

+ 1 - 2
src/PixiEditor/Models/Tools/ToolSettings/Settings/Setting.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/Setting.cs

@@ -1,9 +1,8 @@
 using System.Windows.Controls;
-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.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 internal abstract class Setting<T, TControl> : Setting<T>
     where TControl : Control

+ 3 - 4
src/PixiEditor/Models/Tools/ToolSettings/Settings/SizeSetting.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Settings/SizeSetting.cs

@@ -1,10 +1,9 @@
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
-using PixiEditor.Views;
 using PixiEditor.Views.UserControls;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Settings;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
 internal class SizeSetting : Setting<int>
 {
@@ -17,7 +16,7 @@ internal class SizeSetting : Setting<int>
 
     private SizeInput GenerateTextBox()
     {
-        SizeInput tb = new SizeInput
+        var tb = new SizeInput
         {
             Width = 65,
             Height = 20,
@@ -26,7 +25,7 @@ internal class SizeSetting : Setting<int>
             IsEnabled = true
         };
 
-        Binding binding = new Binding("Value")
+        var binding = new Binding("Value")
         {
             Mode = BindingMode.TwoWay,
         };

+ 2 - 2
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/BasicShapeToolbar.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/BasicShapeToolbar.cs

@@ -1,6 +1,6 @@
-using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 internal class BasicShapeToolbar : BasicToolbar
 {

+ 2 - 2
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/BasicToolbar.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/BasicToolbar.cs

@@ -1,6 +1,6 @@
-using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 /// <summary>
 ///     Toolbar with size setting.

+ 2 - 2
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/BrightnessToolToolbar.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/BrightnessToolToolbar.cs

@@ -1,7 +1,7 @@
 using PixiEditor.Models.Enums;
-using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 internal class BrightnessToolToolbar : BasicToolbar
 {

+ 5 - 0
src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/EmptyToolbar.cs

@@ -0,0 +1,5 @@
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
+
+internal class EmptyToolbar : Toolbar
+{
+}

+ 2 - 2
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/MagicWandToolbar.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/MagicWandToolbar.cs

@@ -1,7 +1,7 @@
 using PixiEditor.Models.Enums;
-using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 internal class MagicWandToolbar : SelectToolToolbar
 {

+ 2 - 2
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/PenToolbar.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/PenToolbar.cs

@@ -1,6 +1,6 @@
-using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 internal class PenToolbar : BasicToolbar
 {

+ 2 - 2
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/SelectToolToolbar.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/SelectToolToolbar.cs

@@ -1,8 +1,8 @@
 using PixiEditor.ChangeableDocument.Enums;
 using PixiEditor.Models.Enums;
-using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 internal class SelectToolToolbar : Toolbar
 {

+ 5 - 5
src/PixiEditor/Models/Tools/ToolSettings/Toolbars/Toolbar.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/ToolSettings/Toolbars/Toolbar.cs

@@ -1,7 +1,7 @@
 using System.Collections.ObjectModel;
-using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Settings;
 
-namespace PixiEditor.Models.Tools.ToolSettings.Toolbars;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
 internal abstract class Toolbar
 {
@@ -38,7 +38,7 @@ internal abstract class Toolbar
     public T GetSetting<T>(string name)
         where T : Setting
     {
-        Setting setting = Settings.FirstOrDefault(currentSetting => string.Equals(currentSetting.Name, name, StringComparison.CurrentCultureIgnoreCase));
+        var setting = Settings.FirstOrDefault(currentSetting => string.Equals(currentSetting.Name, name, StringComparison.CurrentCultureIgnoreCase));
 
         if (setting == null || !(setting is T convertedSetting))
         {
@@ -53,7 +53,7 @@ internal abstract class Toolbar
     /// </summary>
     public void SaveToolbarSettings()
     {
-        for (int i = 0; i < Settings.Count; i++)
+        for (var i = 0; i < Settings.Count; i++)
         {
             if (SharedSettings.Any(x => x.Name == Settings[i].Name))
             {
@@ -71,7 +71,7 @@ internal abstract class Toolbar
     /// </summary>
     public void LoadSharedSettings()
     {
-        for (int i = 0; i < SharedSettings.Count; i++)
+        for (var i = 0; i < SharedSettings.Count; i++)
         {
             if (Settings.Any(x => x.Name == SharedSettings[i].Name))
             {

+ 5 - 11
src/PixiEditor/Models/Tools/Tools/BrightnessTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/BrightnessToolViewModel.cs

@@ -1,19 +1,18 @@
 using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 using PixiEditor.Models.Enums;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.U)]
-internal class BrightnessTool : BitmapOperationTool
+internal class BrightnessToolViewModel : ToolViewModel
 {
-    private const float CorrectionFactor = 5f; // Initial correction factor
+    private const float CorrectionFactor = 5f;
 
     private readonly string defaultActionDisplay = "Draw on pixels to make them brighter. Hold Ctrl to darken.";
 
-    public BrightnessTool()
+    public BrightnessToolViewModel()
     {
         ActionDisplay = defaultActionDisplay;
         Toolbar = new BrightnessToolToolbar(CorrectionFactor);
@@ -30,9 +29,4 @@ internal class BrightnessTool : BitmapOperationTool
         else
             ActionDisplay = "Draw on pixels to make them darker. Release Ctrl to brighten.";
     }
-
-    public override void Use()
-    {
-
-    }
 }

+ 3 - 9
src/PixiEditor/Models/Tools/Tools/CircleTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/CircleToolViewModel.cs

@@ -1,15 +1,14 @@
 using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.C)]
-internal class CircleTool : ShapeTool
+internal class CircleToolViewModel : ShapeTool
 {
     private string defaultActionDisplay = "Click and move mouse to draw a circle. Hold Shift to draw an even one.";
 
-    public CircleTool()
+    public CircleToolViewModel()
     {
         ActionDisplay = defaultActionDisplay;
     }
@@ -23,9 +22,4 @@ internal class CircleTool : ShapeTool
         else
             ActionDisplay = defaultActionDisplay;
     }
-
-    public override void Use()
-    {
-
-    }
 }

+ 3 - 12
src/PixiEditor/Models/Tools/Tools/ColorPickerTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/ColorPickerToolViewModel.cs

@@ -1,24 +1,20 @@
 using System.Windows.Input;
-using ChunkyImageLib.DataHolders;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.O, Transient = Key.LeftAlt)]
-internal class ColorPickerTool : ReadonlyTool
+internal class ColorPickerToolViewModel : ToolViewModel
 {
     private readonly string defaultActionDisplay = "Click to pick colors. Hold Ctrl to hide the canvas. Hold Shift to hide the reference layer";
 
-    public ColorPickerTool()
+    public ColorPickerToolViewModel()
     {
         ActionDisplay = defaultActionDisplay;
     }
 
     public override bool HideHighlight => true;
 
-    public override bool RequiresPreciseMouseData => true;
-
     public override string Tooltip => $"Picks the primary color from the canvas. ({Shortcut})";
 
     public override void UpdateActionDisplay(bool ctrlIsDown, bool shiftIsDown, bool altIsDown)
@@ -51,9 +47,4 @@ internal class ColorPickerTool : ReadonlyTool
             ActionDisplay = defaultActionDisplay;
         }*/
     }
-
-    public override void Use(VecD position)
-    {
-
-    }
 }

+ 17 - 23
src/PixiEditor/Models/Tools/Tools/EraserTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/EraserToolViewModel.cs

@@ -1,23 +1,17 @@
-using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
-using PixiEditor.Models.Commands.Attributes.Commands;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
-
-namespace PixiEditor.Models.Tools.Tools;
-
-[Command.Tool(Key = Key.E)]
-internal class EraserTool : BitmapOperationTool
-{
-    public EraserTool()
-    {
-        ActionDisplay = "Draw to remove color from a pixel.";
-        Toolbar = new BasicToolbar();
-    }
-
-    public override string Tooltip => $"Erasers color from pixel. ({Shortcut})";
-
-    public override void Use()
-    {
-
-    }
-}
+using System.Windows.Input;
+using PixiEditor.Models.Commands.Attributes.Commands;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
+
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
+
+[Command.Tool(Key = Key.E)]
+internal class EraserToolViewModel : ToolViewModel
+{
+    public EraserToolViewModel()
+    {
+        ActionDisplay = "Draw to remove color from a pixel.";
+        Toolbar = new BasicToolbar();
+    }
+
+    public override string Tooltip => $"Erasers color from pixel. ({Shortcut})";
+}

+ 3 - 9
src/PixiEditor/Models/Tools/Tools/FloodFillTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/FloodFillToolViewModel.cs

@@ -1,24 +1,18 @@
 using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 using SkiaSharp;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.G)]
-internal class FloodFillTool : BitmapOperationTool
+internal class FloodFillToolViewModel : ToolViewModel
 {
     private SKPaint fillPaint = new SKPaint() { BlendMode = SKBlendMode.Src };
 
-    public FloodFillTool()
+    public FloodFillToolViewModel()
     {
         ActionDisplay = "Press on an area to fill it.";
     }
 
     public override string Tooltip => $"Fills area with color. ({Shortcut})";
-
-    public override void Use()
-    {
-        throw new NotImplementedException();
-    }
 }

+ 4 - 10
src/PixiEditor/Models/Tools/Tools/LineTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/LineToolViewModel.cs

@@ -1,16 +1,15 @@
 using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.L)]
-internal class LineTool : ShapeTool
+internal class LineToolViewModel : ShapeTool
 {
     private string defaltActionDisplay = "Click and move to draw a line. Hold Shift to draw an even one.";
 
-    public LineTool()
+    public LineToolViewModel()
     {
         ActionDisplay = defaltActionDisplay;
         Toolbar = new BasicToolbar();
@@ -25,9 +24,4 @@ internal class LineTool : ShapeTool
         else
             ActionDisplay = defaltActionDisplay;
     }
-
-    public override void Use()
-    {
-        throw new NotImplementedException();
-    }
 }

+ 4 - 11
src/PixiEditor/Models/Tools/Tools/MagicWandTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/MagicWandToolViewModel.cs

@@ -1,24 +1,17 @@
 using System.Windows.Input;
-using ChunkyImageLib.DataHolders;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.W)]
-internal class MagicWandTool : ReadonlyTool
+internal class MagicWandToolViewModel : ToolViewModel
 {
     public override string Tooltip => $"Magic Wand ({Shortcut}). Flood's the selection";
 
-    public MagicWandTool()
+    public MagicWandToolViewModel()
     {
         Toolbar = new MagicWandToolbar();
         ActionDisplay = "Click to flood the selection.";
     }
-
-    public override void Use(VecD position)
-    {
-
-    }
 }

+ 3 - 9
src/PixiEditor/Models/Tools/Tools/MoveTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/MoveToolViewModel.cs

@@ -1,15 +1,14 @@
 using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.V)]
-internal class MoveTool : BitmapOperationTool
+internal class MoveToolViewModel : ToolViewModel
 {
     private string defaultActionDisplay = "Hold mouse to move selected pixels. Hold Ctrl to move all layers.";
 
-    public MoveTool()
+    public MoveToolViewModel()
     {
         ActionDisplay = defaultActionDisplay;
         Cursor = Cursors.Arrow;
@@ -26,9 +25,4 @@ internal class MoveTool : BitmapOperationTool
         else
             ActionDisplay = defaultActionDisplay;
     }
-
-    public override void Use()
-    {
-
-    }
 }

+ 3 - 10
src/PixiEditor/Models/Tools/Tools/MoveViewportTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/MoveViewportToolViewModel.cs

@@ -1,14 +1,12 @@
 using System.Windows.Input;
-using ChunkyImageLib.DataHolders;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.H, Transient = Key.Space)]
-internal class MoveViewportTool : ReadonlyTool
+internal class MoveViewportToolViewModel : ToolViewModel
 {
-    public MoveViewportTool()
+    public MoveViewportToolViewModel()
     {
         Cursor = Cursors.SizeAll;
         ActionDisplay = "Click and move to pan viewport.";
@@ -16,9 +14,4 @@ internal class MoveViewportTool : ReadonlyTool
 
     public override bool HideHighlight => true;
     public override string Tooltip => $"Move viewport. ({Shortcut})";
-
-    public override void Use(VecD pos)
-    {
-        // Implemented inside Zoombox.xaml.cs
-    }
 }

+ 19 - 0
src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/PenToolViewModel.cs

@@ -0,0 +1,19 @@
+using System.Windows.Input;
+using PixiEditor.Models.Commands.Attributes.Commands;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
+
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools
+{
+    [Command.Tool(Key = Key.B)]
+    internal class PenToolViewModel : ShapeTool
+    {
+        public PenToolViewModel()
+        {
+            Cursor = Cursors.Pen;
+            ActionDisplay = "Click and move to draw.";
+            Toolbar = new PenToolbar();
+        }
+
+        public override string Tooltip => $"Standard brush. ({Shortcut})";
+    }
+}

+ 3 - 8
src/PixiEditor/Models/Tools/Tools/RectangleTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/RectangleToolViewModel.cs

@@ -1,14 +1,13 @@
 using System.Windows.Input;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.R)]
-internal class RectangleTool : ShapeTool
+internal class RectangleToolViewModel : ShapeTool
 {
     private string defaultActionDisplay = "Click and move to draw a rectangle. Hold Shift to draw a square.";
-    public RectangleTool()
+    public RectangleToolViewModel()
     {
         ActionDisplay = defaultActionDisplay;
     }
@@ -24,8 +23,4 @@ internal class RectangleTool : ShapeTool
         else
             ActionDisplay = defaultActionDisplay;
     }
-
-    public override void Use()
-    {
-    }
 }

+ 20 - 0
src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/SelectToolViewModel.cs

@@ -0,0 +1,20 @@
+using System.Windows.Input;
+using PixiEditor.ChangeableDocument.Enums;
+using PixiEditor.Models.Commands.Attributes.Commands;
+using PixiEditor.ViewModels.SubViewModels.Tools.ToolSettings.Toolbars;
+
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
+
+[Command.Tool(Key = Key.M)]
+internal class SelectToolViewModel : ToolViewModel
+{
+    public SelectToolViewModel()
+    {
+        ActionDisplay = "Click and move to select an area.";
+        Toolbar = new SelectToolToolbar();
+    }
+
+    public SelectionMode SelectionType { get; set; } = SelectionMode.Add;
+
+    public override string Tooltip => $"Selects area. ({Shortcut})";
+}

+ 6 - 17
src/PixiEditor/Models/Tools/Tools/ZoomTool.cs → src/PixiEditor/ViewModels/SubViewModels/Tools/Tools/ZoomToolViewModel.cs

@@ -1,16 +1,14 @@
 using System.Windows.Input;
-using ChunkyImageLib.DataHolders;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 
-namespace PixiEditor.Models.Tools.Tools;
+namespace PixiEditor.ViewModels.SubViewModels.Tools.Tools;
 
 [Command.Tool(Key = Key.Z)]
-internal class ZoomTool : ReadonlyTool
+internal class ZoomToolViewModel : ToolViewModel
 {
     private string defaultActionDisplay = "Click and move to zoom. Click to zoom in, hold ctrl and click to zoom out.";
 
-    public ZoomTool()
+    public ZoomToolViewModel()
     {
         ActionDisplay = defaultActionDisplay;
     }
@@ -19,24 +17,15 @@ internal class ZoomTool : ReadonlyTool
 
     public override string Tooltip => $"Zooms viewport ({Shortcut}). Click to zoom in, hold alt and click to zoom out.";
 
-    public override void OnKeyDown(Key key)
+    public override void UpdateActionDisplay(bool ctrlIsDown, bool shiftIsDown, bool altIsDown)
     {
-        if (key is Key.LeftCtrl)
+        if (ctrlIsDown)
         {
             ActionDisplay = "Click and move to zoom. Click to zoom out, release ctrl and click to zoom in.";
         }
-    }
-
-    public override void OnKeyUp(Key key)
-    {
-        if (key is Key.LeftCtrl)
+        else
         {
             ActionDisplay = defaultActionDisplay;
         }
     }
-
-    public override void Use(VecD pos)
-    {
-        // Implemented inside Zoombox.xaml.cs
-    }
 }

+ 4 - 4
src/PixiEditor/ViewModels/ViewModelMain.cs

@@ -5,10 +5,10 @@ using PixiEditor.Models.Commands;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Events;
-using PixiEditor.Models.Tools;
 using PixiEditor.Models.UserPreferences;
 using PixiEditor.ViewModels.SubViewModels.Document;
 using PixiEditor.ViewModels.SubViewModels.Main;
+using PixiEditor.ViewModels.SubViewModels.Tools;
 using SkiaSharp;
 
 namespace PixiEditor.ViewModels;
@@ -188,7 +188,7 @@ internal class ViewModelMain : ViewModelBase
 
     private void SelectedTool_PropertyChanged(object sender, PropertyChangedEventArgs e)
     {
-        if (e.PropertyName == nameof(Tool.ActionDisplay))
+        if (e.PropertyName == nameof(ToolViewModel.ActionDisplay))
         {
             NotifyToolActionDisplayChanged();
         }
@@ -281,9 +281,9 @@ internal class ViewModelMain : ViewModelBase
     private void BitmapUtility_BitmapChanged(object sender, EventArgs e)
     {
         //BitmapManager.ActiveDocument.ChangesSaved = false;
-        if (ToolsSubViewModel.ActiveTool is BitmapOperationTool)
+        /*if (ToolsSubViewModel.ActiveTool is BitmapOperationTool)
         {
             ColorsSubViewModel.AddSwatch(ColorsSubViewModel.PrimaryColor);
-        }
+        }*/
     }
 }

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

@@ -8,7 +8,7 @@
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:local="clr-namespace:PixiEditor"
-    xmlns:tools="clr-namespace:PixiEditor.Models.Tools.Tools"
+    xmlns:tools="clr-namespace:PixiEditor.ViewModels.SubViewModels.Tools.Tools"
     xmlns:vm="clr-namespace:PixiEditor.ViewModels"
     xmlns:doc="clr-namespace:PixiEditor.ViewModels.SubViewModels.Document"
     xmlns:dataHolders="clr-namespace:PixiEditor.Models.DataHolders"
@@ -55,10 +55,10 @@
             <converters:DoubleToIntConverter
                 x:Key="DoubleToIntConverter" />
             <converters:IsSpecifiedTypeConverter
-                SpecifiedType="{x:Type tools:ZoomTool}"
+                SpecifiedType="{x:Type tools:ZoomToolViewModel}"
                 x:Key="IsZoomToolConverter" />
             <converters:IsSpecifiedTypeConverter
-                SpecifiedType="{x:Type tools:MoveViewportTool}"
+                SpecifiedType="{x:Type tools:MoveViewportToolViewModel}"
                 x:Key="IsMoveViewportToolConverter" />
             <converters:SKColorToMediaColorConverter
                 x:Key="SKColorToMediaColorConverter" />