Browse Source

Auto-fixed spacing problems

ArtemK123 4 years ago
parent
commit
5746cb0c72

+ 9 - 15
PixiEditor.UpdateInstaller/ViewModelMain.cs

@@ -1,31 +1,25 @@
-using PixiEditor.UpdateModule;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
+using System;
 using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
+using PixiEditor.UpdateModule;
 
 namespace PixiEditor.UpdateInstaller
 {
     public class ViewModelMain : ViewModelBase
     {
         public ViewModelMain Current { get; private set; }
+
         public UpdateModule.UpdateInstaller Installer { get; set; }
 
         public string UpdateDirectory { get; private set; }
 
-        private float _progressValue;
+        private float progressValue;
 
         public float ProgressValue
         {
-            get => _progressValue;
-            set 
-            { 
-                _progressValue = value;
+            get => progressValue;
+            set
+            {
+                progressValue = value;
                 RaisePropertyChanged(nameof(ProgressValue));
             }
         }
@@ -63,4 +57,4 @@ namespace PixiEditor.UpdateInstaller
             ProgressValue = e.Progress;
         }
     }
-}
+}

+ 3 - 2
PixiEditor.UpdateModule/UpdateDownloader.cs

@@ -9,7 +9,8 @@ namespace PixiEditor.UpdateModule
 {
     public static class UpdateDownloader
     {
-        public static string DownloadLocation = Path.Join(Path.GetTempPath(), "PixiEditor");
+        public static string DownloadLocation { get; } = Path.Join(Path.GetTempPath(), "PixiEditor");
+
         public static async Task DownloadReleaseZip(ReleaseInfo release)
         {
             Asset matchingAsset = GetMatchingAsset(release);
@@ -43,4 +44,4 @@ namespace PixiEditor.UpdateModule
             && x.Name.Contains(arch));
         }
     }
-}
+}

+ 10 - 5
PixiEditor.UpdateModule/UpdateInstaller.cs

@@ -11,17 +11,21 @@ namespace PixiEditor.UpdateModule
         public static string UpdateFilesPath = Path.Join(UpdateDownloader.DownloadLocation, TargetDirectoryName);
 
         public event EventHandler<UpdateProgressChangedEventArgs> ProgressChanged;
-        private float _progress = 0;
-        public float Progress 
+
+        private float progress = 0;
+
+        public float Progress
         {
-            get => _progress;
+            get => progress;
             set
             {
-                _progress = value;
+                progress = value;
                 ProgressChanged?.Invoke(this, new UpdateProgressChangedEventArgs(value));
             }
         }
+
         public string ArchiveFileName { get; set; }
+
         public string TargetDirectory { get; set; }
 
         public UpdateInstaller(string archiveFileName, string targetDirectory)
@@ -37,6 +41,7 @@ namespace PixiEditor.UpdateModule
             {
                 processes[0].WaitForExit();
             }
+
             ZipFile.ExtractToDirectory(ArchiveFileName, UpdateFilesPath, true);
             Progress = 25; //25% for unzip
             string dirWithFiles = Directory.GetDirectories(UpdateFilesPath)[0];
@@ -64,4 +69,4 @@ namespace PixiEditor.UpdateModule
             }
         }
     }
-}
+}

+ 28 - 24
PixiEditor/Helpers/GlobalMouseHook.cs

@@ -13,10 +13,12 @@ namespace PixiEditor.Helpers
     public static class GlobalMouseHook
     {
         private delegate int HookProc(int nCode, int wParam, IntPtr lParam);
-        private static int _mouseHookHandle;
-        private static HookProc _mouseDelegate;
+
+        private static int mouseHookHandle;
+        private static HookProc mouseDelegate;
 
         private static event MouseUpEventHandler MouseUp;
+
         public static event MouseUpEventHandler OnMouseUp
         {
             add
@@ -24,6 +26,7 @@ namespace PixiEditor.Helpers
                 Subscribe();
                 MouseUp += value;
             }
+
             remove
             {
                 MouseUp -= value;
@@ -38,11 +41,11 @@ namespace PixiEditor.Helpers
 
         private static void Unsubscribe()
         {
-            if (_mouseHookHandle != 0)
+            if (mouseHookHandle != 0)
             {
-                int result = UnhookWindowsHookEx(_mouseHookHandle);
-                _mouseHookHandle = 0;
-                _mouseDelegate = null;
+                int result = UnhookWindowsHookEx(mouseHookHandle);
+                mouseHookHandle = 0;
+                mouseDelegate = null;
                 if (result == 0)
                 {
                     int errorCode = Marshal.GetLastWin32Error();
@@ -53,15 +56,15 @@ namespace PixiEditor.Helpers
 
         private static void Subscribe()
         {
-            if (_mouseHookHandle == 0)
+            if (mouseHookHandle == 0)
             {
-                _mouseDelegate = MouseHookProc;
-                _mouseHookHandle = SetWindowsHookEx(
+                mouseDelegate = MouseHookProc;
+                mouseHookHandle = SetWindowsHookEx(
                     WH_MOUSE_LL,
-                    _mouseDelegate,
+                    mouseDelegate,
                     GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName),
                     0);
-                if (_mouseHookHandle == 0)
+                if (mouseHookHandle == 0)
                 {
                     int errorCode = Marshal.GetLastWin32Error();
                     throw new Win32Exception(errorCode);
@@ -80,11 +83,12 @@ namespace PixiEditor.Helpers
                     {
                         MouseButton button = wParam == WM_LBUTTONUP ? MouseButton.Left
                             : wParam == WM_MBUTTONUP ? MouseButton.Middle : MouseButton.Right;
-                        MouseUp.Invoke(null, new Point(mouseHookStruct.pt.x, mouseHookStruct.pt.y), button);
+                        MouseUp.Invoke(null, new Point(mouseHookStruct.Pt.X, mouseHookStruct.Pt.Y), button);
                     }
                 }
             }
-            return CallNextHookEx(_mouseHookHandle, nCode, wParam, lParam);
+
+            return CallNextHookEx(mouseHookHandle, nCode, wParam, lParam);
         }
 
         private const int WH_MOUSE_LL = 14;
@@ -95,23 +99,23 @@ namespace PixiEditor.Helpers
         [StructLayout(LayoutKind.Sequential)]
         private struct POINT
         {
-            public int x;
-            public int y;
+            public int X;
+            public int Y;
         }
 
         [StructLayout(LayoutKind.Sequential)]
         private struct MSLLHOOKSTRUCT
         {
-            public POINT pt;
-            public uint mouseData;
-            public uint flags;
-            public uint time;
-            public IntPtr dwExtraInfo;
+            public POINT Pt;
+            public uint MouseData;
+            public uint Flags;
+            public uint Time;
+            public IntPtr DwExtraInfo;
         }
 
-        [DllImport("user32.dll", 
+        [DllImport("user32.dll",
             CharSet = CharSet.Auto,
-            CallingConvention = CallingConvention.StdCall, 
+            CallingConvention = CallingConvention.StdCall,
             SetLastError = true)]
         private static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hMod, int dwThreadId);
 
@@ -123,7 +127,7 @@ namespace PixiEditor.Helpers
         private static extern int UnhookWindowsHookEx(int idHook);
 
         [DllImport(
-            "user32.dll", 
+            "user32.dll",
             CharSet = CharSet.Auto,
             CallingConvention = CallingConvention.StdCall)]
         private static extern int CallNextHookEx(int idHook, int nCode, int wParam, IntPtr lParam);
@@ -133,4 +137,4 @@ namespace PixiEditor.Helpers
     }
 
     public delegate void MouseUpEventHandler(object sender, Point p, MouseButton button);
-}
+}

+ 49 - 29
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -23,20 +23,20 @@ namespace PixiEditor.Models.Controllers
 
         public Tool SelectedTool
         {
-            get => _selectedTool;
+            get => selectedTool;
             private set
             {
-                _selectedTool = value;
+                selectedTool = value;
                 RaisePropertyChanged("SelectedTool");
             }
         }
 
         public Layer PreviewLayer
         {
-            get => _previewLayer;
+            get => previewLayer;
             set
             {
-                _previewLayer = value;
+                previewLayer = value;
                 RaisePropertyChanged("PreviewLayer");
             }
         }
@@ -61,23 +61,24 @@ namespace PixiEditor.Models.Controllers
         }
 
         public BitmapOperationsUtility BitmapOperations { get; set; }
+
         public ReadonlyToolUtility ReadonlyToolUtility { get; set; }
 
         public Document ActiveDocument
         {
-            get => _activeDocument;
+            get => activeDocument;
             set
             {
-                _activeDocument = value;
+                activeDocument = value;
                 RaisePropertyChanged("ActiveDocument");
                 DocumentChanged?.Invoke(this, new DocumentChangedEventArgs(value));
             }
         }
 
-        private Document _activeDocument;
+        private Document activeDocument;
 
-        private Layer _previewLayer;
-        private Tool _selectedTool;
+        private Layer previewLayer;
+        private Tool selectedTool;
 
         public BitmapManager()
         {
@@ -92,6 +93,7 @@ namespace PixiEditor.Models.Controllers
         }
 
         public event EventHandler<LayersChangedEventArgs> LayersChanged;
+
         public event EventHandler<DocumentChangedEventArgs> DocumentChanged;
 
         private void MouseController_OnMouseDown(object sender, MouseEventArgs e)
@@ -114,8 +116,11 @@ namespace PixiEditor.Models.Controllers
 
         public void SetActiveLayer(int index)
         {
-            if (ActiveDocument.ActiveLayerIndex <= ActiveDocument.Layers.Count - 1)
-                ActiveDocument.ActiveLayer.IsActive = false;
+            if (ActiveDocument.ActiveLayerIndex <= ActiveDocument.Layers.Count - 1)
+            {
+                ActiveDocument.ActiveLayer.IsActive = false;
+            }
+
             ActiveDocument.ActiveLayerIndex = index;
             ActiveDocument.ActiveLayer.IsActive = true;
             LayersChanged?.Invoke(this, new LayersChangedEventArgs(index, LayerAction.SetActive));
@@ -139,20 +144,31 @@ namespace PixiEditor.Models.Controllers
                 MaxHeight = ActiveDocument.Height,
                 MaxWidth = ActiveDocument.Width
             });
-            if (setAsActive) SetActiveLayer(ActiveDocument.Layers.Count - 1);
+            if (setAsActive)
+            {
+                SetActiveLayer(ActiveDocument.Layers.Count - 1);
+            }
+
             LayersChanged?.Invoke(this, new LayersChangedEventArgs(0, LayerAction.Add));
         }
 
         public void RemoveLayer(int layerIndex)
         {
-            if (ActiveDocument.Layers.Count == 0) return;
-
+            if (ActiveDocument.Layers.Count == 0)
+            {
+                return;
+            }
+
             bool wasActive = ActiveDocument.Layers[layerIndex].IsActive;
             ActiveDocument.Layers.RemoveAt(layerIndex);
-            if (wasActive)
-                SetActiveLayer(0);
-            else if (ActiveDocument.ActiveLayerIndex > ActiveDocument.Layers.Count - 1)
-                SetActiveLayer(ActiveDocument.Layers.Count - 1);
+            if (wasActive)
+            {
+                SetActiveLayer(0);
+            }
+            else if (ActiveDocument.ActiveLayerIndex > ActiveDocument.Layers.Count - 1)
+            {
+                SetActiveLayer(ActiveDocument.Layers.Count - 1);
+            }
         }
 
         private void Controller_MousePositionChanged(object sender, MouseMovementEventArgs e)
