Browse Source

Added a few viewModels

flabbet 4 years ago
parent
commit
7e5f4601b4

+ 2 - 2
PixiEditor/Properties/AssemblyInfo.cs

@@ -50,5 +50,5 @@ using System.Windows;
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
 
 
-[assembly: AssemblyVersion("0.1.3.2")]
-[assembly: AssemblyFileVersion("0.1.3.2")]
+[assembly: AssemblyVersion("0.1.3.5")]
+[assembly: AssemblyFileVersion("0.1.3.5")]

+ 60 - 0
PixiEditor/ViewModels/SubViewModels/Main/ClipboardViewModel.cs

@@ -0,0 +1,60 @@
+using PixiEditor.Helpers;
+using PixiEditor.Models.Controllers;
+using PixiEditor.Models.DataHolders;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Media;
+
+namespace PixiEditor.ViewModels.SubViewModels.Main
+{
+    public class ClipboardViewModel : SubViewModel<ViewModelMain>
+    {
+        public RelayCommand CopyCommand { get; set; }
+        public RelayCommand DuplicateCommand { get; set; }
+        public RelayCommand CutCommand { get; set; }
+        public RelayCommand PasteCommand { get; set; }
+
+        public ClipboardViewModel(ViewModelMain owner) : base(owner)
+        {
+            CopyCommand = new RelayCommand(Copy, Owner.SelectionIsNotEmpty);
+            DuplicateCommand = new RelayCommand(Duplicate, Owner.SelectionIsNotEmpty);
+            CutCommand = new RelayCommand(Cut, Owner.SelectionIsNotEmpty);
+            PasteCommand = new RelayCommand(Paste, CanPaste);
+        }
+
+        public void Duplicate(object parameter)
+        {
+            Copy(null);
+            Paste(null);
+        }
+
+        public void Cut(object parameter)
+        {
+            Copy(null);
+            Owner.BitmapManager.ActiveLayer.SetPixels(
+                BitmapPixelChanges.FromSingleColoredArray(Owner.ActiveSelection.SelectedPoints.ToArray(),
+                    Colors.Transparent));
+        }
+
+        public void Paste(object parameter)
+        {
+            ClipboardController.PasteFromClipboard();
+        }
+
+        private bool CanPaste(object property)
+        {
+            return Owner.DocumentIsNotNull(null) && ClipboardController.IsImageInClipboard();
+        }
+
+        private void Copy(object parameter)
+        {
+            ClipboardController.CopyToClipboard(Owner.BitmapManager.ActiveDocument.Layers.ToArray(),
+                Owner.ActiveSelection.SelectedPoints.ToArray(),
+                Owner.BitmapManager.ActiveDocument.Width,
+                Owner.BitmapManager.ActiveDocument.Height);
+        }
+
+    }
+}

+ 87 - 0
PixiEditor/ViewModels/SubViewModels/Main/LayersViewModel.cs

