Browse Source

Chopped multiple methods into command params

flabbet 2 years ago
parent
commit
9a591b7293

+ 16 - 36
src/PixiEditor/ViewModels/SubViewModels/Document/DocumentManagerViewModel.cs

@@ -94,49 +94,29 @@ internal class DocumentManagerViewModel : SubViewModel<ViewModelMain>
         ActiveDocument?.Operations.FlipImage(FlipType.Vertical, ActiveDocument.GetSelectedMembers());
     }
     
-    [Command.Basic("PixiEditor.Document.Rotate90Deg", "Rotate Image 90 deg", "Rotate Image 90 deg", CanExecute = "PixiEditor.HasDocument")]
-    public void Rotate90Deg()
+    [Command.Basic("PixiEditor.Document.Rotate90Deg", "Rotate Image 90 degrees", 
+        "Rotate Image 90 degrees", CanExecute = "PixiEditor.HasDocument", Parameter = RotationAngle.D90)]
+    [Command.Basic("PixiEditor.Document.Rotate180Deg", "Rotate Image 180 degrees", 
+        "Rotate Image 180 degrees", CanExecute = "PixiEditor.HasDocument", Parameter = RotationAngle.D180)]
+    [Command.Basic("PixiEditor.Document.Rotate270Deg", "Rotate Image -90 degrees", 
+        "Rotate Image -90 degrees", CanExecute = "PixiEditor.HasDocument", Parameter = RotationAngle.D270)]
+    public void RotateImage(RotationAngle angle)
     {
-        ActiveDocument?.Operations.RotateImage(RotationAngle.D90);
-    }
-    
-    [Command.Basic("PixiEditor.Document.Rotate90DegLayers", "Rotate Selected Layers 90 deg", "Rotate Selected Layers 90 deg", CanExecute = "PixiEditor.HasDocument")]
-    public void Rotate90DegLayers()
-    {
-        if (ActiveDocument?.SelectedStructureMember == null)
-            return;
-        
-        ActiveDocument?.Operations.RotateImage(RotationAngle.D90, ActiveDocument.GetSelectedMembers());
-    }
-    
-    [Command.Basic("PixiEditor.Document.Rotate180Deg", "Rotate Image 180 deg", "Rotate Image 180 deg", CanExecute = "PixiEditor.HasDocument")]
-    public void Rotate180Deg()
-    {
-        ActiveDocument?.Operations.RotateImage(RotationAngle.D180);
-    }
-    
-    [Command.Basic("PixiEditor.Document.Rotate180DegLayers", "Rotate Selected Layers 180 deg", "Rotate Selected Layers 180 deg", CanExecute = "PixiEditor.HasDocument")]
-    public void Rotate180DegLayers()
-    {
-        if (ActiveDocument?.SelectedStructureMember == null)
-            return;
-        
-        ActiveDocument?.Operations.RotateImage(RotationAngle.D180, ActiveDocument.GetSelectedMembers());
+        ActiveDocument?.Operations.RotateImage(angle);
     }
 
-    [Command.Basic("PixiEditor.Document.Rotate270Deg", "Rotate Image -90 deg", "Rotate Image -90 deg", CanExecute = "PixiEditor.HasDocument")]
-    public void Rotate270Deg()
-    {
-        ActiveDocument?.Operations.RotateImage(RotationAngle.D270);
-    }
-    
-    [Command.Basic("PixiEditor.Document.Rotate270DegLayers", "Rotate Selected Layers 270 deg", "Rotate Selected Layers 270 deg", CanExecute = "PixiEditor.HasDocument")]
-    public void Rotate270DegLayers()
+    [Command.Basic("PixiEditor.Document.Rotate90DegLayers", "Rotate Selected Layers 90 degrees", 
+        "Rotate Selected Layers 90 degrees", CanExecute = "PixiEditor.HasDocument", Parameter = RotationAngle.D90)]
+    [Command.Basic("PixiEditor.Document.Rotate180DegLayers", "Rotate Selected Layers 180 degrees", 
+        "Rotate Selected Layers 180 degrees", CanExecute = "PixiEditor.HasDocument", Parameter = RotationAngle.D180)]
+    [Command.Basic("PixiEditor.Document.Rotate270DegLayers", "Rotate Selected Layers -90 degrees", 
+        "Rotate Selected Layers -90 degrees", CanExecute = "PixiEditor.HasDocument", Parameter = RotationAngle.D270)]
+    public void RotateLayers(RotationAngle angle)
     {
         if (ActiveDocument?.SelectedStructureMember == null)
             return;
         
-        ActiveDocument?.Operations.RotateImage(RotationAngle.D270, ActiveDocument.GetSelectedMembers());
+        ActiveDocument?.Operations.RotateImage(angle, ActiveDocument.GetSelectedMembers());
     }
 
     [Command.Basic("PixiEditor.Document.ToggleVerticalSymmetryAxis", "Toggle vertical symmetry axis", "Toggle vertical symmetry axis", CanExecute = "PixiEditor.HasDocument", IconPath = "SymmetryVertical.png")]

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

@@ -581,9 +581,9 @@
                                                                             <MenuItem Header="Flip _Horizontally" cmds:Menu.Command="PixiEditor.Document.FlipLayersHorizontal"/>
                                                                             <MenuItem Header="Flip _Vertically" cmds:Menu.Command="PixiEditor.Document.FlipLayersVertical"/>
                                                                             <Separator />
-                                                                            <MenuItem Header="Rotate Right" cmds:Menu.Command="PixiEditor.Document.Rotate90DegLayers"/>
+                                                                            <MenuItem Header="Rotate 90&#186;" cmds:Menu.Command="PixiEditor.Document.Rotate90DegLayers"/>
                                                                             <MenuItem Header="Rotate 180&#186;" cmds:Menu.Command="PixiEditor.Document.Rotate180DegLayers"/>
-                                                                            <MenuItem Header="Rotate Left" cmds:Menu.Command="PixiEditor.Document.Rotate270DegLayers"/>
+                                                                            <MenuItem Header="Rotate -90&#186;" cmds:Menu.Command="PixiEditor.Document.Rotate270DegLayers"/>
                                                                         </StackPanel>
                                                                     </Border>
                                                                     <ScrollViewer Margin="5" Grid.Column="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">