@@ -160,7 +176,7 @@ namespace PixiEditor.Models.Controllers
             SelectedTool.OnMouseMove(new MouseEventArgs(Mouse.PrimaryDevice, (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
             if (Mouse.LeftButton == MouseButtonState.Pressed && !IsDraggingViewport() && ActiveDocument != null)
             {
-                ExecuteTool(e.NewPosition, MouseController.ClickedOnCanvas);   
+                ExecuteTool(e.NewPosition, MouseController.ClickedOnCanvas);
             }
             else if (Mouse.LeftButton == MouseButtonState.Released)
             {
@@ -199,8 +215,10 @@ namespace PixiEditor.Models.Controllers
         private void MouseController_StoppedRecordingChanges(object sender, EventArgs e)
         {
             SelectedTool.OnStoppedRecordingMouseUp(new MouseEventArgs(Mouse.PrimaryDevice, (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
-            if (IsOperationTool(SelectedTool) && ((BitmapOperationTool) SelectedTool).RequiresPreviewLayer)
-                BitmapOperations.StopAction();
+            if (IsOperationTool(SelectedTool) && ((BitmapOperationTool)SelectedTool).RequiresPreviewLayer)
+            {
+                BitmapOperations.StopAction();
+            }
         }
 
         public void GeneratePreviewLayer()
@@ -215,12 +233,16 @@ namespace PixiEditor.Models.Controllers
 
         private void HighlightPixels(Coordinates newPosition)
         {
-            if (ActiveDocument == null || ActiveDocument.Layers.Count == 0 || SelectedTool.HideHighlight) return;
+            if (ActiveDocument == null || ActiveDocument.Layers.Count == 0 || SelectedTool.HideHighlight)
+            {
+                return;
+            }
+
             Coordinates[] highlightArea = CoordinatesCalculator.RectangleToCoordinates(
                 CoordinatesCalculator.CalculateThicknessCenter(newPosition, ToolSize));
             if (CanChangeHighlightOffset(highlightArea))
             {
-                PreviewLayer.Offset = new Thickness(highlightArea[0].X, highlightArea[0].Y,0,0);
+                PreviewLayer.Offset = new Thickness(highlightArea[0].X, highlightArea[0].Y, 0, 0);
             }
             else if (!IsInsideBounds(highlightArea))
             {
@@ -236,7 +258,7 @@ namespace PixiEditor.Models.Controllers
 
         private bool CanChangeHighlightOffset(Coordinates[] highlightArea)
         {
-            return highlightArea.Length > 0 && PreviewLayer != null && 
+            return highlightArea.Length > 0 && PreviewLayer != null &&
                    IsInsideBounds(highlightArea) && highlightArea.Length == PreviewLayer.Width * PreviewLayer.Height;
         }
 
@@ -253,7 +275,7 @@ namespace PixiEditor.Models.Controllers
         }
 
         /// <summary>
-        ///     Returns if selected tool is BitmapOperationTool
+        ///     Returns if selected tool is BitmapOperationTool.
         /// </summary>
         /// <returns></returns>
         public bool IsOperationTool()
@@ -262,13 +284,11 @@ namespace PixiEditor.Models.Controllers
         }
 
         /// <summary>
-        ///     Returns if tool is BitmapOperationTool
+        ///     Returns if tool is BitmapOperationTool.
         /// </summary>
-        /// <param name="tool"></param>
-        /// <returns></returns>
         public static bool IsOperationTool(Tool tool)
         {
             return tool is BitmapOperationTool;
         }
     }
-}
+}

+ 2 - 2
PixiEditor/Models/Controllers/ClipboardController.cs

@@ -68,11 +68,11 @@ namespace PixiEditor.Models.Controllers
             }
             else if (dao.GetDataPresent(DataFormats.Dib))
             {
-                finalImage = new WriteableBitmap(Clipboard.GetImage() !);
+                finalImage = new WriteableBitmap(Clipboard.GetImage()!);
             }
             else if (dao.GetDataPresent(DataFormats.Bitmap))
             {
-                finalImage = new WriteableBitmap((dao.GetData(DataFormats.Bitmap) as BitmapSource) !);
+                finalImage = new WriteableBitmap((dao.GetData(DataFormats.Bitmap) as BitmapSource)!);
             }
 
             return finalImage;

+ 11 - 5
PixiEditor/Models/Controllers/MouseMovementController.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Windows.Input;
-using Accessibility;
 using PixiEditor.Models.Position;
 
 namespace PixiEditor.Models.Controllers
@@ -9,12 +8,19 @@ namespace PixiEditor.Models.Controllers
     public class MouseMovementController
     {
         public List<Coordinates> LastMouseMoveCoordinates { get; } = new List<Coordinates>();
+
         public bool IsRecordingChanges { get; private set; }
+
         public bool ClickedOnCanvas { get; set; }
+
         public event EventHandler StartedRecordingChanges;
+
         public event EventHandler<MouseEventArgs> OnMouseDown;
+
         public event EventHandler<MouseEventArgs> OnMouseUp;
+
         public event EventHandler<MouseMovementEventArgs> MousePositionChanged;
+
         public event EventHandler StoppedRecordingChanges;
 
         public void StartRecordingMouseMovementChanges(bool clickedOnCanvas)
@@ -39,7 +45,7 @@ namespace PixiEditor.Models.Controllers
         }
 
         /// <summary>
-        ///     Plain mouse move, does not affect mouse drag recordings
+        ///     Plain mouse move, does not affect mouse drag recordings.
         /// </summary>
         /// <param name="mouseCoordinates"></param>
         public void MouseMoved(Coordinates mouseCoordinates)
@@ -48,7 +54,7 @@ namespace PixiEditor.Models.Controllers
         }
 
         /// <summary>
-        /// Plain mouse down, does not affect mouse recordings
+        /// Plain mouse down, does not affect mouse recordings.
         /// </summary>
         public void MouseDown(MouseEventArgs args)
         {
@@ -56,7 +62,7 @@ namespace PixiEditor.Models.Controllers
         }
 
         /// <summary>
-        /// Plain mouse up, does not affect mouse recordings
+        /// Plain mouse up, does not affect mouse recordings.
         /// </summary>
         public void MouseUp(MouseEventArgs args)
         {
@@ -73,4 +79,4 @@ namespace PixiEditor.Models.Controllers
             }
         }
     }
-}
+}

+ 22 - 20
PixiEditor/Models/ImageManipulation/BitmapUtils.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Windows;
-using System.Windows.Interop;
+using System.Collections.Generic;
 using System.Windows.Media.Imaging;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