@@ -0,0 +1,87 @@
+using PixiEditor.Helpers;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace PixiEditor.ViewModels.SubViewModels.Main
+{
+    public class LayersViewModel : SubViewModel<ViewModelMain>
+    {
+        public RelayCommand SetActiveLayerCommand { get; set; }
+        public RelayCommand NewLayerCommand { get; set; }
+        public RelayCommand DeleteLayerCommand { get; set; }
+        public RelayCommand RenameLayerCommand { get; set; }
+        public RelayCommand MoveToBackCommand { get; set; }
+        public RelayCommand MoveToFrontCommand { get; set; }
+
+        public LayersViewModel(ViewModelMain owner) : base(owner)
+        {
+            SetActiveLayerCommand = new RelayCommand(SetActiveLayer);
+            NewLayerCommand = new RelayCommand(NewLayer, CanCreateNewLayer);
+            DeleteLayerCommand = new RelayCommand(DeleteLayer, CanDeleteLayer);
+            MoveToBackCommand = new RelayCommand(MoveLayerToBack, CanMoveToBack);
+            MoveToFrontCommand = new RelayCommand(MoveLayerToFront, CanMoveToFront);
+            RenameLayerCommand = new RelayCommand(RenameLayer);
+        }
+
+        public void NewLayer(object parameter)
+        {
+            Owner.BitmapManager.AddNewLayer($"New Layer {Owner.BitmapManager.ActiveDocument.Layers.Count}");
+        }
+
+        public bool CanCreateNewLayer(object parameter)
+        {
+            return Owner.BitmapManager.ActiveDocument != null && Owner.BitmapManager.ActiveDocument.Layers.Count > 0;
+        }
+
+        public void SetActiveLayer(object parameter)
+        {
+            Owner.BitmapManager.SetActiveLayer((int)parameter);
+        }
+
+        public void DeleteLayer(object parameter)
+        {
+            Owner.BitmapManager.RemoveLayer((int)parameter);
+        }
+
+        public bool CanDeleteLayer(object property)
+        {
+            return Owner.BitmapManager.ActiveDocument != null && Owner.BitmapManager.ActiveDocument.Layers.Count > 1;
+        }
+
+        public void RenameLayer(object parameter)
+        {
+            Owner.BitmapManager.ActiveDocument.Layers[(int)parameter].IsRenaming = true;
+        }
+
+        public void MoveLayerToFront(object parameter)
+        {
+            int oldIndex = (int)parameter;
+            Owner.BitmapManager.ActiveDocument.Layers.Move(oldIndex, oldIndex + 1);
+            if (Owner.BitmapManager.ActiveDocument.ActiveLayerIndex == oldIndex)
+            {
+                Owner.BitmapManager.SetActiveLayer(oldIndex + 1);
+            }
+        }
+
+        public void MoveLayerToBack(object parameter)
+        {
+            int oldIndex = (int)parameter;
+            Owner.BitmapManager.ActiveDocument.Layers.Move(oldIndex, oldIndex - 1);
+            if (Owner.BitmapManager.ActiveDocument.ActiveLayerIndex == oldIndex)
+            {
+                Owner.BitmapManager.SetActiveLayer(oldIndex - 1);
+            }
+        }
+
+        public bool CanMoveToFront(object property)
+        {
+            return Owner.DocumentIsNotNull(null) && Owner.BitmapManager.ActiveDocument.Layers.Count - 1 > (int)property;
+        }
+
+        public bool CanMoveToBack(object property)
+        {
+            return (int)property > 0;
+        }
+    }
+}

+ 13 - 0
PixiEditor/ViewModels/SubViewModels/Main/ToolsViewModel.cs

