소스 검색

Extracted IoSubViewModel

flabbet 4 년 전
부모
커밋
a2aa8de7f8

+ 171 - 0
PixiEditor/ViewModels/SubViewModels/Main/FileViewModel.cs

@@ -0,0 +1,171 @@
+using Microsoft.Win32;
+using PixiEditor.Helpers;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Dialogs;
+using PixiEditor.Models.Enums;
+using PixiEditor.Models.IO;
+using System;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+namespace PixiEditor.ViewModels.SubViewModels.Main
+{
+    public class FileViewModel : SubViewModel<ViewModelMain>
+    {
+        public RelayCommand OpenNewFilePopupCommand { get; set; }
+        public RelayCommand SaveDocumentCommand { get; set; }
+        public RelayCommand OpenFileCommand { get; set; }
+        public RelayCommand ExportFileCommand { get; set; } //Command that is used to save file
+
+        public FileViewModel(ViewModelMain owner) : base(owner)
+        {
+            OpenNewFilePopupCommand = new RelayCommand(OpenNewFilePopup);
+            SaveDocumentCommand = new RelayCommand(SaveDocument, Owner.DocumentIsNotNull);
+            OpenFileCommand = new RelayCommand(Open);
+            ExportFileCommand = new RelayCommand(ExportFile, CanSave);
+            Owner.OnStartupEvent += Owner_OnStartupEvent;
+        }
+
+        private void Owner_OnStartupEvent(object sender, System.EventArgs e)
+        {
+            var lastArg = Environment.GetCommandLineArgs().Last();
+            if (Importer.IsSupportedFile(lastArg) && File.Exists(lastArg))
+            {
+                Open(lastArg);
+            }
+            else
+            {
+                OpenNewFilePopup(null);
+            }
+        }
+
+        /// <summary>
+        ///     Generates new Layer and sets it as active one
+        /// </summary>
+        /// <param name="parameter"></param>
+        public void OpenNewFilePopup(object parameter)
+        {
+            NewFileDialog newFile = new NewFileDialog();
+            if (newFile.ShowDialog())
+            {
+                NewDocument(newFile.Width, newFile.Height);
+            }
+        }
+
+        public void NewDocument(int width, int height, bool addBaseLayer = true)
+        {
+            Owner.BitmapManager.ActiveDocument = new Document(width, height);
+            if (addBaseLayer)
+            {
+                Owner.BitmapManager.AddNewLayer("Base Layer");
+            }
+            Owner.ResetProgramStateValues();
+        }
+
+
+        /// <summary>
+        ///     Opens file from path.
+        /// </summary>
+        /// <param name="path"></param>
+        public void OpenFile(string path)
+        {
+            ImportFileDialog dialog = new ImportFileDialog();
+
+            if (path != null && File.Exists(path))
+                dialog.FilePath = path;
+
+            if (dialog.ShowDialog())
+            {
+                NewDocument(dialog.FileWidth, dialog.FileHeight, false);
+                Owner.BitmapManager.AddNewLayer("Image", Importer.ImportImage(dialog.FilePath, dialog.FileWidth, dialog.FileHeight));
+            }
+        }
+
+        private void Open(string path)
+        {
+            if (Owner.UnsavedDocumentModified)
+            {
+                var result = ConfirmationDialog.Show(ViewModelMain.ConfirmationDialogMessage);
+                if (result == ConfirmationType.Yes)
+                {
+                    SaveDocument(null);
+                }
+                else if (result == ConfirmationType.Canceled)
+                {
+                    return;
+                }
+            }
+
+            Owner.ResetProgramStateValues();
+            if (path.EndsWith(".pixi"))
+                OpenDocument(path);
+            else
+                OpenFile(path);
+        }
+
+        private void Open(object property)
+        {
+            OpenFileDialog dialog = new OpenFileDialog
+            {
+                Filter = "All Files|*.*|PixiEditor Files | *.pixi|PNG Files|*.png",
+                DefaultExt = "pixi"
+            };
+            if ((bool)dialog.ShowDialog())
+            {
+                if (Importer.IsSupportedFile(dialog.FileName))
+                    Open(dialog.FileName);
+                Owner.RecenterZoombox = !Owner.RecenterZoombox;
+            }
+        }
+
+        private void OpenDocument(string path)
+        {
+            Owner.BitmapManager.ActiveDocument = Importer.ImportDocument(path);
+            Exporter.SaveDocumentPath = path;
+            Owner.UnsavedDocumentModified = false;
+        }
+
+        public void SaveDocument(bool asNew)
+        {
+            SaveDocument(parameter: asNew ? "asnew" : null);
+        }
+
+        private void SaveDocument(object parameter)
+        {
+            bool paramIsAsNew = parameter != null && parameter.ToString()?.ToLower() == "asnew";
+            if (paramIsAsNew || Exporter.SaveDocumentPath == null)
+            {
+                var saved = Exporter.SaveAsEditableFileWithDialog(Owner.BitmapManager.ActiveDocument, !paramIsAsNew);
+                Owner.UnsavedDocumentModified = Owner.UnsavedDocumentModified && !saved;
+            }
+            else
+            {
+                Exporter.SaveAsEditableFile(Owner.BitmapManager.ActiveDocument, Exporter.SaveDocumentPath);
+                Owner.UnsavedDocumentModified = false;
+            }
+        }
+
+        /// <summary>
+        ///     Generates export dialog or saves directly if save data is known.
+        /// </summary>
+        /// <param name="parameter"></param>
+        private void ExportFile(object parameter)
+        {
+            WriteableBitmap bitmap = Owner.BitmapManager.GetCombinedLayersBitmap();
+            Exporter.Export(bitmap, new Size(bitmap.PixelWidth, bitmap.PixelHeight));
+        }
+
+        /// <summary>
+        ///     Returns true if file save is possible.
+        /// </summary>
+        /// <param name="property"></param>
+        /// <returns></returns>
+        private bool CanSave(object property)
+        {
+            return Owner.BitmapManager.ActiveDocument != null;
+        }
+
+    }
+}