@@ -13,12 +9,12 @@ namespace PixiEditor.Models.ImageManipulation
     public static class BitmapUtils
     {
         /// <summary>
-        ///     Converts pixel bytes to WriteableBitmap
+        ///     Converts pixel bytes to WriteableBitmap.
         /// </summary>
-        /// <param name="currentBitmapWidth">Width of bitmap</param>
-        /// <param name="currentBitmapHeight">Height of bitmap</param>
-        /// <param name="byteArray">Bitmap byte array</param>
-        /// <returns>WriteableBitmap</returns>
+        /// <param name="currentBitmapWidth">Width of bitmap.</param>
+        /// <param name="currentBitmapHeight">Height of bitmap.</param>
+        /// <param name="byteArray">Bitmap byte array.</param>
+        /// <returns>WriteableBitmap.</returns>
         public static WriteableBitmap BytesToWriteableBitmap(int currentBitmapWidth, int currentBitmapHeight,
             byte[] byteArray)
         {
@@ -30,10 +26,10 @@ namespace PixiEditor.Models.ImageManipulation
         /// <summary>
         ///     Converts layers bitmaps into one bitmap.
         /// </summary>
-        /// <param name="layers">Layers to combine</param>
-        /// <param name="width">Width of final bitmap</param>
-        /// <param name="height">Height of final bitmap</param>
-        /// <returns>WriteableBitmap of layered bitmaps</returns>
+        /// <param name="layers">Layers to combine.</param>
+        /// <param name="width">Width of final bitmap.</param>
+        /// <param name="height">Height of final bitmap.</param>
+        /// <returns>WriteableBitmap of layered bitmaps.</returns>
         public static WriteableBitmap CombineLayers(Layer[] layers, int width, int height)
         {
             WriteableBitmap finalBitmap = BitmapFactory.New(width, height);
@@ -58,7 +54,11 @@ namespace PixiEditor.Models.ImageManipulation
                             {
                                 color = Color.FromArgb((byte)(color.A * layers[i].Opacity), color.R, color.G, color.B);
                             }
-                            if (color.A != 0 || color.R != 0 || color.B != 0 || color.G != 0) finalBitmap.SetPixel(x, y, color);
+
+                            if (color.A != 0 || color.R != 0 || color.B != 0 || color.G != 0)
+                            {
+                                finalBitmap.SetPixel(x, y, color);
+                            }
                         }
             }
 
@@ -80,17 +80,19 @@ namespace PixiEditor.Models.ImageManipulation
                     {
                         Coordinates position = layers[i].GetRelativePosition(selection[j]);
                         if (position.X < 0 || position.X > layers[i].Width - 1 || position.Y < 0 ||
-                            position.Y > layers[i].Height - 1)
-                            continue;
+                            position.Y > layers[i].Height - 1)
+                        {
+                            continue;
+                        }
+
                         pixels[j] = layers[i].GetPixel(position.X, position.Y);
                     }
                 }
-
-
+
                 result[layers[i]] = pixels;
             }
 
             return result;
         }
     }
-}
+}

+ 2 - 1
PixiEditor/Models/Processes/ProcessHelper.cs

@@ -19,7 +19,8 @@ namespace PixiEditor.Models.Processes
             {
                 throw ex;
             }
+
             return proc;
         }
     }
-}
+}

+ 31 - 14
PixiEditor/Models/Tools/Tool.cs

@@ -8,16 +8,19 @@ namespace PixiEditor.Models.Tools
     public abstract class Tool : NotifyableObject
     {
         public abstract ToolType ToolType { get; }
+
         public string ImagePath => $"/Images/{ToolType}Image.png";
+
         public bool HideHighlight { get; set; } = false;
+
         public string Tooltip { get; set; }
 
         public bool IsActive
         {
-            get => _isActive;
+            get => isActive;
             set
             {
-                _isActive = value;
+                isActive = value;
                 RaisePropertyChanged("IsActive");
             }
         }
@@ -26,18 +29,32 @@ namespace PixiEditor.Models.Tools
 
         public Toolbar Toolbar { get; set; } = new EmptyToolbar();
 
-        private bool _isActive;
+        private bool isActive;
+
         public bool CanStartOutsideCanvas { get; set; } = false;
 
-        public virtual void OnMouseDown(MouseEventArgs e) { }
-        public virtual void OnMouseUp(MouseEventArgs e) { }
-
-        public virtual void OnRecordingLeftMouseDown(MouseEventArgs e) { }
-
-        public virtual void OnStoppedRecordingMouseUp(MouseEventArgs e) { }
-
-        public virtual void OnMouseMove(MouseEventArgs e) { }
-
-        public virtual void AfterAddedUndo() { }
+        public virtual void OnMouseDown(MouseEventArgs e)
+        {
+        }
+
+        public virtual void OnMouseUp(MouseEventArgs e)
+        {
+        }
+
+        public virtual void OnRecordingLeftMouseDown(MouseEventArgs e)
+        {
+        }
+
+        public virtual void OnStoppedRecordingMouseUp(MouseEventArgs e)
+        {
+        }
+
+        public virtual void OnMouseMove(MouseEventArgs e)
+        {
+        }
+
+        public virtual void AfterAddedUndo()
+        {
+        }
     }
-}
+}

+ 10 - 6
PixiEditor/Models/Tools/Tools/BrightnessTool.cs

@@ -18,9 +18,10 @@ namespace PixiEditor.Models.Tools.Tools
         private const float CorrectionFactor = 5f; //Initial correction factor
 
         public override ToolType ToolType => ToolType.Brightness;
+
         public BrightnessMode Mode { get; set; } = BrightnessMode.Default;
 
-        private List<Coordinates> _pixelsVisited = new List<Coordinates>();
+        private List<Coordinates> pixelsVisited = new List<Coordinates>();
 
         public BrightnessTool()
         {
@@ -30,7 +31,7 @@ namespace PixiEditor.Models.Tools.Tools
 
         public override void OnRecordingLeftMouseDown(MouseEventArgs e)
         {
-            _pixelsVisited.Clear();
+            pixelsVisited.Clear();
         }
 
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
@@ -63,9 +64,12 @@ namespace PixiEditor.Models.Tools.Tools
             {
                 if (Mode == BrightnessMode.Default)
                 {
-                    if(_pixelsVisited.Contains(rectangleCoordinates[i]))
-                        continue;
-                    _pixelsVisited.Add(rectangleCoordinates[i]);
+                    if (pixelsVisited.Contains(rectangleCoordinates[i]))
+                    {
+                        continue;
+                    }
+
+                    pixelsVisited.Add(rectangleCoordinates[i]);
                 }
 
                 Color pixel = layer.GetPixelWithOffset(rectangleCoordinates[i].X, rectangleCoordinates[i].Y);
@@ -78,4 +82,4 @@ namespace PixiEditor.Models.Tools.Tools
             return changes;
         }
     }
-}
+}

+ 23 - 8
PixiEditor/Models/Tools/Tools/FloodFill.cs

@@ -40,17 +40,32 @@ namespace PixiEditor.Models.Tools.Tools
                 var cords = stack.Pop();
                 var relativeCords = layer.GetRelativePosition(cords);
 
-                if (cords.X < 0 || cords.X > width - 1) continue;
-                if (cords.Y < 0 || cords.Y > height - 1) continue;
-                if (visited[cords.X, cords.Y]) continue;
-                if (layer.GetPixel(relativeCords.X, relativeCords.Y) == newColor) continue;
-
+                if (cords.X < 0 || cords.X > width - 1)
+                {
+                    continue;
+                }
+
+                if (cords.Y < 0 || cords.Y > height - 1)
+                {
+                    continue;
+                }
+
+                if (visited[cords.X, cords.Y])
+                {
+                    continue;
+                }
+
+                if (layer.GetPixel(relativeCords.X, relativeCords.Y) == newColor)
+                {
+                    continue;
+                }
+
                 if (layer.GetPixel(relativeCords.X, relativeCords.Y) == colorToReplace)
                 {
                     changedCoords.Add(new Coordinates(cords.X, cords.Y));
                     visited[cords.X, cords.Y] = true;
-                    stack.Push(new Coordinates(cords.X, cords.Y - 1));                    
-                    stack.Push(new Coordinates(cords.X, cords.Y + 1));                    
+                    stack.Push(new Coordinates(cords.X, cords.Y - 1));
+                    stack.Push(new Coordinates(cords.X, cords.Y + 1));
                     stack.Push(new Coordinates(cords.X - 1, cords.Y));
                     stack.Push(new Coordinates(cords.X + 1, cords.Y));
                 }
@@ -59,4 +74,4 @@ namespace PixiEditor.Models.Tools.Tools
             return BitmapPixelChanges.FromSingleColoredArray(changedCoords, newColor);
         }
     }
-}
+}

+ 33 - 24
PixiEditor/Models/Tools/Tools/MoveTool.cs

@@ -21,7 +21,8 @@ namespace PixiEditor.Models.Tools.Tools
         public bool MoveAll { get; set; } = false;
 
         public override ToolType ToolType => ToolType.Move;
-        private Layer[] _affectedLayers;
+
+        private Layer[] affectedLayers;
         private Dictionary<Layer, bool> _clearedPixels = new Dictionary<Layer, bool>();
         private Coordinates[] _currentSelection;
         private Coordinates _lastMouseMove;
@@ -51,10 +52,10 @@ namespace PixiEditor.Models.Tools.Tools
                     Change changes = UndoManager.UndoStack.Peek();
                     int layerIndex = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.IndexOf(item.Key);
 
-                    ((LayerChange[]) changes.OldValue).First(x=> x.LayerIndex == layerIndex).PixelChanges.ChangedPixels
+                    ((LayerChange[])changes.OldValue).First(x => x.LayerIndex == layerIndex).PixelChanges.ChangedPixels
                         .AddRangeOverride(beforeMovePixels.ChangedPixels);
 
-                    ((LayerChange[]) changes.NewValue).First(x => x.LayerIndex == layerIndex).PixelChanges.ChangedPixels
+                    ((LayerChange[])changes.NewValue).First(x => x.LayerIndex == layerIndex).PixelChanges.ChangedPixels
                         .AddRangeNewOnly(BitmapPixelChanges
                             .FromSingleColoredArray(_startSelection, System.Windows.Media.Colors.Transparent)
                             .ChangedPixels);
