Browse Source

Add a tool size increase and decrease shortcuts using [ and ]

Brendan Holmes 4 years ago
parent
commit
4584556cc1

+ 9 - 2
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -43,9 +43,16 @@ namespace PixiEditor.Models.Controllers
 
 
         public Color PrimaryColor { get; set; }
         public Color PrimaryColor { get; set; }
 
 
-        public int ToolSize => SelectedTool.Toolbar.GetSetting("ToolSize") != null
-            ? (int) SelectedTool.Toolbar.GetSetting("ToolSize").Value
+        public int ToolSize
+        {
+            get => SelectedTool.Toolbar.GetSetting("ToolSize") != null
+            ? (int)SelectedTool.Toolbar.GetSetting("ToolSize").Value
             : 1;
             : 1;
+            set
+            {
+                SelectedTool.Toolbar.GetSetting("ToolSize").Value = value;
+            }
+        }
 
 
         public BitmapOperationsUtility BitmapOperations { get; set; }
         public BitmapOperationsUtility BitmapOperations { get; set; }
         public ReadonlyToolUtility ReadonlyToolUtility { get; set; }
         public ReadonlyToolUtility ReadonlyToolUtility { get; set; }

+ 14 - 1
PixiEditor/ViewModels/ViewModelMain.cs

@@ -80,6 +80,7 @@ namespace PixiEditor.ViewModels
         public RelayCommand CenterContentCommand { get; set; }
         public RelayCommand CenterContentCommand { get; set; }
         public RelayCommand OpenHyperlinkCommand { get; set; }
         public RelayCommand OpenHyperlinkCommand { get; set; }
         public RelayCommand ZoomCommand { get; set; }
         public RelayCommand ZoomCommand { get; set; }
+        public RelayCommand ChangeToolSizeCommand { get; set; }
 
 
 
 
         private double _mouseXonCanvas;
         private double _mouseXonCanvas;
@@ -178,7 +179,6 @@ namespace PixiEditor.ViewModels
             }
             }
         }
         }
 
 
-
         public BitmapManager BitmapManager { get; set; }
         public BitmapManager BitmapManager { get; set; }
         public PixelChangesController ChangesController { get; set; }
         public PixelChangesController ChangesController { get; set; }
 
 
@@ -239,6 +239,7 @@ namespace PixiEditor.ViewModels
             CenterContentCommand = new RelayCommand(CenterContent, DocumentIsNotNull);
             CenterContentCommand = new RelayCommand(CenterContent, DocumentIsNotNull);
             OpenHyperlinkCommand = new RelayCommand(OpenHyperlink);
             OpenHyperlinkCommand = new RelayCommand(OpenHyperlink);
             ZoomCommand = new RelayCommand(ZoomViewport);
             ZoomCommand = new RelayCommand(ZoomViewport);
+            ChangeToolSizeCommand = new RelayCommand(ChangeToolSize);
             ToolSet = new ObservableCollection<Tool>
             ToolSet = new ObservableCollection<Tool>
             {
             {
                 new MoveTool(), new PenTool(), new SelectTool(), new FloodFill(), new LineTool(),
                 new MoveTool(), new PenTool(), new SelectTool(), new FloodFill(), new LineTool(),
@@ -263,6 +264,8 @@ namespace PixiEditor.ViewModels
                     new Shortcut(Key.Z, SelectToolCommand, ToolType.Zoom),
                     new Shortcut(Key.Z, SelectToolCommand, ToolType.Zoom),
                     new Shortcut(Key.OemPlus, ZoomCommand, 115),
                     new Shortcut(Key.OemPlus, ZoomCommand, 115),
                     new Shortcut(Key.OemMinus, ZoomCommand, 85),
                     new Shortcut(Key.OemMinus, ZoomCommand, 85),
+                    new Shortcut(Key.OemOpenBrackets, ChangeToolSizeCommand, -1),
+                    new Shortcut(Key.OemCloseBrackets, ChangeToolSizeCommand, 1),
                     //Editor
                     //Editor
                     new Shortcut(Key.X, SwapColorsCommand),
                     new Shortcut(Key.X, SwapColorsCommand),
                     new Shortcut(Key.Y, RedoCommand, modifier: ModifierKeys.Control),
                     new Shortcut(Key.Y, RedoCommand, modifier: ModifierKeys.Control),
@@ -299,6 +302,16 @@ namespace PixiEditor.ViewModels
             ZoomPercentage = 100;
             ZoomPercentage = 100;
         }
         }
 
 
+        private void ChangeToolSize(object parameter)
+        {
+            int increment = (int)parameter;
+            int newSize = BitmapManager.ToolSize + increment;
+            if (newSize > 0)
+            {
+                BitmapManager.ToolSize = newSize;
+            }
+        }
+
         private void OpenHyperlink(object parameter)
         private void OpenHyperlink(object parameter)
         {
         {
             if (parameter == null) return;
             if (parameter == null) return;