@@ -11,6 +11,8 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
     {
     {
         private Cursor _toolCursor;
         private Cursor _toolCursor;
         public RelayCommand SelectToolCommand { get; set; } //Command that handles tool switching 
         public RelayCommand SelectToolCommand { get; set; } //Command that handles tool switching 
+        public RelayCommand ChangeToolSizeCommand { get; set; }
+
         public Tool LastActionTool { get; private set; }
         public Tool LastActionTool { get; private set; }
         public ObservableCollection<Tool> ToolSet { get; set; }
         public ObservableCollection<Tool> ToolSet { get; set; }
 
 
@@ -28,6 +30,8 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
         public ToolsViewModel(ViewModelMain owner) : base(owner)
         public ToolsViewModel(ViewModelMain owner) : base(owner)
         {
         {
             SelectToolCommand = new RelayCommand(SetTool, Owner.DocumentIsNotNull);
             SelectToolCommand = new RelayCommand(SetTool, Owner.DocumentIsNotNull);
+            ChangeToolSizeCommand = new RelayCommand(ChangeToolSize);
+
             ToolSet = new ObservableCollection<Tool>
             ToolSet = new ObservableCollection<Tool>
             {
             {
                 new MoveViewportTool(), new MoveTool(), new PenTool(), new SelectTool(), new FloodFill(), new LineTool(),
                 new MoveViewportTool(), new MoveTool(), new PenTool(), new SelectTool(), new FloodFill(), new LineTool(),
@@ -37,6 +41,15 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             SetActiveTool(ToolType.Move);
             SetActiveTool(ToolType.Move);
         }
         }
 
 
+        private void ChangeToolSize(object parameter)
+        {
+            int increment = (int)parameter;
+            int newSize = Owner.BitmapManager.ToolSize + increment;
+            if (newSize > 0)
+            {
+                Owner.BitmapManager.ToolSize = newSize;
+            }
+        }
 
 
         public void SetActiveTool(ToolType tool)
         public void SetActiveTool(ToolType tool)
         {
         {

+ 16 - 127
PixiEditor/ViewModels/ViewModelMain.cs

@@ -44,20 +44,10 @@ namespace PixiEditor.ViewModels
 
 
         public static ViewModelMain Current { get; set; }                
         public static ViewModelMain Current { get; set; }                
         public RelayCommand UndoCommand { get; set; }
         public RelayCommand UndoCommand { get; set; }
-        public RelayCommand RedoCommand { get; set; }
-        public RelayCommand SetActiveLayerCommand { get; set; }
-        public RelayCommand NewLayerCommand { get; set; }
-        public RelayCommand DeleteLayerCommand { get; set; }
-        public RelayCommand RenameLayerCommand { get; set; }
-        public RelayCommand MoveToBackCommand { get; set; }
-        public RelayCommand MoveToFrontCommand { get; set; }
+        public RelayCommand RedoCommand { get; set; }       
         public RelayCommand SwapColorsCommand { get; set; }
         public RelayCommand SwapColorsCommand { get; set; }
         public RelayCommand DeselectCommand { get; set; }
         public RelayCommand DeselectCommand { get; set; }
-        public RelayCommand SelectAllCommand { get; set; }
-        public RelayCommand CopyCommand { get; set; }
-        public RelayCommand DuplicateCommand { get; set; }
-        public RelayCommand CutCommand { get; set; }
-        public RelayCommand PasteCommand { get; set; }
+        public RelayCommand SelectAllCommand { get; set; }        
         public RelayCommand ClipCanvasCommand { get; set; }
         public RelayCommand ClipCanvasCommand { get; set; }
         public RelayCommand DeletePixelsCommand { get; set; }
         public RelayCommand DeletePixelsCommand { get; set; }
         public RelayCommand OpenResizePopupCommand { get; set; }
         public RelayCommand OpenResizePopupCommand { get; set; }
@@ -68,12 +58,13 @@ 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; }
         
         
         public FileViewModel FileSubViewModel { get; set; }
         public FileViewModel FileSubViewModel { get; set; }
         public UpdateViewModel UpdateSubViewModel { get; set; }
         public UpdateViewModel UpdateSubViewModel { get; set; }
         public ToolsViewModel ToolsSubViewModel { get; set; }
         public ToolsViewModel ToolsSubViewModel { get; set; }
         public IoViewModel IoSubViewModel { get; set; }
         public IoViewModel IoSubViewModel { get; set; }
+        public LayersViewModel LayersSubViewModel { get; set; }
+        public ClipboardViewModel ClipboardSubViewModel { get; set; }
 
 
 
 
         private double _mouseXonCanvas;
         private double _mouseXonCanvas;
@@ -196,19 +187,9 @@ namespace PixiEditor.ViewModels
             ChangesController = new PixelChangesController();
             ChangesController = new PixelChangesController();
             UndoCommand = new RelayCommand(Undo, CanUndo);
             UndoCommand = new RelayCommand(Undo, CanUndo);
             RedoCommand = new RelayCommand(Redo, CanRedo);
             RedoCommand = new RelayCommand(Redo, CanRedo);
-            SetActiveLayerCommand = new RelayCommand(SetActiveLayer);
-            NewLayerCommand = new RelayCommand(NewLayer, CanCreateNewLayer);
-            DeleteLayerCommand = new RelayCommand(DeleteLayer, CanDeleteLayer);
-            MoveToBackCommand = new RelayCommand(MoveLayerToBack, CanMoveToBack);
-            MoveToFrontCommand = new RelayCommand(MoveLayerToFront, CanMoveToFront);
             SwapColorsCommand = new RelayCommand(SwapColors);
             SwapColorsCommand = new RelayCommand(SwapColors);
-            RenameLayerCommand = new RelayCommand(RenameLayer);
             DeselectCommand = new RelayCommand(Deselect, SelectionIsNotEmpty);
             DeselectCommand = new RelayCommand(Deselect, SelectionIsNotEmpty);
-            SelectAllCommand = new RelayCommand(SelectAll, CanSelectAll);
-            CopyCommand = new RelayCommand(Copy, SelectionIsNotEmpty);
-            DuplicateCommand = new RelayCommand(Duplicate, SelectionIsNotEmpty);
-            CutCommand = new RelayCommand(Cut, SelectionIsNotEmpty);
-            PasteCommand = new RelayCommand(Paste, CanPaste);
+            SelectAllCommand = new RelayCommand(SelectAll, CanSelectAll);            
             ClipCanvasCommand = new RelayCommand(ClipCanvas, DocumentIsNotNull);
             ClipCanvasCommand = new RelayCommand(ClipCanvas, DocumentIsNotNull);
             DeletePixelsCommand = new RelayCommand(DeletePixels, SelectionIsNotEmpty);
             DeletePixelsCommand = new RelayCommand(DeletePixels, SelectionIsNotEmpty);
             OpenResizePopupCommand = new RelayCommand(OpenResizePopup, DocumentIsNotNull);
             OpenResizePopupCommand = new RelayCommand(OpenResizePopup, DocumentIsNotNull);
@@ -219,12 +200,13 @@ 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);
 
 
             FileSubViewModel = new FileViewModel(this);
             FileSubViewModel = new FileViewModel(this);
             UpdateSubViewModel = new UpdateViewModel(this);
             UpdateSubViewModel = new UpdateViewModel(this);
             ToolsSubViewModel = new ToolsViewModel(this);
             ToolsSubViewModel = new ToolsViewModel(this);
             IoSubViewModel = new IoViewModel(this);
             IoSubViewModel = new IoViewModel(this);
+            LayersSubViewModel = new LayersViewModel(this);
+            ClipboardSubViewModel = new ClipboardViewModel(this);
            
            
             ShortcutController = new ShortcutController
             ShortcutController = new ShortcutController
             {
             {
@@ -245,18 +227,18 @@ namespace PixiEditor.ViewModels
                     new Shortcut(Key.H, ToolsSubViewModel.SelectToolCommand, ToolType.MoveViewport),
                     new Shortcut(Key.H, ToolsSubViewModel.SelectToolCommand, ToolType.MoveViewport),
                     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),
+                    new Shortcut(Key.OemOpenBrackets, ToolsSubViewModel.ChangeToolSizeCommand, -1),
+                    new Shortcut(Key.OemCloseBrackets, ToolsSubViewModel.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),
                     new Shortcut(Key.Z, UndoCommand, modifier: ModifierKeys.Control),
                     new Shortcut(Key.Z, UndoCommand, modifier: ModifierKeys.Control),
                     new Shortcut(Key.D, DeselectCommand, modifier: ModifierKeys.Control),
                     new Shortcut(Key.D, DeselectCommand, modifier: ModifierKeys.Control),
                     new Shortcut(Key.A, SelectAllCommand, modifier: ModifierKeys.Control),
                     new Shortcut(Key.A, SelectAllCommand, modifier: ModifierKeys.Control),
-                    new Shortcut(Key.C, CopyCommand, modifier: ModifierKeys.Control),
-                    new Shortcut(Key.V, PasteCommand, modifier: ModifierKeys.Control),
-                    new Shortcut(Key.J, DuplicateCommand, modifier: ModifierKeys.Control),
-                    new Shortcut(Key.X, CutCommand, modifier: ModifierKeys.Control),
+                    new Shortcut(Key.C, ClipboardSubViewModel.CopyCommand, modifier: ModifierKeys.Control),
+                    new Shortcut(Key.V, ClipboardSubViewModel.PasteCommand, modifier: ModifierKeys.Control),
+                    new Shortcut(Key.J, ClipboardSubViewModel.DuplicateCommand, modifier: ModifierKeys.Control),
+                    new Shortcut(Key.X, ClipboardSubViewModel.CutCommand, modifier: ModifierKeys.Control),
                     new Shortcut(Key.Delete, DeletePixelsCommand),
                     new Shortcut(Key.Delete, DeletePixelsCommand),
                     new Shortcut(Key.I, OpenResizePopupCommand, modifier: ModifierKeys.Control | ModifierKeys.Shift),
                     new Shortcut(Key.I, OpenResizePopupCommand, modifier: ModifierKeys.Control | ModifierKeys.Shift),
                     new Shortcut(Key.C, OpenResizePopupCommand, "canvas", ModifierKeys.Control | ModifierKeys.Shift),
                     new Shortcut(Key.C, OpenResizePopupCommand, "canvas", ModifierKeys.Control | ModifierKeys.Shift),
@@ -283,16 +265,6 @@ 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;
@@ -391,36 +363,6 @@ namespace PixiEditor.ViewModels
             BitmapManager.ActiveDocument?.ClipCanvas();
             BitmapManager.ActiveDocument?.ClipCanvas();
         }
         }
 
 
-        public void Duplicate(object parameter)
-        {
-            Copy(null);
-            Paste(null);
-        }
-
-        public void Cut(object parameter)
-        {
-            Copy(null);
-            BitmapManager.ActiveLayer.SetPixels(
-                BitmapPixelChanges.FromSingleColoredArray(ActiveSelection.SelectedPoints.ToArray(),
-                    Colors.Transparent));
-        }
-
-        public void Paste(object parameter)
-        {
-            ClipboardController.PasteFromClipboard();
-        }
-
-        private bool CanPaste(object property)
-        {
-            return DocumentIsNotNull(null) && ClipboardController.IsImageInClipboard();
-        }
-
-        private void Copy(object parameter)
-        {
-            ClipboardController.CopyToClipboard(BitmapManager.ActiveDocument.Layers.ToArray(),
-                ActiveSelection.SelectedPoints.ToArray(), BitmapManager.ActiveDocument.Width, BitmapManager.ActiveDocument.Height);
-        }
-
         public void SelectAll(object parameter)
         public void SelectAll(object parameter)
         {
         {
             SelectTool select = new SelectTool();
             SelectTool select = new SelectTool();
@@ -442,15 +384,12 @@ namespace PixiEditor.ViewModels
             ActiveSelection?.Clear();
             ActiveSelection?.Clear();
         }
         }
 
 
-        private bool SelectionIsNotEmpty(object property)
+        public bool SelectionIsNotEmpty(object property)
         {
         {
             return ActiveSelection?.SelectedPoints != null && ActiveSelection.SelectedPoints.Count > 0;
             return ActiveSelection?.SelectedPoints != null && ActiveSelection.SelectedPoints.Count > 0;
         }
         }
 
 
-        public void RenameLayer(object parameter)
-        {
-            BitmapManager.ActiveDocument.Layers[(int) parameter].IsRenaming = true;
-        }
+        
 
 
         private void MouseController_StoppedRecordingChanges(object sender, EventArgs e)
         private void MouseController_StoppedRecordingChanges(object sender, EventArgs e)
         {
         {
@@ -487,47 +426,7 @@ namespace PixiEditor.ViewModels
             var tmp = PrimaryColor;
             var tmp = PrimaryColor;
             PrimaryColor = SecondaryColor;
             PrimaryColor = SecondaryColor;
             SecondaryColor = tmp;
             SecondaryColor = tmp;
-        }
-
-        public void MoveLayerToFront(object parameter)
-        {
-            int oldIndex = (int) parameter;
-            BitmapManager.ActiveDocument.Layers.Move(oldIndex, oldIndex + 1);
-            if (BitmapManager.ActiveDocument.ActiveLayerIndex == oldIndex) BitmapManager.SetActiveLayer(oldIndex + 1);
-        }
-
-        public void MoveLayerToBack(object parameter)
-        {
-            int oldIndex = (int) parameter;
-            BitmapManager.ActiveDocument.Layers.Move(oldIndex, oldIndex - 1);
-            if (BitmapManager.ActiveDocument.ActiveLayerIndex == oldIndex) BitmapManager.SetActiveLayer(oldIndex - 1);
-        }
-
-        public bool CanMoveToFront(object property)
-        {
-            return DocumentIsNotNull(null) && BitmapManager.ActiveDocument.Layers.Count - 1 > (int) property;
-        }
-
-        public bool CanMoveToBack(object property)
-        {
-            return (int) property > 0;
-        }
-
-        public void SetActiveLayer(object parameter)
-        {
-            BitmapManager.SetActiveLayer((int) parameter);
-        }
-
-        public void DeleteLayer(object parameter)
-        {
-            BitmapManager.RemoveLayer((int) parameter);
-        }
-
-        public bool CanDeleteLayer(object property)
-        {
-            return BitmapManager.ActiveDocument != null && BitmapManager.ActiveDocument.Layers.Count > 1;
-        }
-          
+        }             
 
 
         /// <summary>
         /// <summary>
         ///     Resets most variables and controller, so new documents can be handled.
         ///     Resets most variables and controller, so new documents can be handled.
@@ -543,16 +442,6 @@ namespace PixiEditor.ViewModels
             UnsavedDocumentModified = false;
             UnsavedDocumentModified = false;
         }
         }
 
 
-        public void NewLayer(object parameter)
-        {
-            BitmapManager.AddNewLayer($"New Layer {BitmapManager.ActiveDocument.Layers.Count}");
-        }
-
-        public bool CanCreateNewLayer(object parameter)
-        {
-            return BitmapManager.ActiveDocument != null && BitmapManager.ActiveDocument.Layers.Count > 0;
-        }
-
         #region Undo/Redo
         #region Undo/Redo
 
 
         /// <summary>
         /// <summary>

+ 12 - 12
PixiEditor/Views/MainWindow.xaml

@@ -89,10 +89,10 @@
                     <MenuItem Header="_Undo" InputGestureText="Ctrl+Z" Command="{Binding UndoCommand}" />
                     <MenuItem Header="_Undo" InputGestureText="Ctrl+Z" Command="{Binding UndoCommand}" />
                     <MenuItem Header="_Redo" InputGestureText="Ctrl+Y" Command="{Binding RedoCommand}" />
                     <MenuItem Header="_Redo" InputGestureText="Ctrl+Y" Command="{Binding RedoCommand}" />
                     <Separator />
                     <Separator />
-                    <MenuItem Header="_Cut" Command="{Binding CutCommand}" InputGestureText="Ctrl+X" />
-                    <MenuItem Header="_Copy" Command="{Binding CopyCommand}" InputGestureText="Ctrl+C" />
-                    <MenuItem Header="_Paste" Command="{Binding PasteCommand}" InputGestureText="Ctrl+V" />
-                    <MenuItem Header="_Duplicate" Command="{Binding DuplicateCommand}" InputGestureText="Ctrl+D" />
+                    <MenuItem Header="_Cut" Command="{Binding ClipboardSubViewModel.CutCommand}" InputGestureText="Ctrl+X" />
+                    <MenuItem Header="_Copy" Command="{Binding ClipboardSubViewModel.CopyCommand}" InputGestureText="Ctrl+C" />
+                    <MenuItem Header="_Paste" Command="{Binding ClipboardSubViewModel.PasteCommand}" InputGestureText="Ctrl+V" />
+                    <MenuItem Header="_Duplicate" Command="{Binding ClipboardSubViewModel.DuplicateCommand}" InputGestureText="Ctrl+J" />
                     <Separator />
                     <Separator />
                     <MenuItem Header="_Delete Selected" Command="{Binding DeletePixelsCommand}"
                     <MenuItem Header="_Delete Selected" Command="{Binding DeletePixelsCommand}"
                               InputGestureText="Delete" />
                               InputGestureText="Delete" />
@@ -260,7 +260,7 @@
                                                          CanClose="False" CanAutoHide="False"
                                                          CanClose="False" CanAutoHide="False"
                                                          CanDockAsTabbedDocument="False" CanFloat="True">
                                                          CanDockAsTabbedDocument="False" CanFloat="True">
                                 <StackPanel Orientation="Vertical">
                                 <StackPanel Orientation="Vertical">
-                                    <Button Command="{Binding NewLayerCommand}" Height="30" Content="New Layer"
+                                    <Button Command="{Binding LayersSubViewModel.NewLayerCommand}" Height="30" Content="New Layer"
                                             HorizontalAlignment="Stretch" Margin="5"
                                             HorizontalAlignment="Stretch" Margin="5"
                                             Style="{StaticResource DarkRoundButton}" />
                                             Style="{StaticResource DarkRoundButton}" />
                                     <StackPanel Orientation="Horizontal" Margin="10,0">
                                     <StackPanel Orientation="Horizontal" Margin="10,0">
@@ -281,27 +281,27 @@
                                         <ItemsControl.ItemTemplate>
                                         <ItemsControl.ItemTemplate>
                                             <DataTemplate>
                                             <DataTemplate>
                                                 <vws:LayerItem LayerIndex="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                                                 <vws:LayerItem LayerIndex="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
-                            Path=(ItemsControl.AlternationIndex)}" SetActiveLayerCommand="{Binding Path=DataContext.SetActiveLayerCommand, ElementName=mainWindow}"
+                            Path=(ItemsControl.AlternationIndex)}" SetActiveLayerCommand="{Binding Path=DataContext.LayersSubViewModel.SetActiveLayerCommand, ElementName=mainWindow}"
                                                                LayerName="{Binding Name, Mode=TwoWay}" IsActive="{Binding IsActive, Mode=TwoWay}"
                                                                LayerName="{Binding Name, Mode=TwoWay}" IsActive="{Binding IsActive, Mode=TwoWay}"
                                                                IsRenaming="{Binding IsRenaming, Mode=TwoWay}"
                                                                IsRenaming="{Binding IsRenaming, Mode=TwoWay}"