@@ -66,8 +67,8 @@ namespace PixiEditor.Models.Tools.Tools
         {   //is because it doesn't fire if no pixel changes were made.
             if (_currentSelection != null && _currentSelection.Length == 0)
             {
-                UndoManager.AddUndoChange(new Change(ApplyOffsets, new object[]{_startingOffsets}, 
-                    ApplyOffsets, new object[] { GetOffsets(_affectedLayers)}, "Move layers"));
+                UndoManager.AddUndoChange(new Change(ApplyOffsets, new object[] { _startingOffsets },
+                    ApplyOffsets, new object[] { GetOffsets(affectedLayers) }, "Move layers"));
             }
         }
 
@@ -96,34 +97,37 @@ namespace PixiEditor.Models.Tools.Tools
                 }
 
                 if (Keyboard.IsKeyDown(Key.LeftCtrl) || MoveAll)
-                    _affectedLayers = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.Where(x => x.IsVisible)
+                    affectedLayers = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.Where(x => x.IsVisible)
                         .ToArray();
-                else
-                    _affectedLayers = new[] {layer};
-
+                else
+                {
+                    affectedLayers = new[] { layer };
+                }
+
                 _startSelection = _currentSelection;
-                _startPixelColors = BitmapUtils.GetPixelsForSelection(_affectedLayers, _startSelection);
-                _startingOffsets = GetOffsets(_affectedLayers);
+                _startPixelColors = BitmapUtils.GetPixelsForSelection(affectedLayers, _startSelection);
+                _startingOffsets = GetOffsets(affectedLayers);
             }
 
-            LayerChange[] result = new LayerChange[_affectedLayers.Length];
+            LayerChange[] result = new LayerChange[affectedLayers.Length];
             var end = mouseMove[0];
-            for (int i = 0; i < _affectedLayers.Length; i++)
+            for (int i = 0; i < affectedLayers.Length; i++)
             {
                 if (_currentSelection.Length > 0)
                 {
-                    var changes = MoveSelection(_affectedLayers[i], mouseMove);
+                    var changes = MoveSelection(affectedLayers[i], mouseMove);
                     changes = RemoveTransparentPixels(changes);
 
-                    result[i] = new LayerChange(changes, _affectedLayers[i]);
+                    result[i] = new LayerChange(changes, affectedLayers[i]);
                 }
                 else
                 {
                     var vector = Transform.GetTranslation(_lastMouseMove, end);
-                    _affectedLayers[i].Offset = new Thickness(_affectedLayers[i].OffsetX + vector.X, _affectedLayers[i].OffsetY + vector.Y, 0, 0);
-                    result[i] = new LayerChange(BitmapPixelChanges.Empty, _affectedLayers[i]);
+                    affectedLayers[i].Offset = new Thickness(affectedLayers[i].OffsetX + vector.X, affectedLayers[i].OffsetY + vector.Y, 0, 0);
+                    result[i] = new LayerChange(BitmapPixelChanges.Empty, affectedLayers[i]);
                 }
             }
+
             _lastMouseMove = end;
 
             return result;
@@ -142,8 +146,11 @@ namespace PixiEditor.Models.Tools.Tools
 
         private BitmapPixelChanges RemoveTransparentPixels(BitmapPixelChanges pixels)
         {
-            foreach (var item in pixels.ChangedPixels.Where(x => x.Value.A == 0).ToList())
-                pixels.ChangedPixels.Remove(item.Key);
+            foreach (var item in pixels.ChangedPixels.Where(x => x.Value.A == 0).ToList())
+            {
+                pixels.ChangedPixels.Remove(item.Key);
+            }
+
             return pixels;
         }
 
@@ -152,11 +159,13 @@ namespace PixiEditor.Models.Tools.Tools
             Coordinates end = mouseMove[0];
 
             _currentSelection = TranslateSelection(end, out Coordinates[] previousSelection);
-            if (_updateViewModelSelection)
-                ViewModelMain.Current.ActiveSelection.SetSelection(_currentSelection, SelectionType.New);
+            if (_updateViewModelSelection)
+            {
+                ViewModelMain.Current.ActiveSelection.SetSelection(_currentSelection, SelectionType.New);
+            }
+
             ClearSelectedPixels(layer, previousSelection);
-
-
+
             _lastMouseMove = end;
             return BitmapPixelChanges.FromArrays(_currentSelection, _startPixelColors[layer]);
         }
@@ -189,4 +198,4 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
     }
-}
+}

+ 9 - 8
PixiEditor/Models/Tools/Tools/MoveViewportTool.cs

@@ -1,14 +1,15 @@
-using PixiEditor.Models.Position;
-using PixiEditor.ViewModels;
-using System.Drawing;
+using System.Drawing;
 using System.Windows.Input;
+using PixiEditor.Models.Position;
+using PixiEditor.ViewModels;
 
 namespace PixiEditor.Models.Tools.Tools
 {
     public class MoveViewportTool : ReadonlyTool
     {
         public override ToolType ToolType => ToolType.MoveViewport;
-        private Point _clickPoint;
+
+        private Point clickPoint;
 
         public MoveViewportTool()
         {
@@ -21,7 +22,7 @@ namespace PixiEditor.Models.Tools.Tools
         {
             if (e.LeftButton == MouseButtonState.Pressed || e.MiddleButton == MouseButtonState.Pressed)
             {
-                _clickPoint = MousePositionConverter.GetCursorPosition();
+                clickPoint = MousePositionConverter.GetCursorPosition();
             }
         }
 
@@ -30,8 +31,8 @@ namespace PixiEditor.Models.Tools.Tools
             if (e.LeftButton == MouseButtonState.Pressed || e.MiddleButton == MouseButtonState.Pressed)
             {
                 var point = MousePositionConverter.GetCursorPosition();
-                ViewModelMain.Current.ViewportPosition = new System.Windows.Point(point.X - _clickPoint.X, 
-                    point.Y - _clickPoint.Y);
+                ViewModelMain.Current.ViewportPosition = new System.Windows.Point(point.X - clickPoint.X,
+                    point.Y - clickPoint.Y);
             }
         }
 
@@ -47,4 +48,4 @@ namespace PixiEditor.Models.Tools.Tools
         {
         }
     }
-}
+}

+ 13 - 11
PixiEditor/Models/Tools/Tools/SelectTool.cs

@@ -16,7 +16,8 @@ namespace PixiEditor.Models.Tools.Tools
     public class SelectTool : ReadonlyTool
     {
         public override ToolType ToolType => ToolType.Select;
-        private Selection _oldSelection;
+
+        private Selection oldSelection;
         public SelectionType SelectionType = SelectionType.Add;
 
         public SelectTool()
@@ -29,10 +30,12 @@ namespace PixiEditor.Models.Tools.Tools
         {
             Enum.TryParse((Toolbar.GetSetting<DropdownSetting>("Mode")?.Value as ComboBoxItem)?.Content as string, out SelectionType);
 
-            _oldSelection = null;
+            oldSelection = null;
             if (ViewModelMain.Current.ActiveSelection != null &&
-                ViewModelMain.Current.ActiveSelection.SelectedPoints != null)
-                _oldSelection = ViewModelMain.Current.ActiveSelection;
+                ViewModelMain.Current.ActiveSelection.SelectedPoints != null)
+            {
+                oldSelection = ViewModelMain.Current.ActiveSelection;
+            }
         }
 
         public override void OnStoppedRecordingMouseUp(MouseEventArgs e)
@@ -43,7 +46,7 @@ namespace PixiEditor.Models.Tools.Tools
                 ViewModelMain.Current.ActiveSelection.Clear();
             }
 
-            UndoManager.AddUndoChange(new Change("ActiveSelection", _oldSelection,
+            UndoManager.AddUndoChange(new Change("ActiveSelection", oldSelection,
                 ViewModelMain.Current.ActiveSelection, "Select pixels"));
         }
 
@@ -67,22 +70,21 @@ namespace PixiEditor.Models.Tools.Tools
         }
 
         /// <summary>
-        ///     Gets coordinates of every pixel in root layer
+        ///     Gets coordinates of every pixel in root layer.
         /// </summary>
-        /// <returns>Coordinates array of pixels</returns>
+        /// <returns>Coordinates array of pixels.</returns>
         public IEnumerable<Coordinates> GetAllSelection()
         {
             return GetAllSelection(ViewModelMain.Current.BitmapManager.ActiveDocument);
         }
 
         /// <summary>
-        ///     Gets coordinates of every pixel in chosen document
+        ///     Gets coordinates of every pixel in chosen document.
         /// </summary>
-        /// <param name="document"></param>
-        /// <returns>Coordinates array of pixels</returns>
+        /// <returns>Coordinates array of pixels.</returns>
         public IEnumerable<Coordinates> GetAllSelection(Document document)
         {
             return GetRectangleSelectionForPoints(new Coordinates(0, 0), new Coordinates(document.Width - 1, document.Height - 1));
         }
     }
-}
+}

+ 14 - 15
PixiEditor/Models/Tools/Tools/ZoomTool.cs

@@ -1,33 +1,32 @@
-using PixiEditor.Models.Controllers;
-using PixiEditor.Models.Position;
-using PixiEditor.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System;
 using System.Windows;
 using System.Windows.Input;