+ 60 - 128
PixiEditor/ViewModels/SubViewModels/Main/IoViewModel.cs

@@ -1,171 +1,103 @@
-using Microsoft.Win32;
-using PixiEditor.Helpers;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Dialogs;
-using PixiEditor.Models.Enums;
-using PixiEditor.Models.IO;
+using PixiEditor.Helpers;
+using PixiEditor.Models.Controllers.Shortcuts;
+using PixiEditor.Models.Position;
 using System;
-using System.IO;
-using System.Linq;
 using System.Windows;
-using System.Windows.Media.Imaging;
+using System.Windows.Input;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main
 {
     public class IoViewModel : SubViewModel<ViewModelMain>
     {
-        public RelayCommand OpenNewFilePopupCommand { get; set; }
-        public RelayCommand SaveDocumentCommand { get; set; }
-        public RelayCommand OpenFileCommand { get; set; }
-        public RelayCommand ExportFileCommand { get; set; } //Command that is used to save file
+        public RelayCommand MouseMoveCommand { get; set; }
+        public RelayCommand MouseDownCommand { get; set; }
+        public RelayCommand KeyDownCommand { get; set; }
+        public RelayCommand KeyUpCommand { get; set; }
+
+        private bool _restoreToolOnKeyUp = false;
 
         public IoViewModel(ViewModelMain owner) : base(owner)
         {
-            OpenNewFilePopupCommand = new RelayCommand(OpenNewFilePopup);
-            SaveDocumentCommand = new RelayCommand(SaveDocument, Owner.DocumentIsNotNull);
-            OpenFileCommand = new RelayCommand(Open);
-            ExportFileCommand = new RelayCommand(ExportFile, CanSave);
-            Owner.OnStartupEvent += Owner_OnStartupEvent;
+            MouseMoveCommand = new RelayCommand(MouseMove);
+            MouseDownCommand = new RelayCommand(MouseDown);
+            KeyDownCommand = new RelayCommand(KeyDown);
+            KeyUpCommand = new RelayCommand(KeyUp);
         }
 
-        private void Owner_OnStartupEvent(object sender, System.EventArgs e)
+        public void MouseHook_OnMouseUp(object sender, Point p, MouseButton button)
         {
-            var lastArg = Environment.GetCommandLineArgs().Last();
-            if (Importer.IsSupportedFile(lastArg) && File.Exists(lastArg))
-            {
-                Open(lastArg);
-            }
-            else
+            GlobalMouseHook.OnMouseUp -= MouseHook_OnMouseUp;
+            if (button == MouseButton.Left)
             {
-                OpenNewFilePopup(null);
+                Owner.BitmapManager.MouseController.StopRecordingMouseMovementChanges();
             }
+            Owner.BitmapManager.MouseController.MouseUp(new MouseEventArgs(Mouse.PrimaryDevice,
+                (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
         }
 
-        /// <summary>
-        ///     Generates new Layer and sets it as active one
-        /// </summary>
-        /// <param name="parameter"></param>
-        public void OpenNewFilePopup(object parameter)
+        private void MouseDown(object parameter)
         {
-            NewFileDialog newFile = new NewFileDialog();
-            if (newFile.ShowDialog())
+            if (Owner.BitmapManager.ActiveDocument.Layers.Count == 0) return;
+            if (Mouse.LeftButton == MouseButtonState.Pressed)
             {
-                NewDocument(newFile.Width, newFile.Height);
+                if (!Owner.BitmapManager.MouseController.IsRecordingChanges)
+                {
+                    bool clickedOnCanvas = Owner.MouseXOnCanvas >= 0 &&
+                        Owner.MouseXOnCanvas <= Owner.BitmapManager.ActiveDocument.Width &&
+                        Owner.MouseYOnCanvas >= 0 && 
+                        Owner.MouseYOnCanvas <= Owner.BitmapManager.ActiveDocument.Height;
+                    Owner.BitmapManager.MouseController.StartRecordingMouseMovementChanges(clickedOnCanvas);
+                    Owner.BitmapManager.MouseController.RecordMouseMovementChange(MousePositionConverter.CurrentCoordinates);
+                }
             }
-        }
+            Owner.BitmapManager.MouseController.MouseDown(new MouseEventArgs(Mouse.PrimaryDevice,
+                (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
 
-        public void NewDocument(int width, int height, bool addBaseLayer = true)
-        {
-            Owner.BitmapManager.ActiveDocument = new Document(width, height);
-            if (addBaseLayer)
-            {
-                Owner.BitmapManager.AddNewLayer("Base Layer");
-            }
-            Owner.ResetProgramStateValues();
+            // Mouse down is guaranteed to only be raised from within this application, so by subscribing here we
+            // only listen for mouse up events that occurred as a result of a mouse down within this application.
+            // This seems better than maintaining a global listener indefinitely.
+            GlobalMouseHook.OnMouseUp += MouseHook_OnMouseUp;
         }
 
-
         /// <summary>
-        ///     Opens file from path.
+        ///     Method connected with command, it executes tool "activity"
         /// </summary>
-        /// <param name="path"></param>
-        public void OpenFile(string path)
+        /// <param name="parameter"></param>
+        private void MouseMove(object parameter)
         {
-            ImportFileDialog dialog = new ImportFileDialog();
+            Coordinates cords = new Coordinates((int)Owner.MouseXOnCanvas, (int)Owner.MouseYOnCanvas);
+            MousePositionConverter.CurrentCoordinates = cords;
 
-            if (path != null && File.Exists(path))
-                dialog.FilePath = path;
 
-            if (dialog.ShowDialog())
+            if (Owner.BitmapManager.MouseController.IsRecordingChanges && Mouse.LeftButton == MouseButtonState.Pressed)
             {
-                NewDocument(dialog.FileWidth, dialog.FileHeight, false);
-                Owner.BitmapManager.AddNewLayer("Image", Importer.ImportImage(dialog.FilePath, dialog.FileWidth, dialog.FileHeight));
+                Owner.BitmapManager.MouseController.RecordMouseMovementChange(cords);
             }
+            Owner.BitmapManager.MouseController.MouseMoved(cords);
         }
 
-        private void Open(string path)
+        private void KeyUp(object parameter)
         {
-            if (Owner.UnsavedDocumentModified)
+            KeyEventArgs args = (KeyEventArgs)parameter;
+            if (_restoreToolOnKeyUp && Owner.ShortcutController.LastShortcut != null &&
+                Owner.ShortcutController.LastShortcut.ShortcutKey == args.Key)
             {
-                var result = ConfirmationDialog.Show(ViewModelMain.ConfirmationDialogMessage);
-                if (result == ConfirmationType.Yes)
-                {
-                    SaveDocument(null);
-                }
-                else if (result == ConfirmationType.Canceled)
-                {
-                    return;
-                }
+                _restoreToolOnKeyUp = false;
+                Owner.ToolsSubViewModel.SetActiveTool(Owner.ToolsSubViewModel.LastActionTool);
+                ShortcutController.BlockShortcutExecution = false;
             }
-
-            Owner.ResetProgramStateValues();
-            if (path.EndsWith(".pixi"))
-                OpenDocument(path);
-            else
-                OpenFile(path);
         }
 
-        private void Open(object property)
+        public void KeyDown(object parameter)
         {
-            OpenFileDialog dialog = new OpenFileDialog
-            {
-                Filter = "All Files|*.*|PixiEditor Files | *.pixi|PNG Files|*.png",
-                DefaultExt = "pixi"
-            };
-            if ((bool)dialog.ShowDialog())
+            KeyEventArgs args = (KeyEventArgs)parameter;
+            if (args.IsRepeat && !_restoreToolOnKeyUp && Owner.ShortcutController.LastShortcut != null &&
+                Owner.ShortcutController.LastShortcut.Command == Owner.ToolsSubViewModel.SelectToolCommand)
             {
-                if (Importer.IsSupportedFile(dialog.FileName))
-                    Open(dialog.FileName);
-                Owner.RecenterZoombox = !Owner.RecenterZoombox;
+                _restoreToolOnKeyUp = true;
+                ShortcutController.BlockShortcutExecution = true;
             }
+            Owner.ShortcutController.KeyPressed(args.Key, Keyboard.Modifiers);
         }
-
-        private void OpenDocument(string path)
-        {
-            Owner.BitmapManager.ActiveDocument = Importer.ImportDocument(path);
-            Exporter.SaveDocumentPath = path;
-            Owner.UnsavedDocumentModified = false;
-        }
-
-        public void SaveDocument(bool asNew)
-        {
-            SaveDocument(parameter: asNew ? "asnew" : null);
-        }
-
-        private void SaveDocument(object parameter)
-        {
-            bool paramIsAsNew = parameter != null && parameter.ToString()?.ToLower() == "asnew";
-            if (paramIsAsNew || Exporter.SaveDocumentPath == null)
-            {
-                var saved = Exporter.SaveAsEditableFileWithDialog(Owner.BitmapManager.ActiveDocument, !paramIsAsNew);
-                Owner.UnsavedDocumentModified = Owner.UnsavedDocumentModified && !saved;
-            }
-            else
-            {
-                Exporter.SaveAsEditableFile(Owner.BitmapManager.ActiveDocument, Exporter.SaveDocumentPath);
-                Owner.UnsavedDocumentModified = false;
-            }
-        }
-
-        /// <summary>
-        ///     Generates export dialog or saves directly if save data is known.
-        /// </summary>
-        /// <param name="parameter"></param>
-        private void ExportFile(object parameter)
-        {
-            WriteableBitmap bitmap = Owner.BitmapManager.GetCombinedLayersBitmap();
-            Exporter.Export(bitmap, new Size(bitmap.PixelWidth, bitmap.PixelHeight));
-        }
-
-        /// <summary>
-        ///     Returns true if file save is possible.
-        /// </summary>
-        /// <param name="property"></param>
-        /// <returns></returns>
-        private bool CanSave(object property)
-        {
-            return Owner.BitmapManager.ActiveDocument != null;
-        }
-
     }
 }

+ 12 - 93
PixiEditor/ViewModels/ViewModelMain.cs

@@ -42,11 +42,7 @@ namespace PixiEditor.ViewModels
 
         public Action CloseAction { get; set; }
 
-        public static ViewModelMain Current { get; set; }        
-        public RelayCommand MouseMoveCommand { get; set; }
-        public RelayCommand MouseDownCommand { get; set; }
-        public RelayCommand KeyDownCommand { get; set; }
-        public RelayCommand KeyUpCommand { get; set; }
+        public static ViewModelMain Current { get; set; }                
         public RelayCommand UndoCommand { get; set; }
         public RelayCommand RedoCommand { get; set; }
         public RelayCommand SetActiveLayerCommand { get; set; }
@@ -74,9 +70,10 @@ namespace PixiEditor.ViewModels
         public RelayCommand ZoomCommand { get; set; }
         public RelayCommand ChangeToolSizeCommand { get; set; }
         
-        public IoViewModel IoSubViewModel { get; set; }
+        public FileViewModel FileSubViewModel { get; set; }
         public UpdateViewModel UpdateSubViewModel { get; set; }
         public ToolsViewModel ToolsSubViewModel { get; set; }
+        public IoViewModel IoSubViewModel { get; set; }
 
 
         private double _mouseXonCanvas;
@@ -190,8 +187,6 @@ namespace PixiEditor.ViewModels
             }
         }
 
-        private bool _restoreToolOnKeyUp = false;
-
         public ViewModelMain()
         {
             BitmapManager = new BitmapManager();
@@ -199,8 +194,6 @@ namespace PixiEditor.ViewModels
             BitmapManager.MouseController.StoppedRecordingChanges += MouseController_StoppedRecordingChanges;
             BitmapManager.DocumentChanged += BitmapManager_DocumentChanged;
             ChangesController = new PixelChangesController();
-            MouseMoveCommand = new RelayCommand(MouseMove);
-            MouseDownCommand = new RelayCommand(MouseDown);
             UndoCommand = new RelayCommand(Undo, CanUndo);
             RedoCommand = new RelayCommand(Redo, CanRedo);
             SetActiveLayerCommand = new RelayCommand(SetActiveLayer);
@@ -209,8 +202,6 @@ namespace PixiEditor.ViewModels
             MoveToBackCommand = new RelayCommand(MoveLayerToBack, CanMoveToBack);
             MoveToFrontCommand = new RelayCommand(MoveLayerToFront, CanMoveToFront);
             SwapColorsCommand = new RelayCommand(SwapColors);
-            KeyDownCommand = new RelayCommand(KeyDown);
-            KeyUpCommand = new RelayCommand(KeyUp);
             RenameLayerCommand = new RelayCommand(RenameLayer);
             DeselectCommand = new RelayCommand(Deselect, SelectionIsNotEmpty);
             SelectAllCommand = new RelayCommand(SelectAll, CanSelectAll);
@@ -230,9 +221,10 @@ namespace PixiEditor.ViewModels
             ZoomCommand = new RelayCommand(ZoomViewport);
             ChangeToolSizeCommand = new RelayCommand(ChangeToolSize);
 
-            IoSubViewModel = new IoViewModel(this);
+            FileSubViewModel = new FileViewModel(this);
             UpdateSubViewModel = new UpdateViewModel(this);
             ToolsSubViewModel = new ToolsViewModel(this);
+            IoSubViewModel = new IoViewModel(this);
            
             ShortcutController = new ShortcutController
             {
@@ -270,12 +262,12 @@ namespace PixiEditor.ViewModels
                     new Shortcut(Key.C, OpenResizePopupCommand, "canvas", ModifierKeys.Control | ModifierKeys.Shift),
                     new Shortcut(Key.F11, SystemCommands.MaximizeWindowCommand),
                     //File
-                    new Shortcut(Key.O, IoSubViewModel.OpenFileCommand, modifier: ModifierKeys.Control),
-                    new Shortcut(Key.S, IoSubViewModel.ExportFileCommand,
+                    new Shortcut(Key.O, FileSubViewModel.OpenFileCommand, modifier: ModifierKeys.Control),
+                    new Shortcut(Key.S, FileSubViewModel.ExportFileCommand,
                         modifier: ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt),
-                    new Shortcut(Key.S, IoSubViewModel.SaveDocumentCommand, modifier: ModifierKeys.Control),
-                    new Shortcut(Key.S, IoSubViewModel.SaveDocumentCommand, "AsNew", ModifierKeys.Control | ModifierKeys.Shift),
-                    new Shortcut(Key.N, IoSubViewModel.OpenNewFilePopupCommand, modifier: ModifierKeys.Control),
+                    new Shortcut(Key.S, FileSubViewModel.SaveDocumentCommand, modifier: ModifierKeys.Control),
+                    new Shortcut(Key.S, FileSubViewModel.SaveDocumentCommand, "AsNew", ModifierKeys.Control | ModifierKeys.Shift),
+                    new Shortcut(Key.N, FileSubViewModel.OpenNewFilePopupCommand, modifier: ModifierKeys.Control),
                 }
             };
             UndoManager.SetMainRoot(this);
@@ -330,7 +322,7 @@ namespace PixiEditor.ViewModels
                 result = ConfirmationDialog.Show(ConfirmationDialogMessage);
                 if (result == ConfirmationType.Yes) 
                 {
-                    IoSubViewModel.SaveDocument(false); 
+                    FileSubViewModel.SaveDocument(false); 
                 }
             }
 
@@ -460,29 +452,6 @@ namespace PixiEditor.ViewModels
             BitmapManager.ActiveDocument.Layers[(int) parameter].IsRenaming = true;
         }
 
-        private void KeyUp(object parameter)
-        {
-            KeyEventArgs args = (KeyEventArgs)parameter;
-            if (_restoreToolOnKeyUp && ShortcutController.LastShortcut != null && ShortcutController.LastShortcut.ShortcutKey == args.Key)
-            {
-                _restoreToolOnKeyUp = false;
-                ToolsSubViewModel.SetActiveTool(ToolsSubViewModel.LastActionTool);
-                ShortcutController.BlockShortcutExecution = false;
-            }
-        }
-
-        public void KeyDown(object parameter)
-        {
-            KeyEventArgs args = (KeyEventArgs)parameter;
-            if (args.IsRepeat && !_restoreToolOnKeyUp && ShortcutController.LastShortcut != null &&
-                ShortcutController.LastShortcut.Command == ToolsSubViewModel.SelectToolCommand)
-            {
-                _restoreToolOnKeyUp = true;
-                ShortcutController.BlockShortcutExecution = true;
-            }
-            ShortcutController.KeyPressed(args.Key, Keyboard.Modifiers);
-        }
-
         private void MouseController_StoppedRecordingChanges(object sender, EventArgs e)
         {
            TriggerNewUndoChange(BitmapManager.SelectedTool);
@@ -558,57 +527,7 @@ namespace PixiEditor.ViewModels
         {
             return BitmapManager.ActiveDocument != null && BitmapManager.ActiveDocument.Layers.Count > 1;
         }
-
-        private void MouseDown(object parameter)
-        {
-            if (BitmapManager.ActiveDocument.Layers.Count == 0) return;
-            if (Mouse.LeftButton == MouseButtonState.Pressed)
-            {
-                if (!BitmapManager.MouseController.IsRecordingChanges)
-                {
-                    bool clickedOnCanvas = MouseXOnCanvas >= 0 && MouseXOnCanvas <= BitmapManager.ActiveDocument.Width &&
-                        MouseYOnCanvas >= 0 && MouseYOnCanvas <= BitmapManager.ActiveDocument.Height;
-                    BitmapManager.MouseController.StartRecordingMouseMovementChanges(clickedOnCanvas);
-                    BitmapManager.MouseController.RecordMouseMovementChange(MousePositionConverter.CurrentCoordinates);
-                }
-            }
-            BitmapManager.MouseController.MouseDown(new MouseEventArgs(Mouse.PrimaryDevice,
-                (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
-
-            // Mouse down is guaranteed to only be raised from within this application, so by subscribing here we
-            // only listen for mouse up events that occurred as a result of a mouse down within this application.
-            // This seems better than maintaining a global listener indefinitely.
-            GlobalMouseHook.OnMouseUp += MouseHook_OnMouseUp;
-        }
-
-        // this is public for testing.
-        public void MouseHook_OnMouseUp(object sender, Point p, MouseButton button)
-        {
-            GlobalMouseHook.OnMouseUp -= MouseHook_OnMouseUp;
-            if (button == MouseButton.Left)
-            {
-                BitmapManager.MouseController.StopRecordingMouseMovementChanges();
-            }
-            BitmapManager.MouseController.MouseUp(new MouseEventArgs(Mouse.PrimaryDevice, 
-                (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
-        }
-
-        /// <summary>
-        ///     Method connected with command, it executes tool "activity"
-        /// </summary>
-        /// <param name="parameter"></param>
-        private void MouseMove(object parameter)
-        {
-            Coordinates cords = new Coordinates((int)MouseXOnCanvas, (int)MouseYOnCanvas);
-            MousePositionConverter.CurrentCoordinates = cords;
-
-
-            if (BitmapManager.MouseController.IsRecordingChanges && Mouse.LeftButton == MouseButtonState.Pressed)
-            {
-                BitmapManager.MouseController.RecordMouseMovementChange(cords);
-            }
-                BitmapManager.MouseController.MouseMoved(cords);
-        }
+          
 
         /// <summary>
         ///     Resets most variables and controller, so new documents can be handled.

+ 9 - 12
PixiEditor/Views/MainWindow.xaml

@@ -42,10 +42,10 @@
 
     <i:Interaction.Triggers>
         <i:EventTrigger EventName="KeyDown">
-            <cmd:EventToCommand Command="{Binding KeyDownCommand}" PassEventArgsToCommand="True" />
+            <cmd:EventToCommand Command="{Binding IoSubViewModel.KeyDownCommand}" PassEventArgsToCommand="True" />
         </i:EventTrigger>
         <i:EventTrigger EventName="KeyUp">
-            <cmd:EventToCommand Command="{Binding KeyUpCommand}" PassEventArgsToCommand="True"/>
+            <cmd:EventToCommand Command="{Binding IoSubViewModel.KeyUpCommand}" PassEventArgsToCommand="True"/>
         </i:EventTrigger>
         <i:EventTrigger EventName="ContentRendered">
             <i:InvokeCommandAction Command="{Binding OnStartupCommand}" />
@@ -76,12 +76,12 @@
                     <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource menuItemStyle}" />
                 </Menu.Resources>
                 <MenuItem Header="_File">
-                    <MenuItem InputGestureText="CTRL+N" Header="_New" Command="{Binding IoSubViewModel.OpenNewFilePopupCommand}" />
-                    <MenuItem Header="_Open" InputGestureText="Ctrl+O" Command="{Binding IoSubViewModel.OpenFileCommand}" />
-                    <MenuItem Header="_Save" InputGestureText="Ctrl+S" Command="{Binding IoSubViewModel.SaveDocumentCommand}" />
+                    <MenuItem InputGestureText="CTRL+N" Header="_New" Command="{Binding FileSubViewModel.OpenNewFilePopupCommand}" />
+                    <MenuItem Header="_Open" InputGestureText="Ctrl+O" Command="{Binding FileSubViewModel.OpenFileCommand}" />
+                    <MenuItem Header="_Save" InputGestureText="Ctrl+S" Command="{Binding FileSubViewModel.SaveDocumentCommand}" />
                     <MenuItem Header="_Save As..." InputGestureText="Ctrl+Shift+S"
-                              Command="{Binding IoSubViewModel.SaveDocumentCommand}" CommandParameter="AsNew" />
-                    <MenuItem Header="_Export" InputGestureText="Ctrl+Shift+Alt+S" Command="{Binding IoSubViewModel.ExportFileCommand}" />
+                              Command="{Binding FileSubViewModel.SaveDocumentCommand}" CommandParameter="AsNew" />
+                    <MenuItem Header="_Export" InputGestureText="Ctrl+Shift+Alt+S" Command="{Binding FileSubViewModel.ExportFileCommand}" />
                     <Separator />
                     <MenuItem Header="_Exit" Command="{x:Static SystemCommands.CloseWindowCommand}" />
                 </MenuItem>
@@ -169,13 +169,10 @@
                                       ViewportPosition="{Binding ViewportPosition, Mode=TwoWay}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="MouseMove">
-                            <i:InvokeCommandAction Command="{Binding MouseMoveCommand}" />
-                        </i:EventTrigger>
-                        <i:EventTrigger EventName="MouseUp">
-                            <i:InvokeCommandAction Command="{Binding MouseUpCommand}" />
+                            <i:InvokeCommandAction Command="{Binding IoSubViewModel.MouseMoveCommand}" />
                         </i:EventTrigger>
                         <i:EventTrigger EventName="MouseDown">
-                            <i:InvokeCommandAction Command="{Binding MouseDownCommand}"/>
+                            <i:InvokeCommandAction Command="{Binding IoSubViewModel.MouseDownCommand}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                     <i:Interaction.Behaviors>

+ 2 - 2
PixiEditorTests/ViewModelsTests/ViewModelMainTests.cs

@@ -46,7 +46,7 @@ namespace PixiEditorTests.ViewModelsTests
         {
             ViewModelMain viewModel = new ViewModelMain();
 
-            viewModel.IoSubViewModel.NewDocument(5,5);
+            viewModel.FileSubViewModel.NewDocument(5,5);
 
             Assert.NotNull(viewModel.BitmapManager.ActiveDocument);
             Assert.Single(viewModel.BitmapManager.ActiveDocument.Layers);
@@ -117,7 +117,7 @@ namespace PixiEditorTests.ViewModelsTests
 
             Exporter.SaveDocumentPath = fileName;
 
-            viewModel.IoSubViewModel.SaveDocumentCommand.Execute(null);
+            viewModel.FileSubViewModel.SaveDocumentCommand.Execute(null);
 
             Assert.True(File.Exists(fileName));