-                                                               MoveToBackCommand="{Binding DataContext.MoveToBackCommand, ElementName=mainWindow}"
-                                                               MoveToFrontCommand="{Binding DataContext.MoveToFrontCommand, ElementName=mainWindow}">
+                                                               MoveToBackCommand="{Binding DataContext.LayersSubViewModel.MoveToBackCommand, ElementName=mainWindow}"
+                                                               MoveToFrontCommand="{Binding DataContext.LayersSubViewModel.MoveToFrontCommand, ElementName=mainWindow}">
                                                     <vws:LayerItem.ContextMenu>
                                                     <vws:LayerItem.ContextMenu>
                                                         <ContextMenu>
                                                         <ContextMenu>
                                                             <MenuItem Header="Delete"
                                                             <MenuItem Header="Delete"
-                                                                              Command="{Binding DeleteLayerCommand, Source={StaticResource ViewModelMain}}"
+                                                                              Command="{Binding LayersSubViewModel.DeleteLayerCommand, Source={StaticResource ViewModelMain}}"
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                             Path=(ItemsControl.AlternationIndex)}" />
                             Path=(ItemsControl.AlternationIndex)}" />
                                                             <MenuItem Header="Rename"
                                                             <MenuItem Header="Rename"
-                                                                              Command="{Binding RenameLayerCommand, Source={StaticResource ViewModelMain}}"
+                                                                              Command="{Binding LayersSubViewModel.RenameLayerCommand, Source={StaticResource ViewModelMain}}"
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                             Path=(ItemsControl.AlternationIndex)}" />
                             Path=(ItemsControl.AlternationIndex)}" />
                                                             <MenuItem Header="Move to front"
                                                             <MenuItem Header="Move to front"
-                                                                              Command="{Binding MoveToFrontCommand, Source={StaticResource ViewModelMain}}"
+                                                                              Command="{Binding LayersSubViewModel.MoveToFrontCommand, Source={StaticResource ViewModelMain}}"
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                             Path=(ItemsControl.AlternationIndex)}" />
                             Path=(ItemsControl.AlternationIndex)}" />
                                                             <MenuItem Header="Move to back"
                                                             <MenuItem Header="Move to back"
-                                                                              Command="{Binding MoveToBackCommand, Source={StaticResource ViewModelMain}}"
+                                                                              Command="{Binding LayersSubViewModel.MoveToBackCommand, Source={StaticResource ViewModelMain}}"
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
                             Path=(ItemsControl.AlternationIndex)}" />
                             Path=(ItemsControl.AlternationIndex)}" />
                                                         </ContextMenu>
                                                         </ContextMenu>