+using PixiEditor.Models.Position;
+using PixiEditor.ViewModels;
 
 namespace PixiEditor.Models.Tools.Tools
 {
     public class ZoomTool : ReadonlyTool
     {
         public const float ZoomSensitivityMultiplier = 30f;
+
         public override ToolType ToolType => ToolType.Zoom;
-        private double _startingX;
-        private double _workAreaWidth = SystemParameters.WorkArea.Width;
-        private double _pixelsPerZoomMultiplier;
+
+        private double startingX;
+        private double workAreaWidth = SystemParameters.WorkArea.Width;
+        private double pixelsPerZoomMultiplier;
 
         public ZoomTool()
         {
             HideHighlight = true;
             CanStartOutsideCanvas = true;
             Tooltip = "Zooms viewport (Z). Click to zoom in, hold alt and click to zoom out.";
-            _pixelsPerZoomMultiplier = _workAreaWidth / ZoomSensitivityMultiplier;
+            pixelsPerZoomMultiplier = workAreaWidth / ZoomSensitivityMultiplier;
         }
 
         public override void OnRecordingLeftMouseDown(MouseEventArgs e)
         {
-            _startingX = MousePositionConverter.GetCursorPosition().X;
+            startingX = MousePositionConverter.GetCursorPosition().X;
             ViewModelMain.Current.ZoomPercentage = 100; //This resest the value, so callback in MainDrawingPanel can fire again later
         }
 
@@ -37,7 +36,7 @@ namespace PixiEditor.Models.Tools.Tools
             {
                 double xPos = MousePositionConverter.GetCursorPosition().X;
 
-                double rawPercentDifference = (xPos - _startingX) / _pixelsPerZoomMultiplier; //negative - zoom out, positive - zoom in, linear
+                double rawPercentDifference = (xPos - startingX) / pixelsPerZoomMultiplier; //negative - zoom out, positive - zoom in, linear
                 double finalPercentDifference = Math.Pow(2, rawPercentDifference) * 100.0; //less than 100 - zoom out, greater than 100 - zoom in
                 Zoom(finalPercentDifference);
             }
@@ -45,8 +44,8 @@ namespace PixiEditor.Models.Tools.Tools
 
         public override void OnStoppedRecordingMouseUp(MouseEventArgs e)
         {
-            if (e.LeftButton == MouseButtonState.Released && e.RightButton == MouseButtonState.Released && 
-                _startingX == MousePositionConverter.GetCursorPosition().X)
+            if (e.LeftButton == MouseButtonState.Released && e.RightButton == MouseButtonState.Released &&
+                startingX == MousePositionConverter.GetCursorPosition().X)
             {
                 if (Keyboard.Modifiers.HasFlag(ModifierKeys.Alt))
                 {
@@ -68,4 +67,4 @@ namespace PixiEditor.Models.Tools.Tools
         {
         }
     }
-}
+}

+ 10 - 12
PixiEditor/Properties/AssemblyInfo.cs

@@ -27,18 +27,16 @@ using System.Windows;
 //the line below to match the UICulture setting in the project file.
 
 //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
-
-
+
 [assembly: ThemeInfo(
-    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
-    //(used if a resource is not found in the page,
-    // or application resource dictionaries)
-    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
-    //(used if a resource is not found in the page,
-    // app, or any theme specific resource dictionaries)
-)]
-
-
+    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+                                     //(used if a resource is not found in the page,
+                                     // or application resource dictionaries)
+    ResourceDictionaryLocation.SourceAssembly) //where the generic resource dictionary is located
+                                               //(used if a resource is not found in the page,
+                                               // app, or any theme specific resource dictionaries)
+]
+
 // Version information for an assembly consists of the following four values:
 //
 //      Major Version
@@ -51,4 +49,4 @@ using System.Windows;
 // [assembly: AssemblyVersion("1.0.*")]
 
 [assembly: AssemblyVersion("0.1.3.2")]
-[assembly: AssemblyFileVersion("0.1.3.2")]
+[assembly: AssemblyFileVersion("0.1.3.2")]

+ 201 - 107
PixiEditor/ViewModels/ViewModelMain.cs

@@ -32,116 +32,150 @@ namespace PixiEditor.ViewModels
     {
         private const string ConfirmationDialogMessage = "Document was modified. Do you want to save changes?";
 
-        private Color _primaryColor = Colors.Black;
+        private Color primaryColor = Colors.Black;
 
-        private bool _recenterZoombox;
+        private bool recenterZoombox;
 
-        private Color _secondaryColor = Colors.White;
+        private Color secondaryColor = Colors.White;
 
-        private Selection _selection;
+        private Selection selection;
 
-        private Cursor _toolCursor;
+        private Cursor toolCursor;
 
-        private LayerChange[] _undoChanges;
+        private LayerChange[] undoChanges;
 
-        private bool _unsavedDocumentModified;
+        private bool unsavedDocumentModified;
 
         public Action CloseAction { get; set; }
 
         public static ViewModelMain Current { get; set; }
-        public RelayCommand SelectToolCommand { get; set; } //Command that handles tool switching 
+
+        public RelayCommand SelectToolCommand { get; set; } //Command that handles tool switching
+
         public RelayCommand OpenNewFilePopupCommand { get; set; } //Command that generates draw area
+
         public RelayCommand MouseMoveCommand { get; set; } //Command that is used to draw
+
         public RelayCommand MouseDownCommand { get; set; }
+
         public RelayCommand KeyDownCommand { get; set; }
+
         public RelayCommand KeyUpCommand { get; set; }
+
         public RelayCommand ExportFileCommand { get; set; } //Command that is used to save file
+
         public RelayCommand UndoCommand { get; set; }
+
         public RelayCommand RedoCommand { get; set; }
+
         public RelayCommand OpenFileCommand { 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 SwapColorsCommand { 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 ClipCanvasCommand { get; set; }
+
         public RelayCommand DeletePixelsCommand { get; set; }
+
         public RelayCommand OpenResizePopupCommand { get; set; }
+
         public RelayCommand SelectColorCommand { get; set; }
+
         public RelayCommand RemoveSwatchCommand { get; set; }
+
         public RelayCommand SaveDocumentCommand { get; set; }
+
         public RelayCommand OnStartupCommand { get; set; }
+
         public RelayCommand CloseWindowCommand { get; set; }
+
         public RelayCommand CenterContentCommand { get; set; }
+
         public RelayCommand OpenHyperlinkCommand { get; set; }
+
         public RelayCommand ZoomCommand { get; set; }
+
         public RelayCommand ChangeToolSizeCommand { get; set; }
-        public RelayCommand RestartApplicationCommand { get; set; }
 
+        public RelayCommand RestartApplicationCommand { get; set; }
 
-        private double _mouseXonCanvas;
+        private double mouseXonCanvas;
 
-        private double _mouseYonCanvas;
+        private double mouseYonCanvas;
 
         public double MouseXOnCanvas //Mouse X coordinate relative to canvas
         {
-            get => _mouseXonCanvas;
+            get => mouseXonCanvas;
             set
             {
-                _mouseXonCanvas = value;
+                mouseXonCanvas = value;
                 RaisePropertyChanged("MouseXOnCanvas");
             }
         }
 
         public double MouseYOnCanvas //Mouse Y coordinate relative to canvas
         {
-            get => _mouseYonCanvas;
+            get => mouseYonCanvas;
             set
             {
-                _mouseYonCanvas = value;
+                mouseYonCanvas = value;
                 RaisePropertyChanged("MouseYOnCanvas");
             }
         }
 
-        private string _versionText;
+        private string versionText;
 
         public string VersionText
         {
-            get => _versionText;
+            get => versionText;
             set
             {
-                _versionText = value;
+                versionText = value;
                 RaisePropertyChanged(nameof(VersionText));
             }
         }
 
-
         public bool RecenterZoombox
         {
-            get => _recenterZoombox;
+            get => recenterZoombox;
             set
             {
-                _recenterZoombox = value;
+                recenterZoombox = value;
                 RaisePropertyChanged("RecenterZoombox");
             }
         }
 
         public Color PrimaryColor //Primary color, hooked with left mouse button
         {
-            get => _primaryColor;
+            get => primaryColor;
             set
             {
-                if (_primaryColor != value)
+                if (primaryColor != value)
                 {
-                    _primaryColor = value;
+                    primaryColor = value;
                     BitmapManager.PrimaryColor = value;
                     RaisePropertyChanged("PrimaryColor");
                 }
@@ -150,12 +184,12 @@ namespace PixiEditor.ViewModels
 
         public Color SecondaryColor
         {
-            get => _secondaryColor;
+            get => secondaryColor;
             set
             {
-                if (_secondaryColor != value)
+                if (secondaryColor != value)
                 {
-                    _secondaryColor = value;
+                    secondaryColor = value;
                     RaisePropertyChanged("SecondaryColor");
                 }
             }
@@ -165,78 +199,85 @@ namespace PixiEditor.ViewModels
 
         public LayerChange[] UndoChanges //This acts like UndoManager process, but it was implemented before process system, so it can be transformed into it
         {
-            get => _undoChanges;
+            get => undoChanges;
             set
             {
-                _undoChanges = value;
+                undoChanges = value;
                 for (int i = 0; i < value.Length; i++)
+                {
                     BitmapManager.ActiveDocument.Layers[value[i].LayerIndex].SetPixels(value[i].PixelChanges);
+                }
             }
         }
 
         public Cursor ToolCursor
         {
-            get => _toolCursor;
+            get => toolCursor;
             set
             {
-                _toolCursor = value;
+                toolCursor = value;
                 RaisePropertyChanged("ToolCursor");
             }
         }
 
-        private double _zoomPercentage = 100;
+        private double zoomPercentage = 100;
 
         public double ZoomPercentage
         {
-            get { return _zoomPercentage; }
-            set 
+            get
+            {
+                return zoomPercentage;
+            }
+
+            set
             {
-                _zoomPercentage = value;
+                zoomPercentage = value;
                 RaisePropertyChanged(nameof(ZoomPercentage));
             }
         }
 
-        private Point _viewPortPosition;
+        private Point viewPortPosition;
 
         public Point ViewportPosition
         {
-            get => _viewPortPosition;
-            set 
+            get => viewPortPosition;
+            set
             {
-                _viewPortPosition = value;
+                viewPortPosition = value;
                 RaisePropertyChanged(nameof(ViewportPosition));
             }
         }
 
-
-        private bool _updateReadyToInstall = false;
+        private bool updateReadyToInstall = false;
 
         public bool UpdateReadyToInstall
         {
-            get => _updateReadyToInstall;
+            get => updateReadyToInstall;
             set
             {
-                _updateReadyToInstall = value;
+                updateReadyToInstall = value;
                 RaisePropertyChanged(nameof(UpdateReadyToInstall));
             }
         }
 
         public BitmapManager BitmapManager { get; set; }
+
         public PixelChangesController ChangesController { get; set; }
 
         public ShortcutController ShortcutController { get; set; }
 
         public Selection ActiveSelection
         {
-            get => _selection;
+            get => selection;
             set
             {
-                _selection = value;
+                selection = value;
                 RaisePropertyChanged("ActiveSelection");
             }
         }
 
-        private bool _restoreToolOnKeyUp = false;
+        private bool restoreToolOnKeyUp = false;
+
         public Tool LastActionTool { get; private set; }
 
         public UpdateChecker UpdateChecker { get; set; }
@@ -287,7 +328,7 @@ namespace PixiEditor.ViewModels
             ToolSet = new ObservableCollection<Tool>
             {
                 new MoveViewportTool(), new MoveTool(), new PenTool(), new SelectTool(), new FloodFill(), new LineTool(),
-                new CircleTool(), new RectangleTool(), new EraserTool(), new ColorPickerTool(), new BrightnessTool(), 
+                new CircleTool(), new RectangleTool(), new EraserTool(), new ColorPickerTool(), new BrightnessTool(),
                 new ZoomTool()
             };
             ShortcutController = new ShortcutController
@@ -371,6 +412,7 @@ namespace PixiEditor.ViewModels
                     UpdateReadyToInstall = true;
                     return true;
                 }
+
                 return false;
             });
         }
@@ -402,8 +444,12 @@ namespace PixiEditor.ViewModels
 
         private void OpenHyperlink(object parameter)
         {
-            if (parameter == null) return;
-            string url = (string) parameter;
+            if (parameter == null)
+            {
+                return;
+            }
+
+            string url = (string)parameter;
             var processInfo = new ProcessStartInfo()
             {
                 FileName = url,
@@ -419,18 +465,26 @@ namespace PixiEditor.ViewModels
 
         private void CloseWindow(object property)
         {
-            if (!(property is CancelEventArgs)) throw new ArgumentException();
-
-            ((CancelEventArgs) property).Cancel = true;
+            if (!(property is CancelEventArgs))
+            {
+                throw new ArgumentException();
+            }
+((CancelEventArgs)property).Cancel = true;
 
             ConfirmationType result = ConfirmationType.No;
-            if (_unsavedDocumentModified)
+            if (unsavedDocumentModified)
             {
                 result = ConfirmationDialog.Show(ConfirmationDialogMessage);
-                if (result == ConfirmationType.Yes) SaveDocument(null);
+                if (result == ConfirmationType.Yes)
+                {
+                    SaveDocument(null);
+                }
             }
 
-            if (result != ConfirmationType.Canceled) ((CancelEventArgs) property).Cancel = false;
+            if (result != ConfirmationType.Canceled)
+            {
+                ((CancelEventArgs)property).Cancel = false;
+            }
         }
 
         private async void OnStartup(object parameter)
@@ -444,6 +498,7 @@ namespace PixiEditor.ViewModels
             {
                 OpenNewFilePopup(null);
             }
+
             await CheckForUpdate();
         }
 
@@ -459,17 +514,20 @@ namespace PixiEditor.ViewModels
                 Filter = "All Files|*.*|PixiEditor Files | *.pixi|PNG Files|*.png",
                 DefaultExt = "pixi"
             };
-            if ((bool) dialog.ShowDialog())
+            if ((bool)dialog.ShowDialog())
             {
                 if (Importer.IsSupportedFile(dialog.FileName))
+                {
                     Open(dialog.FileName);
+                }
+
                 RecenterZoombox = !RecenterZoombox;
             }
         }
 
         private void Open(string path)
         {
-            if (_unsavedDocumentModified)
+            if (unsavedDocumentModified)
             {
                 var result = ConfirmationDialog.Show(ConfirmationDialogMessage);
                 if (result == ConfirmationType.Yes)
@@ -484,16 +542,20 @@ namespace PixiEditor.ViewModels
 
             ResetProgramStateValues();
             if (path.EndsWith(".pixi"))
+            {
                 OpenDocument(path);
+            }
             else
+            {
                 OpenFile(path);
+            }
         }
 
         private void OpenDocument(string path)
         {
             BitmapManager.ActiveDocument = Importer.ImportDocument(path);
             Exporter.SaveDocumentPath = path;
-            _unsavedDocumentModified = false;
+            unsavedDocumentModified = false;
         }
 
         private void SaveDocument(object parameter)
@@ -502,21 +564,27 @@ namespace PixiEditor.ViewModels
             if (paramIsAsNew || Exporter.SaveDocumentPath == null)
             {
                 var saved = Exporter.SaveAsEditableFileWithDialog(BitmapManager.ActiveDocument, !paramIsAsNew);
-                _unsavedDocumentModified = _unsavedDocumentModified && !saved;
+                unsavedDocumentModified = unsavedDocumentModified && !saved;
             }
             else
             {
                 Exporter.SaveAsEditableFile(BitmapManager.ActiveDocument, Exporter.SaveDocumentPath);
-                _unsavedDocumentModified = false;
+                unsavedDocumentModified = false;
             }
         }
 
         private void RemoveSwatch(object parameter)
         {
-            if (!(parameter is Color)) throw new ArgumentException();
-            Color color = (Color) parameter;
+            if (!(parameter is Color))
+            {
+                throw new ArgumentException();
+            }
+
+            Color color = (Color)parameter;
             if (BitmapManager.ActiveDocument.Swatches.Contains(color))
+            {
                 BitmapManager.ActiveDocument.Swatches.Remove(color);
+            }
         }
 
         private void SelectColor(object parameter)
@@ -528,32 +596,38 @@ namespace PixiEditor.ViewModels
         {
             ActiveSelection = new Selection(Array.Empty<Coordinates>());
             RecenterZoombox = !RecenterZoombox;
-            _unsavedDocumentModified = true;
+            unsavedDocumentModified = true;
         }
 
         public void AddSwatch(Color color)
         {
             if (!BitmapManager.ActiveDocument.Swatches.Contains(color))
+            {
                 BitmapManager.ActiveDocument.Swatches.Add(color);
+            }
         }
 
         private void OpenResizePopup(object parameter)
         {
-            bool isCanvasDialog = (string) parameter == "canvas";
+            bool isCanvasDialog = (string)parameter == "canvas";
             ResizeDocumentDialog dialog = new ResizeDocumentDialog(BitmapManager.ActiveDocument.Width,
                 BitmapManager.ActiveDocument.Height, isCanvasDialog);
             if (dialog.ShowDialog())
             {
                 if (isCanvasDialog)
+                {
                     BitmapManager.ActiveDocument.ResizeCanvas(dialog.Width, dialog.Height, dialog.ResizeAnchor);
+                }
                 else
+                {
                     BitmapManager.ActiveDocument.Resize(dialog.Width, dialog.Height);
+                }
             }
         }
 
         private void DeletePixels(object parameter)
         {
-            BitmapManager.BitmapOperations.DeletePixels(new[] {BitmapManager.ActiveLayer},
+            BitmapManager.BitmapOperations.DeletePixels(new[] { BitmapManager.ActiveLayer },
                 ActiveSelection.SelectedPoints.ToArray());
         }
 
@@ -620,20 +694,20 @@ namespace PixiEditor.ViewModels
 
         public void SetTool(object parameter)
         {
-            SetActiveTool((ToolType) parameter);
+            SetActiveTool((ToolType)parameter);
         }
 
         public void RenameLayer(object parameter)
         {
-            BitmapManager.ActiveDocument.Layers[(int) parameter].IsRenaming = true;
+            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)
+            if (restoreToolOnKeyUp && ShortcutController.LastShortcut != null && ShortcutController.LastShortcut.ShortcutKey == args.Key)
             {
-                _restoreToolOnKeyUp = false;
+                restoreToolOnKeyUp = false;
                 SetActiveTool(LastActionTool);
                 ShortcutController.BlockShortcutExecution = false;
             }
@@ -642,23 +716,24 @@ namespace PixiEditor.ViewModels
         public void KeyDown(object parameter)
         {
             KeyEventArgs args = (KeyEventArgs)parameter;
-            if (args.IsRepeat && !_restoreToolOnKeyUp && ShortcutController.LastShortcut != null && ShortcutController.LastShortcut.Command == SelectToolCommand)
+            if (args.IsRepeat && !restoreToolOnKeyUp && ShortcutController.LastShortcut != null && ShortcutController.LastShortcut.Command == SelectToolCommand)
             {
-                _restoreToolOnKeyUp = true;
+                restoreToolOnKeyUp = true;
                 ShortcutController.BlockShortcutExecution = true;
             }
+
             ShortcutController.KeyPressed(args.Key, Keyboard.Modifiers);
         }
 
         private void MouseController_StoppedRecordingChanges(object sender, EventArgs e)
         {
-           TriggerNewUndoChange(BitmapManager.SelectedTool);
+            TriggerNewUndoChange(BitmapManager.SelectedTool);
         }
 
         public void TriggerNewUndoChange(Tool toolUsed)
         {
             if (BitmapManager.IsOperationTool(toolUsed)
-                && ((BitmapOperationTool) toolUsed).UseDefaultUndoMethod)
+                && ((BitmapOperationTool)toolUsed).UseDefaultUndoMethod)
             {
                 Tuple<LayerChange, LayerChange>[] changes = ChangesController.PopChanges();
                 if (changes != null && changes.Length > 0)
@@ -675,9 +750,11 @@ namespace PixiEditor.ViewModels
         {
             ChangesController.AddChanges(new LayerChange(e.PixelsChanged, e.ChangedLayerIndex),
                 new LayerChange(e.OldPixelsValues, e.ChangedLayerIndex));
-            _unsavedDocumentModified = true;
+            unsavedDocumentModified = true;
             if (BitmapManager.IsOperationTool())
+            {
                 AddSwatch(PrimaryColor);
+            }
         }
 
         public void SwapColors(object parameter)
@@ -689,36 +766,42 @@ namespace PixiEditor.ViewModels
 
         public void MoveLayerToFront(object parameter)
         {
-            int oldIndex = (int) parameter;
+            int oldIndex = (int)parameter;
             BitmapManager.ActiveDocument.Layers.Move(oldIndex, oldIndex + 1);
-            if (BitmapManager.ActiveDocument.ActiveLayerIndex == oldIndex) BitmapManager.SetActiveLayer(oldIndex + 1);
+            if (BitmapManager.ActiveDocument.ActiveLayerIndex == oldIndex)
+            {
+                BitmapManager.SetActiveLayer(oldIndex + 1);
+            }
         }
 
         public void MoveLayerToBack(object parameter)
         {
-            int oldIndex = (int) parameter;
+            int oldIndex = (int)parameter;
             BitmapManager.ActiveDocument.Layers.Move(oldIndex, oldIndex - 1);
-            if (BitmapManager.ActiveDocument.ActiveLayerIndex == oldIndex) BitmapManager.SetActiveLayer(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;
+            return DocumentIsNotNull(null) && BitmapManager.ActiveDocument.Layers.Count - 1 > (int)property;
         }
 
         public bool CanMoveToBack(object property)
         {
-            return (int) property > 0;
+            return (int)property > 0;
         }
 
         public void SetActiveLayer(object parameter)
         {
-            BitmapManager.SetActiveLayer((int) parameter);
+            BitmapManager.SetActiveLayer((int)parameter);
         }
 
         public void DeleteLayer(object parameter)
         {
-            BitmapManager.RemoveLayer((int) parameter);
+            BitmapManager.RemoveLayer((int)parameter);
         }
 
         public bool CanDeleteLayer(object property)
@@ -735,7 +818,10 @@ namespace PixiEditor.ViewModels
         public void SetActiveTool(Tool tool)
         {
             Tool activeTool = ToolSet.FirstOrDefault(x => x.IsActive);
-            if (activeTool != null) activeTool.IsActive = false;
+            if (activeTool != null)
+            {
+                activeTool.IsActive = false;
+            }
 
             tool.IsActive = true;
             LastActionTool = BitmapManager.SelectedTool;
@@ -743,17 +829,25 @@ namespace PixiEditor.ViewModels
             SetToolCursor(tool.ToolType);
         }
 
-            private void SetToolCursor(ToolType tool)
+        private void SetToolCursor(ToolType tool)
         {
             if (tool != ToolType.None)
+            {
                 ToolCursor = BitmapManager.SelectedTool.Cursor;
+            }
             else
+            {
                 ToolCursor = Cursors.Arrow;
+            }
         }
 
         private void MouseDown(object parameter)
         {
-            if (BitmapManager.ActiveDocument.Layers.Count == 0) return;
+            if (BitmapManager.ActiveDocument.Layers.Count == 0)
+            {
+                return;
+            }
+
             if (Mouse.LeftButton == MouseButtonState.Pressed)
             {
                 if (!BitmapManager.MouseController.IsRecordingChanges)
@@ -764,6 +858,7 @@ namespace PixiEditor.ViewModels
                     BitmapManager.MouseController.RecordMouseMovementChange(MousePositionConverter.CurrentCoordinates);
                 }
             }
+
             BitmapManager.MouseController.MouseDown(new MouseEventArgs(Mouse.PrimaryDevice,
                 (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
 
@@ -781,12 +876,13 @@ namespace PixiEditor.ViewModels
             {
                 BitmapManager.MouseController.StopRecordingMouseMovementChanges();
             }
-            BitmapManager.MouseController.MouseUp(new MouseEventArgs(Mouse.PrimaryDevice, 
+
+            BitmapManager.MouseController.MouseUp(new MouseEventArgs(Mouse.PrimaryDevice,
                 (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
         }
 
         /// <summary>
-        ///     Method connected with command, it executes tool "activity"
+        ///     Method connected with command, it executes tool "activity".
         /// </summary>
         /// <param name="parameter"></param>
         private void MouseMove(object parameter)
@@ -794,47 +890,53 @@ namespace PixiEditor.ViewModels
             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);
+
+            BitmapManager.MouseController.MouseMoved(cords);
         }
 
         /// <summary>
-        ///     Generates new Layer and sets it as active one
+        ///     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);
+            if (newFile.ShowDialog())
+            {
+                NewDocument(newFile.Width, newFile.Height);
+            }
         }
 
         /// <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);
-                BitmapManager.AddNewLayer("Image",Importer.ImportImage(dialog.FilePath, dialog.FileWidth, dialog.FileHeight));
+                BitmapManager.AddNewLayer("Image", Importer.ImportImage(dialog.FilePath, dialog.FileWidth, dialog.FileHeight));
             }
         }
 
         public void NewDocument(int width, int height, bool addBaseLayer = true)
         {
             BitmapManager.ActiveDocument = new Document(width, height);
-            if(addBaseLayer)
+            if (addBaseLayer)
+            {
                 BitmapManager.AddNewLayer("Base Layer");
+            }
+
             ResetProgramStateValues();
         }
 
@@ -849,7 +951,7 @@ namespace PixiEditor.ViewModels
             ActiveSelection = new Selection(Array.Empty<Coordinates>());
             RecenterZoombox = !RecenterZoombox;
             Exporter.SaveDocumentPath = null;
-            _unsavedDocumentModified = false;
+            unsavedDocumentModified = false;
         }
 
         public void NewLayer(object parameter)
@@ -862,10 +964,8 @@ namespace PixiEditor.ViewModels
             return BitmapManager.ActiveDocument != null && BitmapManager.ActiveDocument.Layers.Count > 0;
         }
 
-        #region Undo/Redo
-
         /// <summary>
-        ///     Undo last action
+        ///     Undo last action.
         /// </summary>
         /// <param name="parameter"></param>
         public void Undo(object parameter)
@@ -885,7 +985,7 @@ namespace PixiEditor.ViewModels
         }
 
         /// <summary>
-        ///     Redo last action
+        ///     Redo last action.
         /// </summary>
         /// <param name="parameter"></param>
         public void Redo(object parameter)
@@ -903,10 +1003,6 @@ namespace PixiEditor.ViewModels
             return UndoManager.CanRedo;
         }
 
-        #endregion
-
-        #region SaveFile
-
         /// <summary>
         ///     Generates export dialog or saves directly if save data is known.
         /// </summary>
@@ -926,7 +1022,5 @@ namespace PixiEditor.ViewModels
         {
             return BitmapManager.ActiveDocument != null;
         }
-
-        #endregion
     }
-}
+}

+ 42 - 41
PixiEditor/Views/MainDrawingPanel.xaml.cs

@@ -1,18 +1,16 @@
-using PixiEditor.ViewModels;
-using System;
+using System;
 using System.Windows;
-using System.Windows.Automation;
 using System.Windows.Controls;
 using System.Windows.Input;
 using PixiEditor.Models.Tools.Tools;
+using PixiEditor.ViewModels;
 using Xceed.Wpf.Toolkit.Core.Input;
 using Xceed.Wpf.Toolkit.Zoombox;
-using PixiEditor.Models.Position;
 
 namespace PixiEditor.Views
 {
     /// <summary>
-    ///     Interaction logic for MainDrawingPanel.xaml
+    ///     Interaction logic for MainDrawingPanel.xaml.
     /// </summary>
     public partial class MainDrawingPanel : UserControl
     {
@@ -46,8 +44,7 @@ namespace PixiEditor.Views
         // Using a DependencyProperty as the backing store for Item.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty IsUsingZoomToolProperty =
             DependencyProperty.Register("IsUsingZoomTool", typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false));
-
-
+
         public double ZoomPercentage
         {
             get { return (double)GetValue(ZoomPercentageProperty); }
@@ -57,9 +54,7 @@ namespace PixiEditor.Views
         // Using a DependencyProperty as the backing store for ZoomPercentage.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty ZoomPercentageProperty =
             DependencyProperty.Register("ZoomPercentage", typeof(double), typeof(MainDrawingPanel), new PropertyMetadata(0.0, ZoomPercentegeChanged));
-
-
-
+
         public Point ViewportPosition
         {
             get { return (Point)GetValue(ViewportPositionProperty); }
@@ -73,37 +68,34 @@ namespace PixiEditor.Views
 
         public bool Center
         {
-            get => (bool) GetValue(CenterProperty);
+            get => (bool)GetValue(CenterProperty);
             set => SetValue(CenterProperty, value);
         }
 
         public double MouseX
         {
-            get => (double) GetValue(MouseXProperty);
+            get => (double)GetValue(MouseXProperty);
             set => SetValue(MouseXProperty, value);
         }
 
         public double MouseY
         {
-            get => (double) GetValue(MouseYProperty);
+            get => (double)GetValue(MouseYProperty);
             set => SetValue(MouseYProperty, value);
         }
-
-
+
         public ICommand MouseMoveCommand
         {
-            get => (ICommand) GetValue(MouseMoveCommandProperty);
+            get => (ICommand)GetValue(MouseMoveCommandProperty);
             set => SetValue(MouseMoveCommandProperty, value);
         }
-
-
+
         public bool CenterOnStart
         {
-            get => (bool) GetValue(CenterOnStartProperty);
+            get => (bool)GetValue(CenterOnStartProperty);
             set => SetValue(CenterOnStartProperty, value);
         }
-
-
+
         public object Item
         {
             get => GetValue(ItemProperty);
@@ -112,7 +104,7 @@ namespace PixiEditor.Views
 
         public bool IsUsingZoomTool
         {
-            get => (bool) GetValue(IsUsingZoomToolProperty);
+            get => (bool)GetValue(IsUsingZoomToolProperty);
             set => SetValue(IsUsingZoomToolProperty, value);
         }
 
@@ -125,9 +117,7 @@ namespace PixiEditor.Views
         // Using a DependencyProperty as the backing store for MiddleMouseClickedCommand.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty MiddleMouseClickedCommandProperty =
             DependencyProperty.Register("MiddleMouseClickedCommand", typeof(ICommand), typeof(MainDrawingPanel), new PropertyMetadata(default(ICommand)));
-
-
-
+
         public object MiddleMouseClickedCommandParameter
         {
             get { return (object)GetValue(MiddleMouseClickedCommandParameterProperty); }
@@ -136,24 +126,23 @@ namespace PixiEditor.Views
 
         // Using a DependencyProperty as the backing store for MiddleMouseClickedCommandParameter.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty MiddleMouseClickedCommandParameterProperty =
-            DependencyProperty.Register("MiddleMouseClickedCommandParameter", typeof(object), typeof(MainDrawingPanel), 
+            DependencyProperty.Register("MiddleMouseClickedCommandParameter", typeof(object), typeof(MainDrawingPanel),
                 new PropertyMetadata(default(object)));
-
-
-
+
         private static void ZoomPercentegeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
             MainDrawingPanel panel = (MainDrawingPanel)d;
             double percentage = (double)e.NewValue;
-            if(percentage == 100)
+            if (percentage == 100)
             {
                 panel.SetClickValues();
             }
+
             panel.Zoombox.ZoomTo(panel.ClickScale * ((double)e.NewValue / 100.0));
         }
 
-        public double ClickScale;
-        public Point ClickPosition;
+        public double ClickScale { get; set; }
+        public Point ClickPosition { get; set; }
 
         public MainDrawingPanel()
         {
@@ -168,7 +157,8 @@ namespace PixiEditor.Views
             {
                 panel.Zoombox.Position = default;
                 return;
-            }           
+            }
+
             TranslateZoombox(panel, (Point)e.NewValue);
         }
 
@@ -195,7 +185,11 @@ namespace PixiEditor.Views
 
         private void SetClickValues()
         {
-            if (!IsUsingZoomTool) return;
+            if (!IsUsingZoomTool)
+            {
+                return;
+            }
+
             ClickScale = Zoombox.Scale;
             SetZoomOrigin();
         }
@@ -203,21 +197,28 @@ namespace PixiEditor.Views
         private void SetZoomOrigin()
         {
             var item = (FrameworkElement)Item;
-            if (item == null) return;
+            if (item == null)
+            {
+                return;
+            }
+
             var mousePos = Mouse.GetPosition(item);
             Zoombox.ZoomOrigin = new Point(Math.Clamp(mousePos.X / item.Width, 0, 1), Math.Clamp(mousePos.Y / item.Height, 0, 1));
         }
 
         private static void OnCenterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
-            MainDrawingPanel panel = (MainDrawingPanel) d;
+            MainDrawingPanel panel = (MainDrawingPanel)d;
             panel.Zoombox.CenterContent();
         }
-
-
+
         private void Zoombox_Loaded(object sender, RoutedEventArgs e)
         {
-            if (CenterOnStart) ((Zoombox) sender).CenterContent();
+            if (CenterOnStart)
+            {
+                ((Zoombox)sender).CenterContent();
+            }
+
             ClickScale = Zoombox.Scale;
         }
 
@@ -241,11 +242,11 @@ namespace PixiEditor.Views
 
         private void Zoombox_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            if (e.MiddleButton == MouseButtonState.Pressed && 
+            if (e.MiddleButton == MouseButtonState.Pressed &&
                 MiddleMouseClickedCommand.CanExecute(MiddleMouseClickedCommandParameter))
             {
                 MiddleMouseClickedCommand.Execute(MiddleMouseClickedCommandParameter);
             }
         }
     }
-}
+}

+ 1 - 1
PixiEditor/Views/MainWindow.xaml

@@ -13,7 +13,7 @@
         xmlns:cmd="http://www.galasoft.ch/mvvmlight" 
         xmlns:avalondock="https://github.com/Dirkster99/AvalonDock"
         xmlns:colorpicker="clr-namespace:ColorPicker;assembly=ColorPicker"
-        mc:Ignorable="d" WindowStyle="None" Initialized="mainWindow_Initialized"
+        mc:Ignorable="d" WindowStyle="None" Initialized="MainWindow_Initialized"
         Title="PixiEditor" Name="mainWindow" Height="1000" Width="1600" Background="{StaticResource MainColor}"
         WindowStartupLocation="CenterScreen" WindowState="Maximized" DataContext="{DynamicResource ViewModelMain}">
     <WindowChrome.WindowChrome>

+ 6 - 11
PixiEditor/Views/MainWindow.xaml.cs

@@ -1,8 +1,6 @@
 using System;
 using System.ComponentModel;
-using System.Diagnostics;
 using System.IO;
-using System.Reflection;
 using System.Windows;
 using System.Windows.Input;
 using PixiEditor.Models.Processes;
@@ -12,11 +10,12 @@ using PixiEditor.ViewModels;
 namespace PixiEditor
 {
     /// <summary>
-    ///     Interaction logic for MainWindow.xaml
+    ///     Interaction logic for MainWindow.xaml.
     /// </summary>
     public partial class MainWindow : Window
     {
         ViewModelMain viewModel;
+
         public MainWindow()
         {
             InitializeComponent();
@@ -31,19 +30,16 @@ namespace PixiEditor
             e.CanExecute = true;
         }
 
-
         private void CommandBinding_Executed_Minimize(object sender, ExecutedRoutedEventArgs e)
         {
             SystemCommands.MinimizeWindow(this);
         }
 
-
         private void CommandBinding_Executed_Maximize(object sender, ExecutedRoutedEventArgs e)
         {
             SystemCommands.MaximizeWindow(this);
         }
 
-
         private void CommandBinding_Executed_Restore(object sender, ExecutedRoutedEventArgs e)
         {
             SystemCommands.RestoreWindow(this);
@@ -54,7 +50,6 @@ namespace PixiEditor
             SystemCommands.CloseWindow(this);
         }
 
-
         private void MainWindowStateChangeRaised(object sender, EventArgs e)
         {
             if (WindowState == WindowState.Maximized)
@@ -69,7 +64,7 @@ namespace PixiEditor
             }
         }
 
-        private void mainWindow_Initialized(object sender, EventArgs e)
+        private void MainWindow_Initialized(object sender, EventArgs e)
         {
             string dir = AppDomain.CurrentDomain.BaseDirectory;
             UpdateDownloader.CreateTempDirectory();
@@ -82,12 +77,12 @@ namespace PixiEditor
                     ProcessHelper.RunAsAdmin(updaterPath);
                     Close();
                 }
-                catch(Win32Exception)
+                catch (Win32Exception)
                 {
-                    MessageBox.Show("Couldn't update without administrator rights.", "Insufficient permissions", 
+                    MessageBox.Show("Couldn't update without administrator rights.", "Insufficient permissions",
                         MessageBoxButton.OK, MessageBoxImage.Error);
                 }
             }
         }
     }
-}
+}

+ 0 - 1
PixiEditorTests/ModelsTests/ControllersTests/BitmapManagerTests.cs

@@ -1,7 +1,6 @@
 using System.Windows.Media;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
 using Xunit;

+ 0 - 2
PixiEditorTests/ModelsTests/ControllersTests/MockedSinglePixelPen.cs

@@ -1,10 +1,8 @@
 using System.Windows.Media;
-using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
-using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
 {