Browse Source

Reformatted code style

flabbet 5 years ago
parent
commit
c615dd7a12
100 changed files with 1812 additions and 1842 deletions
  1. 10 10
      PixiEditor/App.xaml
  2. 5 3
      PixiEditor/Exceptions/LengthMismatchException.cs
  3. 20 35
      PixiEditor/Helpers/Behaviours/AllowableCharactersTextBoxBehavior.cs
  4. 12 19
      PixiEditor/Helpers/Behaviours/HintTextBehavior.cs
  5. 17 21
      PixiEditor/Helpers/Behaviours/MouseBehaviour.cs
  6. 20 25
      PixiEditor/Helpers/Behaviours/TextBoxFocusBehavior.cs
  7. 1 5
      PixiEditor/Helpers/Converters/BoolToColorConverter.cs
  8. 1 5
      PixiEditor/Helpers/Converters/BoolToIntConverter.cs
  9. 5 9
      PixiEditor/Helpers/Converters/BoolToInvertedBoolConverter.cs
  10. 3 5
      PixiEditor/Helpers/Converters/ColorToBrushConverter.cs
  11. 5 12
      PixiEditor/Helpers/Converters/OppositeVisibilityConverter.cs
  12. 2 2
      PixiEditor/Helpers/Converters/ToolSizeToIntConverter.cs
  13. 6 11
      PixiEditor/Helpers/Extensions/DictionaryHelper.cs
  14. 3 7
      PixiEditor/Helpers/NotifyableObject.cs
  15. 6 5
      PixiEditor/Helpers/RelayCommand.cs
  16. 3 3
      PixiEditor/Helpers/UI/ReversedOrderStackPanel.cs
  17. 31 35
      PixiEditor/Helpers/UI/RgbColorSlider.cs
  18. 3 6
      PixiEditor/Helpers/Validators/SizeValidationRule.cs
  19. 30 33
      PixiEditor/Models/Colors/ExColor.cs
  20. 40 52
      PixiEditor/Models/Controllers/BitmapManager.cs
  21. 41 40
      PixiEditor/Models/Controllers/BitmapOperationsUtility.cs
  22. 17 27
      PixiEditor/Models/Controllers/ClipboardController.cs
  23. 9 10
      PixiEditor/Models/Controllers/MouseMovementController.cs
  24. 13 24
      PixiEditor/Models/Controllers/PixelChangesController.cs
  25. 3 4
      PixiEditor/Models/Controllers/ReadonlyToolUtility.cs
  26. 9 11
      PixiEditor/Models/Controllers/Shortcuts/Shortcut.cs
  27. 5 8
      PixiEditor/Models/Controllers/Shortcuts/ShortcutController.cs
  28. 19 40
      PixiEditor/Models/Controllers/UndoManager.cs
  29. 13 14
      PixiEditor/Models/DataHolders/Change.cs
  30. 85 65
      PixiEditor/Models/DataHolders/Document.cs
  31. 4 4
      PixiEditor/Models/DataHolders/LayerChanges.cs
  32. 22 24
      PixiEditor/Models/DataHolders/NotifyableColor.cs
  33. 17 21
      PixiEditor/Models/DataHolders/Selection.cs
  34. 19 18
      PixiEditor/Models/DataHolders/SerializableDocument.cs
  35. 7 13
      PixiEditor/Models/DataHolders/StackEx.cs
  36. 11 23
      PixiEditor/Models/DataHolders/Tuple.cs
  37. 3 9
      PixiEditor/Models/Dialogs/ConfirmationDialog.cs
  38. 1 1
      PixiEditor/Models/Dialogs/CustomDialog.cs
  39. 42 22
      PixiEditor/Models/Dialogs/ExportFileDialog.cs
  40. 35 15
      PixiEditor/Models/Dialogs/ImportFileDialog.cs
  41. 23 11
      PixiEditor/Models/Dialogs/NewFileDialog.cs
  42. 33 21
      PixiEditor/Models/Dialogs/ResizeDocumentDialog.cs
  43. 6 8
      PixiEditor/Models/Enums/AnchorPoint.cs
  44. 5 7
      PixiEditor/Models/Enums/ConfirmationType.cs
  45. 2 2
      PixiEditor/Models/Enums/FileType.cs
  46. 5 2
      PixiEditor/Models/Enums/LayerAction.cs
  47. 5 7
      PixiEditor/Models/Enums/SelectionType.cs
  48. 3 6
      PixiEditor/Models/Events/DocumentChangedEventArgs.cs
  49. 2 2
      PixiEditor/Models/IO/BinarySerialization.cs
  50. 32 35
      PixiEditor/Models/IO/Exporter.cs
  51. 11 23
      PixiEditor/Models/IO/FilesManager.cs
  52. 5 5
      PixiEditor/Models/IO/Importer.cs
  53. 21 40
      PixiEditor/Models/ImageManipulation/Morphology.cs
  54. 2 4
      PixiEditor/Models/ImageManipulation/Transform.cs
  55. 24 27
      PixiEditor/Models/Images/BitmapUtils.cs
  56. 1 1
      PixiEditor/Models/Images/ImageGenerator.cs
  57. 16 9
      PixiEditor/Models/Layers/BasicLayer.cs
  58. 78 79
      PixiEditor/Models/Layers/Layer.cs
  59. 3 4
      PixiEditor/Models/Layers/LayerGenerator.cs
  60. 9 11
      PixiEditor/Models/Layers/SerializableLayer.cs
  61. 8 8
      PixiEditor/Models/Position/Coordinates.cs
  62. 106 118
      PixiEditor/Models/Position/CoordinatesCalculator.cs
  63. 1 1
      PixiEditor/Models/Position/DoubleCords.cs
  64. 12 12
      PixiEditor/Models/Position/MousePositionConverter.cs
  65. 4 5
      PixiEditor/Models/Tools/BitmapOperationTool.cs
  66. 13 24
      PixiEditor/Models/Tools/BitmapPixelChanges.cs
  67. 1 1
      PixiEditor/Models/Tools/ReadonlyTool.cs
  68. 38 44
      PixiEditor/Models/Tools/ShapeTool.cs
  69. 28 19
      PixiEditor/Models/Tools/Tool.cs
  70. 8 6
      PixiEditor/Models/Tools/ToolSettings/Settings/BoolSetting.cs
  71. 4 4
      PixiEditor/Models/Tools/ToolSettings/Settings/ColorSetting.cs
  72. 8 11
      PixiEditor/Models/Tools/ToolSettings/Settings/DropdownSetting.cs
  73. 9 10
      PixiEditor/Models/Tools/ToolSettings/Settings/FloatSetting.cs
  74. 12 9
      PixiEditor/Models/Tools/ToolSettings/Settings/Setting.cs
  75. 6 6
      PixiEditor/Models/Tools/ToolSettings/Settings/SizeSetting.cs
  76. 1 1
      PixiEditor/Models/Tools/ToolSettings/Toolbars/BasicShapeToolbar.cs
  77. 1 1
      PixiEditor/Models/Tools/ToolSettings/Toolbars/BasicToolbar.cs
  78. 1 1
      PixiEditor/Models/Tools/ToolSettings/Toolbars/BrightnessToolToolbar.cs
  79. 1 2
      PixiEditor/Models/Tools/ToolSettings/Toolbars/EmptyToolbar.cs
  80. 2 5
      PixiEditor/Models/Tools/ToolSettings/Toolbars/SelectToolToolbar.cs
  81. 3 15
      PixiEditor/Models/Tools/ToolSettings/Toolbars/Toolbar.cs
  82. 12 2
      PixiEditor/Models/Tools/ToolType.cs
  83. 36 33
      PixiEditor/Models/Tools/Tools/BrightnessTool.cs
  84. 47 53
      PixiEditor/Models/Tools/Tools/CircleTool.cs
  85. 12 8
      PixiEditor/Models/Tools/Tools/ColorPickerTool.cs
  86. 7 7
      PixiEditor/Models/Tools/Tools/EarserTool.cs
  87. 13 12
      PixiEditor/Models/Tools/Tools/FloodFill.cs
  88. 41 47
      PixiEditor/Models/Tools/Tools/LineTool.cs
  89. 40 41
      PixiEditor/Models/Tools/Tools/MoveTool.cs
  90. 18 16
      PixiEditor/Models/Tools/Tools/PenTool.cs
  91. 56 56
      PixiEditor/Models/Tools/Tools/RectangleTool.cs
  92. 14 16
      PixiEditor/Models/Tools/Tools/SelectTool.cs
  93. 5 5
      PixiEditor/Properties/AssemblyInfo.cs
  94. 1 0
      PixiEditor/Properties/Settings.settings
  95. 32 24
      PixiEditor/Styles/AnchorPointToggleButtonStyle.xaml
  96. 71 56
      PixiEditor/Styles/ColorSliderStyle.xaml
  97. 3 3
      PixiEditor/Styles/ColorToggleButton.xaml
  98. 185 105
      PixiEditor/Styles/ComboBoxDarkStyle.xaml
  99. 5 5
      PixiEditor/Styles/DockingManagerStyle.xaml
  100. 63 50
      PixiEditor/Styles/MenuButtonStyle.xaml

+ 10 - 10
PixiEditor/App.xaml

@@ -5,16 +5,16 @@
     <Application.Resources>
     <Application.Resources>
         <ResourceDictionary>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
             <ResourceDictionary.MergedDictionaries>
-                <ResourceDictionary Source="Styles/ThemeColors.xaml"/>
-                <ResourceDictionary Source="Styles/MenuButtonStyle.xaml"/>
-                <ResourceDictionary Source="Styles/ThemeStyle.xaml"/>
-                <ResourceDictionary Source="Styles/Titlebar.xaml"/>
-                <ResourceDictionary Source="Styles/ComboBoxDarkStyle.xaml"/>
-                <ResourceDictionary Source="Styles/ColorSliderStyle.xaml"/>
-                <ResourceDictionary Source="Styles/ColorToggleButton.xaml"/>
-                <ResourceDictionary Source="Styles/AnchorPointToggleButtonStyle.xaml"/>
-                <ResourceDictionary Source="Styles/DockingManagerStyle.xaml"/>
+                <ResourceDictionary Source="Styles/ThemeColors.xaml" />
+                <ResourceDictionary Source="Styles/MenuButtonStyle.xaml" />
+                <ResourceDictionary Source="Styles/ThemeStyle.xaml" />
+                <ResourceDictionary Source="Styles/Titlebar.xaml" />
+                <ResourceDictionary Source="Styles/ComboBoxDarkStyle.xaml" />
+                <ResourceDictionary Source="Styles/ColorSliderStyle.xaml" />
+                <ResourceDictionary Source="Styles/ColorToggleButton.xaml" />
+                <ResourceDictionary Source="Styles/AnchorPointToggleButtonStyle.xaml" />
+                <ResourceDictionary Source="Styles/DockingManagerStyle.xaml" />
             </ResourceDictionary.MergedDictionaries>
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
         </ResourceDictionary>
     </Application.Resources>
     </Application.Resources>
-</Application>
+</Application>

+ 5 - 3
PixiEditor/Exceptions/LengthMismatchException.cs

@@ -6,10 +6,12 @@ namespace PixiEditor.Exceptions
     {
     {
         public const string DefaultMessage = "First array length doesn't match second array length";
         public const string DefaultMessage = "First array length doesn't match second array length";
 
 
-        public ArrayLengthMismatchException() : base(DefaultMessage) { }
-        public ArrayLengthMismatchException(string message) : base(message)
+        public ArrayLengthMismatchException() : base(DefaultMessage)
         {
         {
+        }
 
 
+        public ArrayLengthMismatchException(string message) : base(message)
+        {
         }
         }
     }
     }
-}
+}

+ 20 - 35
PixiEditor/Helpers/Behaviours/AllowableCharactersTextBoxBehavior.cs

@@ -10,33 +10,23 @@ namespace PixiEditor.Helpers.Behaviours
     public class AllowableCharactersTextBoxBehavior : Behavior<TextBox>
     public class AllowableCharactersTextBoxBehavior : Behavior<TextBox>
     {
     {
         public static readonly DependencyProperty RegularExpressionProperty =
         public static readonly DependencyProperty RegularExpressionProperty =
-             DependencyProperty.Register("RegularExpression", typeof(string), typeof(AllowableCharactersTextBoxBehavior),
-             new FrameworkPropertyMetadata(".*"));
+            DependencyProperty.Register("RegularExpression", typeof(string), typeof(AllowableCharactersTextBoxBehavior),
+                new FrameworkPropertyMetadata(".*"));
+
+        public static readonly DependencyProperty MaxLengthProperty =
+            DependencyProperty.Register("MaxLength", typeof(int), typeof(AllowableCharactersTextBoxBehavior),
+                new FrameworkPropertyMetadata(int.MinValue));
+
         public string RegularExpression
         public string RegularExpression
         {
         {
-            get
-            {
-                return (string)base.GetValue(RegularExpressionProperty);
-            }
-            set
-            {
-                base.SetValue(RegularExpressionProperty, value);
-            }
+            get => (string) GetValue(RegularExpressionProperty);
+            set => SetValue(RegularExpressionProperty, value);
         }
         }
 
 
-        public static readonly DependencyProperty MaxLengthProperty =
-            DependencyProperty.Register("MaxLength", typeof(int), typeof(AllowableCharactersTextBoxBehavior),
-            new FrameworkPropertyMetadata(int.MinValue));
         public int MaxLength
         public int MaxLength
         {
         {
-            get
-            {
-                return (int)base.GetValue(MaxLengthProperty);
-            }
-            set
-            {
-                base.SetValue(MaxLengthProperty, value);
-            }
+            get => (int) GetValue(MaxLengthProperty);
+            set => SetValue(MaxLengthProperty, value);
         }
         }
 
 
         protected override void OnAttached()
         protected override void OnAttached()
@@ -52,10 +42,7 @@ namespace PixiEditor.Helpers.Behaviours
             {
             {
                 string text = Convert.ToString(e.DataObject.GetData(DataFormats.Text));
                 string text = Convert.ToString(e.DataObject.GetData(DataFormats.Text));
 
 
-                if (!IsValid(text, true))
-                {
-                    e.CancelCommand();
-                }
+                if (!IsValid(text, true)) e.CancelCommand();
             }
             }
             else
             else
             {
             {
@@ -63,7 +50,7 @@ namespace PixiEditor.Helpers.Behaviours
             }
             }
         }
         }
 
 
-        void OnPreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
+        private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
         {
         {
             e.Handled = !IsValid(e.Text, false);
             e.Handled = !IsValid(e.Text, false);
         }
         }
@@ -89,21 +76,19 @@ namespace PixiEditor.Helpers.Behaviours
 
 
         private int LengthOfModifiedText(string newText, bool paste)
         private int LengthOfModifiedText(string newText, bool paste)
         {
         {
-            var countOfSelectedChars = this.AssociatedObject.SelectedText.Length;
-            var caretIndex = this.AssociatedObject.CaretIndex;
-            string text = this.AssociatedObject.Text;
+            var countOfSelectedChars = AssociatedObject.SelectedText.Length;
+            var caretIndex = AssociatedObject.CaretIndex;
+            string text = AssociatedObject.Text;
 
 
             if (countOfSelectedChars > 0 || paste)
             if (countOfSelectedChars > 0 || paste)
             {
             {
                 text = text.Remove(caretIndex, countOfSelectedChars);
                 text = text.Remove(caretIndex, countOfSelectedChars);
                 return text.Length + newText.Length;
                 return text.Length + newText.Length;
             }
             }
-            else
-            {
-                var insert = Keyboard.IsKeyToggled(Key.Insert);
 
 
-                return insert && caretIndex < text.Length ? text.Length : text.Length + newText.Length;
-            }
+            var insert = Keyboard.IsKeyToggled(Key.Insert);
+
+            return insert && caretIndex < text.Length ? text.Length : text.Length + newText.Length;
         }
         }
     }
     }
-}
+}

+ 12 - 19
PixiEditor/Helpers/Behaviours/HintTextBehavior.cs

@@ -5,22 +5,21 @@ using System.Windows.Media;
 
 
 namespace PixiEditor.Helpers.Behaviours
 namespace PixiEditor.Helpers.Behaviours
 {
 {
-    class HintTextBehavior : Behavior<TextBox>
+    internal class HintTextBehavior : Behavior<TextBox>
     {
     {
+        // Using a DependencyProperty as the backing store for Hint.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty HintProperty =
+            DependencyProperty.Register("Hint", typeof(string), typeof(HintTextBehavior),
+                new PropertyMetadata(string.Empty));
 
 
         private Brush _textColor;
         private Brush _textColor;
 
 
         public string Hint
         public string Hint
         {
         {
-            get { return (string)GetValue(HintProperty); }
-            set { SetValue(HintProperty, value); }
+            get => (string) GetValue(HintProperty);
+            set => SetValue(HintProperty, value);
         }
         }
 
 
-        // Using a DependencyProperty as the backing store for Hint.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty HintProperty =
-            DependencyProperty.Register("Hint", typeof(string), typeof(HintTextBehavior), new PropertyMetadata(string.Empty));
-
-
 
 
         protected override void OnAttached()
         protected override void OnAttached()
         {
         {
@@ -33,25 +32,19 @@ namespace PixiEditor.Helpers.Behaviours
 
 
         private void AssociatedObject_LostFocus(object sender, RoutedEventArgs e)
         private void AssociatedObject_LostFocus(object sender, RoutedEventArgs e)
         {
         {
-            if (string.IsNullOrEmpty(AssociatedObject.Text) == true)
-            {
-                SetHint(true);
-            }
+            if (string.IsNullOrEmpty(AssociatedObject.Text)) SetHint(true);
         }
         }
 
 
         private void AssociatedObject_GotFocus(object sender, RoutedEventArgs e)
         private void AssociatedObject_GotFocus(object sender, RoutedEventArgs e)
         {
         {
-            if (AssociatedObject.Text == Hint)
-            {
-                SetHint(false);
-            }
+            if (AssociatedObject.Text == Hint) SetHint(false);
         }
         }
 
 
         private void SetHint(bool active)
         private void SetHint(bool active)
         {
         {
-            if (active == true)
+            if (active)
             {
             {
-                AssociatedObject.Foreground = (SolidColorBrush)new BrushConverter().ConvertFromString("#7B7B7B");
+                AssociatedObject.Foreground = (SolidColorBrush) new BrushConverter().ConvertFromString("#7B7B7B");
                 AssociatedObject.Text = Hint;
                 AssociatedObject.Text = Hint;
             }
             }
             else
             else
@@ -68,4 +61,4 @@ namespace PixiEditor.Helpers.Behaviours
             AssociatedObject.GotFocus -= AssociatedObject_GotFocus;
             AssociatedObject.GotFocus -= AssociatedObject_GotFocus;
         }
         }
     }
     }
-}
+}

+ 17 - 21
PixiEditor/Helpers/Behaviours/MouseBehaviour.cs

@@ -1,42 +1,41 @@
 using System.Windows;
 using System.Windows;
 using System.Windows.Input;
 using System.Windows.Input;
+using System.Windows.Interactivity;
 
 
 namespace PixiEditor.Helpers.Behaviours
 namespace PixiEditor.Helpers.Behaviours
 {
 {
-
-    public class MouseBehaviour : System.Windows.Interactivity.Behavior<FrameworkElement>
+    public class MouseBehaviour : Behavior<FrameworkElement>
     {
     {
         public static readonly DependencyProperty MouseYProperty = DependencyProperty.Register(
         public static readonly DependencyProperty MouseYProperty = DependencyProperty.Register(
             "MouseY", typeof(double), typeof(MouseBehaviour), new PropertyMetadata(default(double)));
             "MouseY", typeof(double), typeof(MouseBehaviour), new PropertyMetadata(default(double)));
 
 
+        public static readonly DependencyProperty MouseXProperty = DependencyProperty.Register(
+            "MouseX", typeof(double), typeof(MouseBehaviour), new PropertyMetadata(default(double)));
+
+        // Using a DependencyProperty as the backing store for RelativeTo.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty RelativeToProperty =
+            DependencyProperty.Register("RelativeTo", typeof(FrameworkElement), typeof(MouseBehaviour),
+                new PropertyMetadata(default(FrameworkElement)));
+
         public double MouseY
         public double MouseY
         {
         {
-            get { return (double)GetValue(MouseYProperty); }
-            set { SetValue(MouseYProperty, value); }
+            get => (double) GetValue(MouseYProperty);
+            set => SetValue(MouseYProperty, value);
         }
         }
 
 
-        public static readonly DependencyProperty MouseXProperty = DependencyProperty.Register(
-            "MouseX", typeof(double), typeof(MouseBehaviour), new PropertyMetadata(default(double)));
-
         public double MouseX
         public double MouseX
         {
         {
-            get { return (double)GetValue(MouseXProperty); }
-            set { SetValue(MouseXProperty, value); }
+            get => (double) GetValue(MouseXProperty);
+            set => SetValue(MouseXProperty, value);
         }
         }
 
 
 
 
-
         public FrameworkElement RelativeTo
         public FrameworkElement RelativeTo
         {
         {
-            get { return (FrameworkElement)GetValue(RelativeToProperty); }
-            set { SetValue(RelativeToProperty, value); }
+            get => (FrameworkElement) GetValue(RelativeToProperty);
+            set => SetValue(RelativeToProperty, value);
         }
         }
 
 
-        // Using a DependencyProperty as the backing store for RelativeTo.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty RelativeToProperty =
-            DependencyProperty.Register("RelativeTo", typeof(FrameworkElement), typeof(MouseBehaviour), new PropertyMetadata(default(FrameworkElement)));
-
-
 
 
         protected override void OnAttached()
         protected override void OnAttached()
         {
         {
@@ -45,10 +44,7 @@ namespace PixiEditor.Helpers.Behaviours
 
 
         private void AssociatedObjectOnMouseMove(object sender, MouseEventArgs mouseEventArgs)
         private void AssociatedObjectOnMouseMove(object sender, MouseEventArgs mouseEventArgs)
         {
         {
-            if (RelativeTo == null)
-            {
-                RelativeTo = AssociatedObject;
-            }
+            if (RelativeTo == null) RelativeTo = AssociatedObject;
             var pos = mouseEventArgs.GetPosition(RelativeTo);
             var pos = mouseEventArgs.GetPosition(RelativeTo);
             MouseX = pos.X;
             MouseX = pos.X;
             MouseY = pos.Y;
             MouseY = pos.Y;

+ 20 - 25
PixiEditor/Helpers/Behaviours/TextBoxFocusBehavior.cs

@@ -6,28 +6,27 @@ using System.Windows.Interactivity;
 
 
 namespace PixiEditor.Helpers.Behaviours
 namespace PixiEditor.Helpers.Behaviours
 {
 {
-    class TextBoxFocusBehavior : Behavior<TextBox>
+    internal class TextBoxFocusBehavior : Behavior<TextBox>
     {
     {
-
-        public bool FillSize
-        {
-            get { return (bool)GetValue(FillSizeProperty); }
-            set { SetValue(FillSizeProperty, value); }
-        }
-
         // Using a DependencyProperty as the backing store for FillSize.  This enables animation, styling, binding, etc...
         // Using a DependencyProperty as the backing store for FillSize.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty FillSizeProperty =
         public static readonly DependencyProperty FillSizeProperty =
-            DependencyProperty.Register("FillSize", typeof(bool), typeof(TextBoxFocusBehavior), new PropertyMetadata(false));
-
+            DependencyProperty.Register("FillSize", typeof(bool), typeof(TextBoxFocusBehavior),
+                new PropertyMetadata(false));
 
 
 
 
         private string _oldText; //Value of textbox before editing
         private string _oldText; //Value of textbox before editing
-        private bool _valueConverted = false; //This bool is used to avoid double convertion if enter is hitted
+        private bool _valueConverted; //This bool is used to avoid double convertion if enter is hitted
+
+        public bool FillSize
+        {
+            get => (bool) GetValue(FillSizeProperty);
+            set => SetValue(FillSizeProperty, value);
+        }
 
 
         //Converts number to proper format if enter is clicked and moves focus to next object
         //Converts number to proper format if enter is clicked and moves focus to next object
-        private void AssociatedObject_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
+        private void AssociatedObject_KeyUp(object sender, KeyEventArgs e)
         {
         {
-            if (e.Key != System.Windows.Input.Key.Enter) return;
+            if (e.Key != Key.Enter) return;
 
 
             ConvertValue();
             ConvertValue();
             AssociatedObject.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down));
             AssociatedObject.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down));
@@ -54,7 +53,7 @@ namespace PixiEditor.Helpers.Behaviours
         }
         }
 
 
         private void AssociatedObjectGotKeyboardFocus(object sender,
         private void AssociatedObjectGotKeyboardFocus(object sender,
-            System.Windows.Input.KeyboardFocusChangedEventArgs e)
+            KeyboardFocusChangedEventArgs e)
         {
         {
             AssociatedObject.SelectAll();
             AssociatedObject.SelectAll();
             if (FillSize)
             if (FillSize)
@@ -65,7 +64,7 @@ namespace PixiEditor.Helpers.Behaviours
         }
         }
 
 
         private void AssociatedObjectGotMouseCapture(object sender,
         private void AssociatedObjectGotMouseCapture(object sender,
-            System.Windows.Input.MouseEventArgs e)
+            MouseEventArgs e)
         {
         {
             AssociatedObject.SelectAll();
             AssociatedObject.SelectAll();
         }
         }
@@ -79,27 +78,23 @@ namespace PixiEditor.Helpers.Behaviours
             }
             }
         }
         }
 
 
-        private void AssociatedObject_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
+        private void AssociatedObject_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
         {
         {
             ConvertValue();
             ConvertValue();
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Converts number from textbox to format "number px" ex. "15 px"
+        ///     Converts number from textbox to format "number px" ex. "15 px"
         /// </summary>
         /// </summary>
         private void ConvertValue()
         private void ConvertValue()
         {
         {
-            if (_valueConverted == true || FillSize == false) return;
-            
-            if (int.TryParse(Regex.Replace(AssociatedObject.Text, "\\p{L}", ""), out int result) == true && result > 0)
-            {
+            if (_valueConverted || FillSize == false) return;
+
+            if (int.TryParse(Regex.Replace(AssociatedObject.Text, "\\p{L}", ""), out int result) && result > 0)
                 AssociatedObject.Text = string.Format("{0} {1}", AssociatedObject.Text, "px");
                 AssociatedObject.Text = string.Format("{0} {1}", AssociatedObject.Text, "px");
-            }
             else //If text in textbox isn't number, set it to old value
             else //If text in textbox isn't number, set it to old value
-            {
                 AssociatedObject.Text = _oldText;
                 AssociatedObject.Text = _oldText;
-            }
             _valueConverted = true;
             _valueConverted = true;
         }
         }
     }
     }
-}
+}

+ 1 - 5
PixiEditor/Helpers/Converters/BoolToColorConverter.cs

@@ -14,13 +14,9 @@ namespace PixiEditor.Helpers.Converters
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
             if (value is bool boolean)
             if (value is bool boolean)
-            {
                 if (boolean == false)
                 if (boolean == false)
-                {
                     return "Transparent";
                     return "Transparent";
-                }
-            }
             return "#638DCA";
             return "#638DCA";
         }
         }
     }
     }
-}
+}

+ 1 - 5
PixiEditor/Helpers/Converters/BoolToIntConverter.cs

@@ -14,13 +14,9 @@ namespace PixiEditor.Helpers.Converters
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
             if (value is bool boolean)
             if (value is bool boolean)
-            {
                 if (boolean == false)
                 if (boolean == false)
-                {
                     return 0;
                     return 0;
-                }
-            }
             return 1;
             return 1;
         }
         }
     }
     }
-}
+}

+ 5 - 9
PixiEditor/Helpers/Converters/BoolToInvertedBoolConverter.cs

@@ -1,25 +1,21 @@
 using System;
 using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Globalization;
 using System.Windows.Data;
 using System.Windows.Data;
 
 
 namespace PixiEditor.Helpers.Converters
 namespace PixiEditor.Helpers.Converters
 {
 {
     public class BoolToInvertedBoolConverter : IValueConverter
     public class BoolToInvertedBoolConverter : IValueConverter
     {
     {
-        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
             if (value is bool boolValue)
             if (value is bool boolValue)
-            {
                 return !boolValue;
                 return !boolValue;
-            }
-            else
-                return false;
+            return false;
         }
         }
 
 
-        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
             throw new NotImplementedException("ConvertBack() of BoolToInvertedBoolConverter is not implemented");
             throw new NotImplementedException("ConvertBack() of BoolToInvertedBoolConverter is not implemented");
         }
         }
     }
     }
-}
+}

+ 3 - 5
PixiEditor/Helpers/Converters/ColorToBrushConverter.cs

@@ -1,7 +1,5 @@
 using System;
 using System;
-using System.Collections.Generic;
 using System.Globalization;
 using System.Globalization;
-using System.Text;
 using System.Windows.Data;
 using System.Windows.Data;
 using System.Windows.Media;
 using System.Windows.Media;
 
 
@@ -11,16 +9,16 @@ namespace PixiEditor.Helpers.Converters
     {
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
-            Color col = (Color)value;
+            Color col = (Color) value;
             Color c = Color.FromArgb(col.A, col.R, col.G, col.B);
             Color c = Color.FromArgb(col.A, col.R, col.G, col.B);
             return new SolidColorBrush(c);
             return new SolidColorBrush(c);
         }
         }
 
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
-            SolidColorBrush c = (SolidColorBrush)value;
+            SolidColorBrush c = (SolidColorBrush) value;
             Color col = Color.FromArgb(c.Color.A, c.Color.R, c.Color.G, c.Color.B);
             Color col = Color.FromArgb(c.Color.A, c.Color.R, c.Color.G, c.Color.B);
             return col;
             return col;
         }
         }
     }
     }
-}
+}

+ 5 - 12
PixiEditor/Helpers/Converters/OppositeVisibilityConverter.cs

@@ -9,10 +9,7 @@ namespace PixiEditor.Helpers.Converters
     {
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
-            if (value.ToString().ToLower() == "visible")
-            {
-                return Visibility.Hidden;
-            }
+            if (value.ToString().ToLower() == "visible") return Visibility.Hidden;
             return Visibility.Visible;
             return Visibility.Visible;
         }
         }
 
 
@@ -20,16 +17,12 @@ namespace PixiEditor.Helpers.Converters
         {
         {
             if (value is Visibility)
             if (value is Visibility)
             {
             {
-                if ((Visibility)value == Visibility.Visible)
-                {
+                if ((Visibility) value == Visibility.Visible)
                     return "Hidden";
                     return "Hidden";
-                }
-                else
-                {
-                    return "Visible";
-                }
+                return "Visible";
             }
             }
+
             return null;
             return null;
         }
         }
     }
     }
-}
+}

+ 2 - 2
PixiEditor/Helpers/Converters/ToolSizeToIntConverter.cs

@@ -7,7 +7,7 @@ using System.Windows.Data;
 namespace PixiEditor.Helpers
 namespace PixiEditor.Helpers
 {
 {
     [ValueConversion(typeof(string), typeof(int))]
     [ValueConversion(typeof(string), typeof(int))]
-    class ToolSizeToIntConverter : IValueConverter
+    internal class ToolSizeToIntConverter : IValueConverter
     {
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {
@@ -23,4 +23,4 @@ namespace PixiEditor.Helpers
             return int.Parse(slicedString);
             return int.Parse(slicedString);
         }
         }
     }
     }
-}
+}

+ 6 - 11
PixiEditor/Helpers/Extensions/DictionaryHelper.cs

@@ -4,23 +4,18 @@ namespace PixiEditor.Helpers.Extensions
 {
 {
     public static class DictionaryHelper
     public static class DictionaryHelper
     {
     {
-        public static void AddRangeOverride<TKey, TValue>(this IDictionary<TKey, TValue> dict, IDictionary<TKey, TValue> dictToAdd)
+        public static void AddRangeOverride<TKey, TValue>(this IDictionary<TKey, TValue> dict,
+            IDictionary<TKey, TValue> dictToAdd)
         {
         {
-            foreach (var item in dictToAdd)
-            {
-                dict[item.Key] = item.Value;
-            }
+            foreach (var item in dictToAdd) dict[item.Key] = item.Value;
         }
         }
 
 
-        public static void AddRangeNewOnly<TKey, TValue>(this IDictionary<TKey, TValue> dict, IDictionary<TKey, TValue> dictToAdd)
+        public static void AddRangeNewOnly<TKey, TValue>(this IDictionary<TKey, TValue> dict,
+            IDictionary<TKey, TValue> dictToAdd)
         {
         {
             foreach (var item in dictToAdd)
             foreach (var item in dictToAdd)
-            {
                 if (!dict.ContainsKey(item.Key))
                 if (!dict.ContainsKey(item.Key))
-                {
                     dict.Add(item.Key, item.Value);
                     dict.Add(item.Key, item.Value);
-                }
-            }
         }
         }
     }
     }
-}
+}

+ 3 - 7
PixiEditor/Helpers/NotifyableObject.cs

@@ -6,15 +6,11 @@ namespace PixiEditor.Helpers
     [Serializable]
     [Serializable]
     public class NotifyableObject : INotifyPropertyChanged
     public class NotifyableObject : INotifyPropertyChanged
     {
     {
-        [field: NonSerialized]
-        public event PropertyChangedEventHandler PropertyChanged = delegate { };
+        [field: NonSerialized] public event PropertyChangedEventHandler PropertyChanged = delegate { };
 
 
         protected void RaisePropertyChanged(string property)
         protected void RaisePropertyChanged(string property)
         {
         {
-            if (property != null)
-            {
-                PropertyChanged(this, new PropertyChangedEventArgs(property));
-            }
+            if (property != null) PropertyChanged(this, new PropertyChangedEventArgs(property));
         }
         }
     }
     }
-}
+}

+ 6 - 5
PixiEditor/Helpers/RelayCommand.cs

@@ -7,8 +7,8 @@ namespace PixiEditor.Helpers
     {
     {
         #region Fields
         #region Fields
 
 
-        readonly Action<object> _execute;
-        readonly Predicate<object> _canExecute;
+        private readonly Action<object> _execute;
+        private readonly Predicate<object> _canExecute;
 
 
         #endregion // Fields
         #endregion // Fields
 
 
@@ -27,6 +27,7 @@ namespace PixiEditor.Helpers
             _execute = execute;
             _execute = execute;
             _canExecute = canExecute;
             _canExecute = canExecute;
         }
         }
+
         #endregion // Constructors
         #endregion // Constructors
 
 
         #region ICommand Members
         #region ICommand Members
@@ -38,8 +39,8 @@ namespace PixiEditor.Helpers
 
 
         public event EventHandler CanExecuteChanged
         public event EventHandler CanExecuteChanged
         {
         {
-            add { CommandManager.RequerySuggested += value; }
-            remove { CommandManager.RequerySuggested -= value; }
+            add => CommandManager.RequerySuggested += value;
+            remove => CommandManager.RequerySuggested -= value;
         }
         }
 
 
         public void Execute(object parameter)
         public void Execute(object parameter)
@@ -49,4 +50,4 @@ namespace PixiEditor.Helpers
 
 
         #endregion // ICommand Members
         #endregion // ICommand Members
     }
     }
-}
+}

+ 3 - 3
PixiEditor/Helpers/UI/ReversedOrderStackPanel.cs

@@ -7,9 +7,9 @@ namespace PixiEditor.Helpers.UI
 {
 {
     public class ReversedOrderStackPanel : StackPanel
     public class ReversedOrderStackPanel : StackPanel
     {
     {
-        protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize)
+        protected override Size ArrangeOverride(Size arrangeSize)
         {
         {
-            bool fHorizontal = (Orientation == Orientation.Horizontal);
+            bool fHorizontal = Orientation == Orientation.Horizontal;
             var rcChild = new Rect(arrangeSize);
             var rcChild = new Rect(arrangeSize);
             double previousChildSize = 0.0;
             double previousChildSize = 0.0;
 
 
@@ -40,4 +40,4 @@ namespace PixiEditor.Helpers.UI
             return arrangeSize;
             return arrangeSize;
         }
         }
     }
     }
-}
+}

+ 31 - 35
PixiEditor/Helpers/UI/RgbColorSlider.cs

@@ -1,15 +1,21 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Media;
 using System.Windows.Media;
-using System.Windows.Media.Imaging;
 
 
 namespace PixiEditor.Helpers.UI
 namespace PixiEditor.Helpers.UI
 {
 {
     public class RgbColorSlider : Slider
     public class RgbColorSlider : Slider
     {
     {
+        // Using a DependencyProperty as the backing store for SliderArgbType.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty SliderArgbTypeProperty =
+            DependencyProperty.Register("SliderArgbType", typeof(string), typeof(RgbColorSlider),
+                new PropertyMetadata(""));
+
+        // Using a DependencyProperty as the backing store for CurrentColor.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty CurrentColorProperty =
+            DependencyProperty.Register("CurrentColor", typeof(Color), typeof(RgbColorSlider),
+                new PropertyMetadata(Colors.Black, ColorChangedCallback));
+
         public RgbColorSlider()
         public RgbColorSlider()
         {
         {
             Minimum = 0;
             Minimum = 0;
@@ -19,6 +25,20 @@ namespace PixiEditor.Helpers.UI
             MinHeight = 12;
             MinHeight = 12;
         }
         }
 
 
+
+        public string SliderArgbType
+        {
+            get => (string) GetValue(SliderArgbTypeProperty);
+            set => SetValue(SliderArgbTypeProperty, value);
+        }
+
+
+        public Color CurrentColor
+        {
+            get => (Color) GetValue(CurrentColorProperty);
+            set => SetValue(CurrentColorProperty, value);
+        }
+
         public override void EndInit()
         public override void EndInit()
         {
         {
             base.EndInit();
             base.EndInit();
@@ -28,9 +48,10 @@ namespace PixiEditor.Helpers.UI
 
 
         private void GenerateBackground()
         private void GenerateBackground()
         {
         {
-            Background = new LinearGradientBrush(new GradientStopCollection() {
+            Background = new LinearGradientBrush(new GradientStopCollection
+            {
                 new GradientStop(GetColorForSelectedArgb(0), 0.0),
                 new GradientStop(GetColorForSelectedArgb(0), 0.0),
-                new GradientStop(GetColorForSelectedArgb(255), 1),
+                new GradientStop(GetColorForSelectedArgb(255), 1)
             });
             });
         }
         }
 
 
@@ -42,39 +63,14 @@ namespace PixiEditor.Helpers.UI
                 "R" => Color.FromArgb(CurrentColor.A, value, CurrentColor.G, CurrentColor.B),
                 "R" => Color.FromArgb(CurrentColor.A, value, CurrentColor.G, CurrentColor.B),
                 "G" => Color.FromArgb(CurrentColor.A, CurrentColor.R, value, CurrentColor.B),
                 "G" => Color.FromArgb(CurrentColor.A, CurrentColor.R, value, CurrentColor.B),
                 "B" => Color.FromArgb(CurrentColor.A, CurrentColor.R, CurrentColor.G, value),
                 "B" => Color.FromArgb(CurrentColor.A, CurrentColor.R, CurrentColor.G, value),
-                _ => CurrentColor,
+                _ => CurrentColor
             };
             };
         }
         }
 
 
-
-
-        public string SliderArgbType
-        {
-            get { return (string)GetValue(SliderArgbTypeProperty); }
-            set { SetValue(SliderArgbTypeProperty, value); }
-        }
-
-        // Using a DependencyProperty as the backing store for SliderArgbType.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty SliderArgbTypeProperty =
-            DependencyProperty.Register("SliderArgbType", typeof(string), typeof(RgbColorSlider), new PropertyMetadata(""));
-
-
-
-        public Color CurrentColor
-        {
-            get { return (Color)GetValue(CurrentColorProperty); }
-            set { SetValue(CurrentColorProperty, value); }
-        }
-
-        // Using a DependencyProperty as the backing store for CurrentColor.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty CurrentColorProperty =
-            DependencyProperty.Register("CurrentColor", typeof(Color), typeof(RgbColorSlider), 
-                new PropertyMetadata(Colors.Black, ColorChangedCallback));
-
         private static void ColorChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
         private static void ColorChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
         {
-            RgbColorSlider slider = (RgbColorSlider)d;
+            RgbColorSlider slider = (RgbColorSlider) d;
             slider.GenerateBackground();
             slider.GenerateBackground();
         }
         }
     }
     }
-}
+}

+ 3 - 6
PixiEditor/Helpers/Validators/SizeValidationRule.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Text;
+using System.Globalization;
 using System.Windows.Controls;
 using System.Windows.Controls;
 
 
 namespace PixiEditor.Helpers.Validators
 namespace PixiEditor.Helpers.Validators
@@ -10,7 +7,7 @@ namespace PixiEditor.Helpers.Validators
     {
     {
         public override ValidationResult Validate(object value, CultureInfo cultureInfo)
         public override ValidationResult Validate(object value, CultureInfo cultureInfo)
         {
         {
-            return new ValidationResult(int.Parse(((string)value).Split(' ')[0]) > 0, null); //Size is greater than 0
+            return new ValidationResult(int.Parse(((string) value).Split(' ')[0]) > 0, null); //Size is greater than 0
         }
         }
     }
     }
-}
+}

+ 30 - 33
PixiEditor/Models/Colors/ExColor.cs

@@ -6,13 +6,15 @@ namespace PixiEditor.Models.Colors
     public static class ExColor
     public static class ExColor
     {
     {
         /// <summary>
         /// <summary>
-        /// Creates color with corrected brightness.
+        ///     Creates color with corrected brightness.
         /// </summary>
         /// </summary>
         /// <param name="color">Color to correct.</param>
         /// <param name="color">Color to correct.</param>
-        /// <param name="correctionFactor">The brightness correction factor. Must be between -1 and 1. 
-        /// Negative values produce darker colors.</param>
+        /// <param name="correctionFactor">
+        ///     The brightness correction factor. Must be between -1 and 1.
+        ///     Negative values produce darker colors.
+        /// </param>
         /// <returns>
         /// <returns>
-        /// Corrected <see cref="Color"/> structure.
+        ///     Corrected <see cref="Color" /> structure.
         /// </returns>
         /// </returns>
         public static Color ChangeColorBrightness(Color color, float correctionFactor)
         public static Color ChangeColorBrightness(Color color, float correctionFactor)
         {
         {
@@ -29,7 +31,7 @@ namespace PixiEditor.Models.Colors
 
 
 
 
         /// <summary>
         /// <summary>
-        /// Converts RGB to HSL
+        ///     Converts RGB to HSL
         /// </summary>
         /// </summary>
         /// <param name="r">Red value</param>
         /// <param name="r">Red value</param>
         /// <param name="b">Blue value</param>
         /// <param name="b">Blue value</param>
@@ -39,9 +41,9 @@ namespace PixiEditor.Models.Colors
         {
         {
             int h;
             int h;
             float s, l;
             float s, l;
-            float dR = (r / 255.0f);
-            float dG = (g / 255.0f);
-            float dB = (b / 255.0f);
+            float dR = r / 255.0f;
+            float dG = g / 255.0f;
+            float dB = b / 255.0f;
 
 
             float min = Math.Min(Math.Min(dR, dG), dB);
             float min = Math.Min(Math.Min(dR, dG), dB);
             float max = Math.Max(Math.Max(dR, dG), dB);
             float max = Math.Max(Math.Max(dR, dG), dB);
@@ -56,35 +58,30 @@ namespace PixiEditor.Models.Colors
             }
             }
             else
             else
             {
             {
-                s = (l <= 0.5) ? (delta / (max + min)) : (delta / (2 - max - min));
+                s = l <= 0.5 ? delta / (max + min) : delta / (2 - max - min);
 
 
                 float hue;
                 float hue;
 
 
                 if (dR == max)
                 if (dR == max)
-                {
-                    hue = ((dG - dB) / 6) / delta;
-                }
+                    hue = (dG - dB) / 6 / delta;
                 else if (dG == max)
                 else if (dG == max)
-                {
-                    hue = (1.0f / 3) + (dB - dR) / 6 / delta;
-                }
+                    hue = 1.0f / 3 + (dB - dR) / 6 / delta;
                 else
                 else
-                {
-                    hue = (2.0f / 3) + (dR - dG) / 6 / delta;
-                }
+                    hue = 2.0f / 3 + (dR - dG) / 6 / delta;
 
 
                 if (hue < 0)
                 if (hue < 0)
                     hue += 1;
                     hue += 1;
                 if (hue > 1)
                 if (hue > 1)
                     hue -= 1;
                     hue -= 1;
 
 
-                h = (int)(hue * 360);
+                h = (int) (hue * 360);
             }
             }
+
             return new Tuple<int, float, float>(h, s * 100, l * 100);
             return new Tuple<int, float, float>(h, s * 100, l * 100);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Converts HSL color format to RGB
+        ///     Converts HSL color format to RGB
         /// </summary>
         /// </summary>
         /// <param name="h"></param>
         /// <param name="h"></param>
         /// <param name="s"></param>
         /// <param name="s"></param>
@@ -100,20 +97,21 @@ namespace PixiEditor.Models.Colors
 
 
             if (s == 0)
             if (s == 0)
             {
             {
-                r = g = b = (byte)(l * 255);
+                r = g = b = (byte) (l * 255);
             }
             }
             else
             else
             {
             {
                 float v1, v2;
                 float v1, v2;
-                float hue = (float)h / 360;
+                float hue = (float) h / 360;
 
 
-                v2 = (l < 0.5) ? (l * (1 + s)) : (l + s - (l * s));
+                v2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
                 v1 = 2 * l - v2;
                 v1 = 2 * l - v2;
 
 
-                r = (byte)(255 * HueToRGB(v1, v2, hue + (1.0f / 3)));
-                g = (byte)(255 * HueToRGB(v1, v2, hue));
-                b = (byte)(255 * HueToRGB(v1, v2, hue - (1.0f / 3)));
+                r = (byte) (255 * HueToRGB(v1, v2, hue + 1.0f / 3));
+                g = (byte) (255 * HueToRGB(v1, v2, hue));
+                b = (byte) (255 * HueToRGB(v1, v2, hue - 1.0f / 3));
             }
             }
+
             return Color.FromRgb(r, g, b);
             return Color.FromRgb(r, g, b);
         }
         }
 
 
@@ -125,17 +123,16 @@ namespace PixiEditor.Models.Colors
             if (hue > 1)
             if (hue > 1)
                 hue -= 1;
                 hue -= 1;
 
 
-            if ((6 * hue) < 1)
-                return (v1 + (v2 - v1) * 6 * hue);
+            if (6 * hue < 1)
+                return v1 + (v2 - v1) * 6 * hue;
 
 
-            if ((2 * hue) < 1)
+            if (2 * hue < 1)
                 return v2;
                 return v2;
 
 
-            if ((3 * hue) < 2)
-                return (v1 + (v2 - v1) * ((2.0f / 3) - hue) * 6);
+            if (3 * hue < 2)
+                return v1 + (v2 - v1) * (2.0f / 3 - hue) * 6;
 
 
             return v1;
             return v1;
         }
         }
-
     }
     }
-}
+}

+ 40 - 52
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -1,4 +1,9 @@
-using PixiEditor.Helpers;
+using System;
+using System.Linq;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using PixiEditor.Helpers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Events;
 using PixiEditor.Models.Events;
@@ -6,18 +11,28 @@ using PixiEditor.Models.Images;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
-using System;
-using System.Linq;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
 
 
 namespace PixiEditor.Models.Controllers
 namespace PixiEditor.Models.Controllers
 {
 {
     public class BitmapManager : NotifyableObject
     public class BitmapManager : NotifyableObject
     {
     {
-        public MouseMovementController MouseController { get; set; }
+        private Document _activeDocument;
+
+        private Layer _previewLayer;
         private Tool _selectedTool;
         private Tool _selectedTool;
+
+        public BitmapManager()
+        {
+            MouseController = new MouseMovementController();
+            MouseController.StartedRecordingChanges += MouseController_StartedRecordingChanges;
+            MouseController.MousePositionChanged += Controller_MousePositionChanged;
+            MouseController.StoppedRecordingChanges += MouseController_StoppedRecordingChanges;
+            BitmapOperations = new BitmapOperationsUtility(this);
+            ReadonlyToolUtility = new ReadonlyToolUtility(this);
+        }
+
+        public MouseMovementController MouseController { get; set; }
+
         public Tool SelectedTool
         public Tool SelectedTool
         {
         {
             get => _selectedTool;
             get => _selectedTool;
@@ -28,11 +43,9 @@ namespace PixiEditor.Models.Controllers
             }
             }
         }
         }
 
 
-        private Layer _previewLayer;
-
         public Layer PreviewLayer
         public Layer PreviewLayer
         {
         {
-            get { return _previewLayer; }
+            get => _previewLayer;
             set
             set
             {
             {
                 _previewLayer = value;
                 _previewLayer = value;
@@ -44,15 +57,13 @@ namespace PixiEditor.Models.Controllers
 
 
         public Color PrimaryColor { get; set; }
         public Color PrimaryColor { get; set; }
 
 
-        public int ToolSize => SelectedTool.Toolbar.GetSetting("ToolSize") != null ? (int)SelectedTool.Toolbar.GetSetting("ToolSize").Value : 1;
-
-        public event EventHandler<LayersChangedEventArgs> LayersChanged;
-        public event EventHandler<DocumentChangedEventArgs> DocumentChanged;
+        public int ToolSize => SelectedTool.Toolbar.GetSetting("ToolSize") != null
+            ? (int) SelectedTool.Toolbar.GetSetting("ToolSize").Value
+            : 1;
 
 
         public BitmapOperationsUtility BitmapOperations { get; set; }
         public BitmapOperationsUtility BitmapOperations { get; set; }
         public ReadonlyToolUtility ReadonlyToolUtility { get; set; }
         public ReadonlyToolUtility ReadonlyToolUtility { get; set; }
 
 
-        private Document _activeDocument;
         public Document ActiveDocument
         public Document ActiveDocument
         {
         {
             get => _activeDocument;
             get => _activeDocument;
@@ -64,6 +75,9 @@ namespace PixiEditor.Models.Controllers
             }
             }
         }
         }
 
 
+        public event EventHandler<LayersChangedEventArgs> LayersChanged;
+        public event EventHandler<DocumentChangedEventArgs> DocumentChanged;
+
         public void SetActiveTool(Tool tool)
         public void SetActiveTool(Tool tool)
         {
         {
             PreviewLayer?.Clear();
             PreviewLayer?.Clear();
@@ -72,22 +86,10 @@ namespace PixiEditor.Models.Controllers
             SelectedTool.Toolbar.LoadSharedSettings();
             SelectedTool.Toolbar.LoadSharedSettings();
         }
         }
 
 
-        public BitmapManager()
-        {
-            MouseController = new MouseMovementController();
-            MouseController.StartedRecordingChanges += MouseController_StartedRecordingChanges;
-            MouseController.MousePositionChanged += Controller_MousePositionChanged;
-            MouseController.StoppedRecordingChanges += MouseController_StoppedRecordingChanges;
-            BitmapOperations = new BitmapOperationsUtility(this);
-            ReadonlyToolUtility = new ReadonlyToolUtility(this);
-        }
-
         public void SetActiveLayer(int index)
         public void SetActiveLayer(int index)
         {
         {
             if (ActiveDocument.ActiveLayerIndex <= ActiveDocument.Layers.Count - 1)
             if (ActiveDocument.ActiveLayerIndex <= ActiveDocument.Layers.Count - 1)
-            {
                 ActiveDocument.ActiveLayer.IsActive = false;
                 ActiveDocument.ActiveLayer.IsActive = false;
-            }
             ActiveDocument.ActiveLayerIndex = index;
             ActiveDocument.ActiveLayerIndex = index;
             ActiveDocument.ActiveLayer.IsActive = true;
             ActiveDocument.ActiveLayer.IsActive = true;
             LayersChanged?.Invoke(this, new LayersChangedEventArgs(index, LayerAction.SetActive));
             LayersChanged?.Invoke(this, new LayersChangedEventArgs(index, LayerAction.SetActive));
@@ -96,10 +98,7 @@ namespace PixiEditor.Models.Controllers
         public void AddNewLayer(string name, int width, int height, bool setAsActive = true)
         public void AddNewLayer(string name, int width, int height, bool setAsActive = true)
         {
         {
             ActiveDocument.Layers.Add(new Layer(name, width, height));
             ActiveDocument.Layers.Add(new Layer(name, width, height));
-            if (setAsActive)
-            {
-                SetActiveLayer(ActiveDocument.Layers.Count - 1);
-            }
+            if (setAsActive) SetActiveLayer(ActiveDocument.Layers.Count - 1);
             LayersChanged?.Invoke(this, new LayersChangedEventArgs(0, LayerAction.Add));
             LayersChanged?.Invoke(this, new LayersChangedEventArgs(0, LayerAction.Add));
         }
         }
 
 
@@ -110,13 +109,9 @@ namespace PixiEditor.Models.Controllers
             bool wasActive = ActiveDocument.Layers[layerIndex].IsActive;
             bool wasActive = ActiveDocument.Layers[layerIndex].IsActive;
             ActiveDocument.Layers.RemoveAt(layerIndex);
             ActiveDocument.Layers.RemoveAt(layerIndex);
             if (wasActive)
             if (wasActive)
-            {
                 SetActiveLayer(0);
                 SetActiveLayer(0);
-            }
             else if (ActiveDocument.ActiveLayerIndex > ActiveDocument.Layers.Count - 1)
             else if (ActiveDocument.ActiveLayerIndex > ActiveDocument.Layers.Count - 1)
-            {
                 SetActiveLayer(ActiveDocument.Layers.Count - 1);
                 SetActiveLayer(ActiveDocument.Layers.Count - 1);
-            }
         }
         }
 
 
         private void Controller_MousePositionChanged(object sender, MouseMovementEventArgs e)
         private void Controller_MousePositionChanged(object sender, MouseMovementEventArgs e)
@@ -124,14 +119,11 @@ namespace PixiEditor.Models.Controllers
             if (Mouse.LeftButton == MouseButtonState.Pressed && ActiveDocument != null)
             if (Mouse.LeftButton == MouseButtonState.Pressed && ActiveDocument != null)
             {
             {
                 if (IsOperationTool(SelectedTool))
                 if (IsOperationTool(SelectedTool))
-                {
                     BitmapOperations.ExecuteTool(e.NewPosition,
                     BitmapOperations.ExecuteTool(e.NewPosition,
-                        MouseController.LastMouseMoveCoordinates.ToList(), (BitmapOperationTool)SelectedTool);
-                }
+                        MouseController.LastMouseMoveCoordinates.ToList(), (BitmapOperationTool) SelectedTool);
                 else
                 else
-                {
-                    ReadonlyToolUtility.ExecuteTool(MouseController.LastMouseMoveCoordinates.ToArray(), (ReadonlyTool)SelectedTool);
-                }
+                    ReadonlyToolUtility.ExecuteTool(MouseController.LastMouseMoveCoordinates.ToArray(),
+                        (ReadonlyTool) SelectedTool);
             }
             }
             else if (Mouse.LeftButton == MouseButtonState.Released)
             else if (Mouse.LeftButton == MouseButtonState.Released)
             {
             {
@@ -149,17 +141,13 @@ namespace PixiEditor.Models.Controllers
         {
         {
             SelectedTool.OnMouseUp();
             SelectedTool.OnMouseUp();
             if (IsOperationTool(SelectedTool) && ((BitmapOperationTool) SelectedTool).RequiresPreviewLayer)
             if (IsOperationTool(SelectedTool) && ((BitmapOperationTool) SelectedTool).RequiresPreviewLayer)
-            {
                 BitmapOperations.StopAction();
                 BitmapOperations.StopAction();
-            }
         }
         }
 
 
         public void GeneratePreviewLayer()
         public void GeneratePreviewLayer()
         {
         {
-            if ((PreviewLayer == null && ActiveDocument != null) || PreviewLayerSizeMismatch())
-            {
+            if (PreviewLayer == null && ActiveDocument != null || PreviewLayerSizeMismatch())
                 PreviewLayer = new Layer("_previewLayer", ActiveDocument.Width, ActiveDocument.Height);
                 PreviewLayer = new Layer("_previewLayer", ActiveDocument.Width, ActiveDocument.Height);
-            }
         }
         }
 
 
         private bool PreviewLayerSizeMismatch()
         private bool PreviewLayerSizeMismatch()
@@ -174,7 +162,8 @@ namespace PixiEditor.Models.Controllers
             PreviewLayer.Clear();
             PreviewLayer.Clear();
             Coordinates[] highlightArea = CoordinatesCalculator.RectangleToCoordinates(
             Coordinates[] highlightArea = CoordinatesCalculator.RectangleToCoordinates(
                 CoordinatesCalculator.CalculateThicknessCenter(newPosition, ToolSize));
                 CoordinatesCalculator.CalculateThicknessCenter(newPosition, ToolSize));
-            PreviewLayer.ApplyPixels(BitmapPixelChanges.FromSingleColoredArray(highlightArea, Color.FromArgb(77, 0, 0, 0)));
+            PreviewLayer.ApplyPixels(
+                BitmapPixelChanges.FromSingleColoredArray(highlightArea, Color.FromArgb(77, 0, 0, 0)));
         }
         }
 
 
         public WriteableBitmap GetCombinedLayersBitmap()
         public WriteableBitmap GetCombinedLayersBitmap()
@@ -187,18 +176,17 @@ namespace PixiEditor.Models.Controllers
         {
         {
             return tool is BitmapOperationTool;
             return tool is BitmapOperationTool;
         }
         }
-
     }
     }
 
 
     public class LayersChangedEventArgs : EventArgs
     public class LayersChangedEventArgs : EventArgs
     {
     {
-        public int LayerAffected { get; set; }
-        public LayerAction LayerChangeType { get; set; }
-
         public LayersChangedEventArgs(int layerAffected, LayerAction layerChangeType)
         public LayersChangedEventArgs(int layerAffected, LayerAction layerChangeType)
         {
         {
             LayerAffected = layerAffected;
             LayerAffected = layerAffected;
             LayerChangeType = layerChangeType;
             LayerChangeType = layerChangeType;
         }
         }
+
+        public int LayerAffected { get; set; }
+        public LayerAction LayerChangeType { get; set; }
     }
     }
-}
+}

+ 41 - 40
PixiEditor/Models/Controllers/BitmapOperationsUtility.cs

@@ -1,36 +1,35 @@
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Images;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using PixiEditor.Models.Tools;
-using PixiEditor.Models.Tools.Tools;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Windows.Input;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Images;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
+using PixiEditor.Models.Tools;
 
 
 namespace PixiEditor.Models.Controllers
 namespace PixiEditor.Models.Controllers
 {
 {
     public class BitmapOperationsUtility
     public class BitmapOperationsUtility
     {
     {
-
-        private Coordinates _lastMousePos;
         private LayerChange[] _lastModifiedLayers;
         private LayerChange[] _lastModifiedLayers;
 
 
-        public event EventHandler<BitmapChangedEventArgs> BitmapChanged;
-
-        public BitmapManager Manager { get; set; }
+        private Coordinates _lastMousePos;
 
 
         public BitmapOperationsUtility(BitmapManager manager)
         public BitmapOperationsUtility(BitmapManager manager)
         {
         {
             Manager = manager;
             Manager = manager;
         }
         }
 
 
+        public BitmapManager Manager { get; set; }
+
+        public event EventHandler<BitmapChangedEventArgs> BitmapChanged;
+
         public void DeletePixels(Layer[] layers, Coordinates[] pixels)
         public void DeletePixels(Layer[] layers, Coordinates[] pixels)
         {
         {
-            var changes = BitmapPixelChanges.FromSingleColoredArray(pixels, Color.FromArgb(0,0,0,0));
+            var changes = BitmapPixelChanges.FromSingleColoredArray(pixels, Color.FromArgb(0, 0, 0, 0));
             var oldValues = BitmapUtils.GetPixelsForSelection(layers, pixels);
             var oldValues = BitmapUtils.GetPixelsForSelection(layers, pixels);
             LayerChange[] old = new LayerChange[layers.Length];
             LayerChange[] old = new LayerChange[layers.Length];
             LayerChange[] newChange = new LayerChange[layers.Length];
             LayerChange[] newChange = new LayerChange[layers.Length];
@@ -41,6 +40,7 @@ namespace PixiEditor.Models.Controllers
                 newChange[i] = new LayerChange(changes, i);
                 newChange[i] = new LayerChange(changes, i);
                 layers[i].ApplyPixels(changes);
                 layers[i].ApplyPixels(changes);
             }
             }
+
             UndoManager.AddUndoChange(new Change("UndoChanges", old, newChange, "Deleted pixels"));
             UndoManager.AddUndoChange(new Change("UndoChanges", old, newChange, "Deleted pixels"));
         }
         }
 
 
@@ -61,34 +61,36 @@ namespace PixiEditor.Models.Controllers
             if (_lastModifiedLayers == null) return;
             if (_lastModifiedLayers == null) return;
             for (int i = 0; i < _lastModifiedLayers.Length; i++)
             for (int i = 0; i < _lastModifiedLayers.Length; i++)
             {
             {
-                BitmapPixelChanges oldValues = GetOldPixelsValues(_lastModifiedLayers[i].PixelChanges.ChangedPixels.Keys.ToArray());
-                Manager.ActiveDocument.Layers[_lastModifiedLayers[i].LayerIndex].ApplyPixels(_lastModifiedLayers[i].PixelChanges);
-                BitmapChanged?.Invoke(this, new BitmapChangedEventArgs(_lastModifiedLayers[i].PixelChanges, 
+                BitmapPixelChanges oldValues =
+                    GetOldPixelsValues(_lastModifiedLayers[i].PixelChanges.ChangedPixels.Keys.ToArray());
+                Manager.ActiveDocument.Layers[_lastModifiedLayers[i].LayerIndex]
+                    .ApplyPixels(_lastModifiedLayers[i].PixelChanges);
+                BitmapChanged?.Invoke(this, new BitmapChangedEventArgs(_lastModifiedLayers[i].PixelChanges,
                     oldValues, _lastModifiedLayers[i].LayerIndex));
                     oldValues, _lastModifiedLayers[i].LayerIndex));
                 Manager.PreviewLayer.Clear();
                 Manager.PreviewLayer.Clear();
             }
             }
         }
         }
 
 
 
 
-
         private void UseTool(List<Coordinates> mouseMoveCords, BitmapOperationTool tool, Color color)
         private void UseTool(List<Coordinates> mouseMoveCords, BitmapOperationTool tool, Color color)
         {
         {
             if (Keyboard.IsKeyDown(Key.LeftShift) && !MouseCordsNotInLine(mouseMoveCords))
             if (Keyboard.IsKeyDown(Key.LeftShift) && !MouseCordsNotInLine(mouseMoveCords))
-            {
                 mouseMoveCords = GetSquareCoordiantes(mouseMoveCords);
                 mouseMoveCords = GetSquareCoordiantes(mouseMoveCords);
-            };
+            ;
             if (!tool.RequiresPreviewLayer)
             if (!tool.RequiresPreviewLayer)
             {
             {
                 LayerChange[] modifiedLayers = tool.Use(Manager.ActiveLayer, mouseMoveCords.ToArray(), color);
                 LayerChange[] modifiedLayers = tool.Use(Manager.ActiveLayer, mouseMoveCords.ToArray(), color);
                 LayerChange[] oldPixelsValues = new LayerChange[modifiedLayers.Length];
                 LayerChange[] oldPixelsValues = new LayerChange[modifiedLayers.Length];
                 for (int i = 0; i < modifiedLayers.Length; i++)
                 for (int i = 0; i < modifiedLayers.Length; i++)
                 {
                 {
-                    oldPixelsValues[i] = new LayerChange(GetOldPixelsValues(modifiedLayers[i].PixelChanges.ChangedPixels.Keys.ToArray()), 
+                    oldPixelsValues[i] = new LayerChange(
+                        GetOldPixelsValues(modifiedLayers[i].PixelChanges.ChangedPixels.Keys.ToArray()),
                         modifiedLayers[i].LayerIndex);
                         modifiedLayers[i].LayerIndex);
-                    Manager.ActiveDocument.Layers[modifiedLayers[i].LayerIndex].ApplyPixels(modifiedLayers[i].PixelChanges);
-                    BitmapChanged?.Invoke(this, new BitmapChangedEventArgs(modifiedLayers[i].PixelChanges, 
+                    Manager.ActiveDocument.Layers[modifiedLayers[i].LayerIndex]
+                        .ApplyPixels(modifiedLayers[i].PixelChanges);
+                    BitmapChanged?.Invoke(this, new BitmapChangedEventArgs(modifiedLayers[i].PixelChanges,
                         oldPixelsValues[i].PixelChanges, modifiedLayers[i].LayerIndex));
                         oldPixelsValues[i].PixelChanges, modifiedLayers[i].LayerIndex));
-                }              
+                }
             }
             }
             else
             else
             {
             {
@@ -102,7 +104,7 @@ namespace PixiEditor.Models.Controllers
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Extracts square from rectangle mouse drag, used to draw symmetric shapes.
+        ///     Extracts square from rectangle mouse drag, used to draw symmetric shapes.
         /// </summary>
         /// </summary>
         /// <param name="mouseMoveCords"></param>
         /// <param name="mouseMoveCords"></param>
         /// <returns></returns>
         /// <returns></returns>
@@ -110,14 +112,8 @@ namespace PixiEditor.Models.Controllers
         {
         {
             int xLength = mouseMoveCords[0].Y - mouseMoveCords[^1].Y;
             int xLength = mouseMoveCords[0].Y - mouseMoveCords[^1].Y;
             int yLength = mouseMoveCords[0].Y - mouseMoveCords[^1].Y;
             int yLength = mouseMoveCords[0].Y - mouseMoveCords[^1].Y;
-            if (mouseMoveCords[^1].Y > mouseMoveCords[0].Y)
-            {
-                xLength *= -1;
-            }
-            if (mouseMoveCords[^1].X > mouseMoveCords[0].X)
-            {
-                xLength *= -1;
-            }
+            if (mouseMoveCords[^1].Y > mouseMoveCords[0].Y) xLength *= -1;
+            if (mouseMoveCords[^1].X > mouseMoveCords[0].X) xLength *= -1;
             mouseMoveCords[0] = new Coordinates(mouseMoveCords[^1].X + xLength, mouseMoveCords[^1].Y + yLength);
             mouseMoveCords[0] = new Coordinates(mouseMoveCords[^1].X + xLength, mouseMoveCords[^1].Y + yLength);
             return mouseMoveCords;
             return mouseMoveCords;
         }
         }
@@ -128,10 +124,13 @@ namespace PixiEditor.Models.Controllers
             Manager.ActiveLayer.LayerBitmap.Lock();
             Manager.ActiveLayer.LayerBitmap.Lock();
             for (int i = 0; i < coordinates.Length; i++)
             for (int i = 0; i < coordinates.Length; i++)
             {
             {
-                if (coordinates[i].X < 0 || coordinates[i].X > Manager.ActiveDocument.Width - 1 || coordinates[i].Y < 0 || coordinates[i].Y > Manager.ActiveDocument.Height - 1)
+                if (coordinates[i].X < 0 || coordinates[i].X > Manager.ActiveDocument.Width - 1 ||
+                    coordinates[i].Y < 0 || coordinates[i].Y > Manager.ActiveDocument.Height - 1)
                     continue;
                     continue;
-                values.Add(coordinates[i], Manager.ActiveLayer.LayerBitmap.GetPixel(coordinates[i].X, coordinates[i].Y));
+                values.Add(coordinates[i],
+                    Manager.ActiveLayer.LayerBitmap.GetPixel(coordinates[i].X, coordinates[i].Y));
             }
             }
+
             Manager.ActiveLayer.LayerBitmap.Unlock();
             Manager.ActiveLayer.LayerBitmap.Unlock();
             return new BitmapPixelChanges(values);
             return new BitmapPixelChanges(values);
         }
         }
@@ -143,7 +142,8 @@ namespace PixiEditor.Models.Controllers
             {
             {
                 Manager.GeneratePreviewLayer();
                 Manager.GeneratePreviewLayer();
                 Manager.PreviewLayer.Clear();
                 Manager.PreviewLayer.Clear();
-                modifiedLayers = ((BitmapOperationTool)Manager.SelectedTool).Use(Manager.ActiveDocument.ActiveLayer, mouseMove.ToArray(), Manager.PrimaryColor);
+                modifiedLayers = ((BitmapOperationTool) Manager.SelectedTool).Use(Manager.ActiveDocument.ActiveLayer,
+                    mouseMove.ToArray(), Manager.PrimaryColor);
                 BitmapPixelChanges[] changes = modifiedLayers.Select(x => x.PixelChanges).ToArray();
                 BitmapPixelChanges[] changes = modifiedLayers.Select(x => x.PixelChanges).ToArray();
                 Manager.PreviewLayer.ApplyPixels(BitmapPixelChanges.CombineOverride(changes));
                 Manager.PreviewLayer.ApplyPixels(BitmapPixelChanges.CombineOverride(changes));
                 _lastModifiedLayers = modifiedLayers;
                 _lastModifiedLayers = modifiedLayers;
@@ -154,14 +154,15 @@ namespace PixiEditor.Models.Controllers
 
 
 public class BitmapChangedEventArgs : EventArgs
 public class BitmapChangedEventArgs : EventArgs
 {
 {
-    public BitmapPixelChanges PixelsChanged { get; set; }
-    public BitmapPixelChanges OldPixelsValues { get; set; }
-    public int ChangedLayerIndex { get; set; }
-
-    public BitmapChangedEventArgs(BitmapPixelChanges pixelsChanged, BitmapPixelChanges oldPixelsValues, int changedLayerIndex)
+    public BitmapChangedEventArgs(BitmapPixelChanges pixelsChanged, BitmapPixelChanges oldPixelsValues,
+        int changedLayerIndex)
     {
     {
         PixelsChanged = pixelsChanged;
         PixelsChanged = pixelsChanged;
         OldPixelsValues = oldPixelsValues;
         OldPixelsValues = oldPixelsValues;
         ChangedLayerIndex = changedLayerIndex;
         ChangedLayerIndex = changedLayerIndex;
     }
     }
+
+    public BitmapPixelChanges PixelsChanged { get; set; }
+    public BitmapPixelChanges OldPixelsValues { get; set; }
+    public int ChangedLayerIndex { get; set; }
 }
 }

+ 17 - 27
PixiEditor/Models/Controllers/ClipboardController.cs

@@ -1,22 +1,19 @@
-using PixiEditor.Models.DataHolders;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Media.Imaging;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Images;
 using PixiEditor.Models.Images;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
-using System;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Windows;
-using System.Windows.Media.Imaging;
 
 
 namespace PixiEditor.Models.Controllers
 namespace PixiEditor.Models.Controllers
 {
 {
     public class ClipboardController
     public class ClipboardController
     {
     {
-
         /// <summary>
         /// <summary>
-        /// Copies selection to clipboard in PNG, Bitmap and DIB formats.
+        ///     Copies selection to clipboard in PNG, Bitmap and DIB formats.
         /// </summary>
         /// </summary>
         /// <param name="bitmap">Bitmap where selection is</param>
         /// <param name="bitmap">Bitmap where selection is</param>
         /// <param name="selection"></param>
         /// <param name="selection"></param>
@@ -42,46 +39,39 @@ namespace PixiEditor.Models.Controllers
 
 
         public void PasteFromClipboard()
         public void PasteFromClipboard()
         {
         {
-            DataObject dao = (DataObject)Clipboard.GetDataObject();
+            DataObject dao = (DataObject) Clipboard.GetDataObject();
             WriteableBitmap finalImage = null;
             WriteableBitmap finalImage = null;
             if (dao.GetDataPresent("PNG"))
             if (dao.GetDataPresent("PNG"))
-            {
                 using (MemoryStream pngStream = dao.GetData("PNG") as MemoryStream)
                 using (MemoryStream pngStream = dao.GetData("PNG") as MemoryStream)
                 {
                 {
                     if (pngStream != null)
                     if (pngStream != null)
                     {
                     {
-                        PngBitmapDecoder decoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.OnLoad);
+                        PngBitmapDecoder decoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.IgnoreImageCache,
+                            BitmapCacheOption.OnLoad);
                         finalImage = new WriteableBitmap(decoder.Frames[0].Clone());
                         finalImage = new WriteableBitmap(decoder.Frames[0].Clone());
                     }
                     }
                 }
                 }
-            }
             else if (dao.GetDataPresent(DataFormats.Dib))
             else if (dao.GetDataPresent(DataFormats.Dib))
-            {
                 finalImage = new WriteableBitmap(Clipboard.GetImage());
                 finalImage = new WriteableBitmap(Clipboard.GetImage());
-            }
             else if (dao.GetDataPresent(DataFormats.Bitmap))
             else if (dao.GetDataPresent(DataFormats.Bitmap))
-            {
                 finalImage = new WriteableBitmap(dao.GetData(DataFormats.Bitmap) as BitmapSource);
                 finalImage = new WriteableBitmap(dao.GetData(DataFormats.Bitmap) as BitmapSource);
-            }
-            if (finalImage != null)
-            {
-                AddImageToLayers(finalImage);
-            }
+
+            if (finalImage != null) AddImageToLayers(finalImage);
         }
         }
 
 
         public bool IsImageInClipboard()
         public bool IsImageInClipboard()
         {
         {
-            DataObject dao = (DataObject)Clipboard.GetDataObject();
-            return dao.GetDataPresent("PNG") || dao.GetDataPresent(DataFormats.Dib) || dao.GetDataPresent(DataFormats.Bitmap);
+            DataObject dao = (DataObject) Clipboard.GetDataObject();
+            return dao.GetDataPresent("PNG") || dao.GetDataPresent(DataFormats.Dib) ||
+                   dao.GetDataPresent(DataFormats.Bitmap);
         }
         }
 
 
         private void AddImageToLayers(WriteableBitmap image)
         private void AddImageToLayers(WriteableBitmap image)
         {
         {
             Document doc = ViewModelMain.Current.BitmapManager.ActiveDocument;
             Document doc = ViewModelMain.Current.BitmapManager.ActiveDocument;
             Rect imgRect = new Rect(0, 0, image.PixelWidth, image.PixelHeight);
             Rect imgRect = new Rect(0, 0, image.PixelWidth, image.PixelHeight);
-            ViewModelMain.Current.BitmapManager.AddNewLayer("Image", doc.Width, doc.Height, true);
-            ViewModelMain.Current.BitmapManager.ActiveLayer.
-                LayerBitmap.Blit(imgRect, image, imgRect);
+            ViewModelMain.Current.BitmapManager.AddNewLayer("Image", doc.Width, doc.Height);
+            ViewModelMain.Current.BitmapManager.ActiveLayer.LayerBitmap.Blit(imgRect, image, imgRect);
         }
         }
 
 
         public BitmapSource BitmapSelectionToBmpSource(WriteableBitmap bitmap, Coordinates[] selection)
         public BitmapSource BitmapSelectionToBmpSource(WriteableBitmap bitmap, Coordinates[] selection)
@@ -93,4 +83,4 @@ namespace PixiEditor.Models.Controllers
             return bitmap.Crop(offsetX, offsetY, width, height);
             return bitmap.Crop(offsetX, offsetY, width, height);
         }
         }
     }
     }
-}
+}

+ 9 - 10
PixiEditor/Models/Controllers/MouseMovementController.cs

@@ -1,16 +1,16 @@
-using PixiEditor.Models.Position;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using PixiEditor.Models.Position;
 
 
 namespace PixiEditor.Models.Controllers
 namespace PixiEditor.Models.Controllers
 {
 {
     public class MouseMovementController
     public class MouseMovementController
     {
     {
         public List<Coordinates> LastMouseMoveCoordinates { get; } = new List<Coordinates>();
         public List<Coordinates> LastMouseMoveCoordinates { get; } = new List<Coordinates>();
+        public bool IsRecordingChanges { get; private set; }
         public event EventHandler StartedRecordingChanges;
         public event EventHandler StartedRecordingChanges;
         public event EventHandler<MouseMovementEventArgs> MousePositionChanged;
         public event EventHandler<MouseMovementEventArgs> MousePositionChanged;
         public event EventHandler StoppedRecordingChanges;
         public event EventHandler StoppedRecordingChanges;
-        public bool IsRecordingChanges { get; private set; } = false;
 
 
         public void StartRecordingMouseMovementChanges()
         public void StartRecordingMouseMovementChanges()
         {
         {
@@ -21,20 +21,19 @@ namespace PixiEditor.Models.Controllers
                 StartedRecordingChanges?.Invoke(this, EventArgs.Empty);
                 StartedRecordingChanges?.Invoke(this, EventArgs.Empty);
             }
             }
         }
         }
+
         public void RecordMouseMovementChange(Coordinates mouseCoordinates)
         public void RecordMouseMovementChange(Coordinates mouseCoordinates)
         {
         {
-            if (IsRecordingChanges == true)
-            {
+            if (IsRecordingChanges)
                 if (LastMouseMoveCoordinates.Count == 0 || mouseCoordinates != LastMouseMoveCoordinates[^1])
                 if (LastMouseMoveCoordinates.Count == 0 || mouseCoordinates != LastMouseMoveCoordinates[^1])
                 {
                 {
                     LastMouseMoveCoordinates.Add(mouseCoordinates);
                     LastMouseMoveCoordinates.Add(mouseCoordinates);
                     MousePositionChanged?.Invoke(this, new MouseMovementEventArgs(mouseCoordinates));
                     MousePositionChanged?.Invoke(this, new MouseMovementEventArgs(mouseCoordinates));
                 }
                 }
-            }
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Plain mose move, does not affect mouse drag recordings
+        ///     Plain mose move, does not affect mouse drag recordings
         /// </summary>
         /// </summary>
         /// <param name="mouseCoordinates"></param>
         /// <param name="mouseCoordinates"></param>
         public void MouseMoved(Coordinates mouseCoordinates)
         public void MouseMoved(Coordinates mouseCoordinates)
@@ -55,10 +54,10 @@ namespace PixiEditor.Models.Controllers
 
 
 public class MouseMovementEventArgs : EventArgs
 public class MouseMovementEventArgs : EventArgs
 {
 {
-    public Coordinates NewPosition { get; set; }
-
     public MouseMovementEventArgs(Coordinates mousePosition)
     public MouseMovementEventArgs(Coordinates mousePosition)
     {
     {
         NewPosition = mousePosition;
         NewPosition = mousePosition;
     }
     }
-}
+
+    public Coordinates NewPosition { get; set; }
+}

+ 13 - 24
PixiEditor/Models/Controllers/PixelChangesController.cs

@@ -1,18 +1,17 @@
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using PixiEditor.Models.Tools;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Windows.Media;
 using System.Windows.Media;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Position;
+using PixiEditor.Models.Tools;
 
 
 namespace PixiEditor.Models.Controllers
 namespace PixiEditor.Models.Controllers
 {
 {
     public class PixelChangesController
     public class PixelChangesController
     {
     {
-        Dictionary<int, LayerChange> LastChanges { get; set; }
-        Dictionary<int, LayerChange> LastOldValues { get; set; }
+        private Dictionary<int, LayerChange> LastChanges { get; set; }
+        private Dictionary<int, LayerChange> LastOldValues { get; set; }
 
 
         public void AddChanges(LayerChange changes, LayerChange oldValues)
         public void AddChanges(LayerChange changes, LayerChange oldValues)
         {
         {
@@ -20,8 +19,8 @@ namespace PixiEditor.Models.Controllers
             {
             {
                 if (LastChanges == null)
                 if (LastChanges == null)
                 {
                 {
-                    LastChanges = new Dictionary<int, LayerChange> { { changes.LayerIndex, changes } };
-                    LastOldValues = new Dictionary<int, LayerChange> { { oldValues.LayerIndex, oldValues } };
+                    LastChanges = new Dictionary<int, LayerChange> {{changes.LayerIndex, changes}};
+                    LastOldValues = new Dictionary<int, LayerChange> {{oldValues.LayerIndex, oldValues}};
                 }
                 }
                 else if (LastChanges.ContainsKey(changes.LayerIndex))
                 else if (LastChanges.ContainsKey(changes.LayerIndex))
                 {
                 {
@@ -43,28 +42,16 @@ namespace PixiEditor.Models.Controllers
         private void AddToExistingLayerChange(LayerChange layerChange, LayerChange oldValues)
         private void AddToExistingLayerChange(LayerChange layerChange, LayerChange oldValues)
         {
         {
             foreach (var change in layerChange.PixelChanges.ChangedPixels)
             foreach (var change in layerChange.PixelChanges.ChangedPixels)
-            {
                 if (LastChanges[layerChange.LayerIndex].PixelChanges.ChangedPixels.ContainsKey(change.Key))
                 if (LastChanges[layerChange.LayerIndex].PixelChanges.ChangedPixels.ContainsKey(change.Key))
-                {
                     continue;
                     continue;
-                }
                 else
                 else
-                {
                     LastChanges[layerChange.LayerIndex].PixelChanges.ChangedPixels.Add(change.Key, change.Value);
                     LastChanges[layerChange.LayerIndex].PixelChanges.ChangedPixels.Add(change.Key, change.Value);
-                }
-            }
 
 
             foreach (var change in oldValues.PixelChanges.ChangedPixels)
             foreach (var change in oldValues.PixelChanges.ChangedPixels)
-            {
                 if (LastOldValues[layerChange.LayerIndex].PixelChanges.ChangedPixels.ContainsKey(change.Key))
                 if (LastOldValues[layerChange.LayerIndex].PixelChanges.ChangedPixels.ContainsKey(change.Key))
-                {
                     continue;
                     continue;
-                }
                 else
                 else
-                {
                     LastOldValues[layerChange.LayerIndex].PixelChanges.ChangedPixels.Add(change.Key, change.Value);
                     LastOldValues[layerChange.LayerIndex].PixelChanges.ChangedPixels.Add(change.Key, change.Value);
-                }
-            }
         }
         }
 
 
         public Tuple<LayerChange, LayerChange>[] PopChanges()
         public Tuple<LayerChange, LayerChange>[] PopChanges()
@@ -75,8 +62,10 @@ namespace PixiEditor.Models.Controllers
             int i = 0;
             int i = 0;
             foreach (var change in LastChanges)
             foreach (var change in LastChanges)
             {
             {
-                Dictionary<Coordinates, Color> pixelChanges = change.Value.PixelChanges.ChangedPixels.ToDictionary(entry => entry.Key, entry => entry.Value);
-                Dictionary<Coordinates, Color> oldValues = LastOldValues[change.Key].PixelChanges.ChangedPixels.ToDictionary(entry => entry.Key, entry => entry.Value);
+                Dictionary<Coordinates, Color> pixelChanges =
+                    change.Value.PixelChanges.ChangedPixels.ToDictionary(entry => entry.Key, entry => entry.Value);
+                Dictionary<Coordinates, Color> oldValues = LastOldValues[change.Key].PixelChanges.ChangedPixels
+                    .ToDictionary(entry => entry.Key, entry => entry.Value);
 
 
                 var tmp = new LayerChange(new BitmapPixelChanges(pixelChanges), change.Key);
                 var tmp = new LayerChange(new BitmapPixelChanges(pixelChanges), change.Key);
                 var oldValuesTmp = new LayerChange(new BitmapPixelChanges(oldValues), change.Key);
                 var oldValuesTmp = new LayerChange(new BitmapPixelChanges(oldValues), change.Key);
@@ -90,4 +79,4 @@ namespace PixiEditor.Models.Controllers
             return result;
             return result;
         }
         }
     }
     }
-}
+}

+ 3 - 4
PixiEditor/Models/Controllers/ReadonlyToolUtility.cs

@@ -5,17 +5,16 @@ namespace PixiEditor.Models.Controllers
 {
 {
     public class ReadonlyToolUtility
     public class ReadonlyToolUtility
     {
     {
-        public BitmapManager Manager { get; set; }
-
         public ReadonlyToolUtility(BitmapManager manager)
         public ReadonlyToolUtility(BitmapManager manager)
         {
         {
             Manager = manager;
             Manager = manager;
         }
         }
 
 
+        public BitmapManager Manager { get; set; }
+
         public void ExecuteTool(Coordinates[] mouseMove, ReadonlyTool tool)
         public void ExecuteTool(Coordinates[] mouseMove, ReadonlyTool tool)
         {
         {
             tool.Use(mouseMove);
             tool.Use(mouseMove);
         }
         }
-
     }
     }
-}
+}

+ 9 - 11
PixiEditor/Models/Controllers/Shortcuts/Shortcut.cs

@@ -4,12 +4,8 @@ namespace PixiEditor.Models.Controllers
 {
 {
     public class Shortcut
     public class Shortcut
     {
     {
-        public Key ShortcutKey { get; set; }
-        public ModifierKeys Modifier { get; set; }
-        public ICommand Command { get; set; }
-        public object CommandParameter { get; set; }
-
-        public Shortcut(Key shortcutKey, ICommand command, object commandParameter = null, ModifierKeys modifier = ModifierKeys.None)
+        public Shortcut(Key shortcutKey, ICommand command, object commandParameter = null,
+            ModifierKeys modifier = ModifierKeys.None)
         {
         {
             ShortcutKey = shortcutKey;
             ShortcutKey = shortcutKey;
             Modifier = modifier;
             Modifier = modifier;
@@ -17,12 +13,14 @@ namespace PixiEditor.Models.Controllers
             CommandParameter = commandParameter;
             CommandParameter = commandParameter;
         }
         }
 
 
+        public Key ShortcutKey { get; set; }
+        public ModifierKeys Modifier { get; set; }
+        public ICommand Command { get; set; }
+        public object CommandParameter { get; set; }
+
         public void Execute()
         public void Execute()
         {
         {
-            if (Command.CanExecute(CommandParameter))
-            {
-                Command.Execute(CommandParameter);
-            }
+            if (Command.CanExecute(CommandParameter)) Command.Execute(CommandParameter);
         }
         }
     }
     }
-}
+}

+ 5 - 8
PixiEditor/Models/Controllers/Shortcuts/ShortcutController.cs

@@ -6,16 +6,15 @@ namespace PixiEditor.Models.Controllers
 {
 {
     public class ShortcutController
     public class ShortcutController
     {
     {
-        public static bool BlockShortcutExecution { get; set; }
-
-        public List<Shortcut> Shortcuts { get; set; }
-
         public ShortcutController()
         public ShortcutController()
         {
         {
             Shortcuts = new List<Shortcut>();
             Shortcuts = new List<Shortcut>();
-
         }
         }
 
 
+        public static bool BlockShortcutExecution { get; set; }
+
+        public List<Shortcut> Shortcuts { get; set; }
+
         public void KeyPressed(Key key)
         public void KeyPressed(Key key)
         {
         {
             if (!BlockShortcutExecution)
             if (!BlockShortcutExecution)
@@ -24,14 +23,12 @@ namespace PixiEditor.Models.Controllers
                 if (shortcuts.Length < 1) return;
                 if (shortcuts.Length < 1) return;
                 shortcuts = shortcuts.OrderByDescending(x => x.Modifier).ToArray();
                 shortcuts = shortcuts.OrderByDescending(x => x.Modifier).ToArray();
                 for (int i = 0; i < shortcuts.Length; i++)
                 for (int i = 0; i < shortcuts.Length; i++)
-                {
                     if (Keyboard.Modifiers.HasFlag(shortcuts[i].Modifier))
                     if (Keyboard.Modifiers.HasFlag(shortcuts[i].Modifier))
                     {
                     {
                         shortcuts[i].Execute();
                         shortcuts[i].Execute();
                         break;
                         break;
                     }
                     }
-                }
             }
             }
         }
         }
     }
     }
-}
+}

+ 19 - 40
PixiEditor/Models/Controllers/UndoManager.cs

@@ -1,36 +1,25 @@
-using PixiEditor.Models.DataHolders;
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
+using PixiEditor.Models.DataHolders;
 
 
 namespace PixiEditor.Models.Controllers
 namespace PixiEditor.Models.Controllers
 {
 {
     public static class UndoManager
     public static class UndoManager
     {
     {
+        private static List<Change> _recordedChanges = new List<Change>();
+        private static bool _lastChangeWasUndo;
         public static StackEx<Change> UndoStack { get; set; } = new StackEx<Change>();
         public static StackEx<Change> UndoStack { get; set; } = new StackEx<Change>();
         public static StackEx<Change> RedoStack { get; set; } = new StackEx<Change>();
         public static StackEx<Change> RedoStack { get; set; } = new StackEx<Change>();
-        private static List<Change> _recordedChanges = new List<Change>();
-        private static bool _lastChangeWasUndo = false;
-        public static bool CanUndo
-        {
-            get
-            {
-                return UndoStack.Count > 0;
-            }
-        }
-        public static bool CanRedo
-        {
-            get
-            {
-                return RedoStack.Count > 0;
-            }
-        }
+
+        public static bool CanUndo => UndoStack.Count > 0;
+
+        public static bool CanRedo => RedoStack.Count > 0;
 
 
         public static object MainRoot { get; set; }
         public static object MainRoot { get; set; }
 
 
         /// <summary>
         /// <summary>
-        /// Sets object(root) in which undo properties are stored.
+        ///     Sets object(root) in which undo properties are stored.
         /// </summary>
         /// </summary>
         /// <param name="root">Parent object.</param>
         /// <param name="root">Parent object.</param>
         public static void SetMainRoot(object root)
         public static void SetMainRoot(object root)
@@ -41,16 +30,15 @@ namespace PixiEditor.Models.Controllers
 
 
         public static void AddUndoChange(Change change)
         public static void AddUndoChange(Change change)
         {
         {
-            if (_lastChangeWasUndo == false && RedoStack.Count > 0) //Cleares RedoStack if las move wasn't redo or undo and if redo stack is greater than 0
-            {
+            if (_lastChangeWasUndo == false && RedoStack.Count > 0
+            ) //Cleares RedoStack if las move wasn't redo or undo and if redo stack is greater than 0
                 RedoStack.Clear();
                 RedoStack.Clear();
-            }
             _lastChangeWasUndo = false;
             _lastChangeWasUndo = false;
             UndoStack.Push(change);
             UndoStack.Push(change);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Adds property change to UndoStack
+        ///     Adds property change to UndoStack
         /// </summary>
         /// </summary>
         /// <param name="property">Changed property name.</param>
         /// <param name="property">Changed property name.</param>
         /// <param name="oldValue">Old value of property.</param>
         /// <param name="oldValue">Old value of property.</param>
@@ -58,51 +46,41 @@ namespace PixiEditor.Models.Controllers
         /// <param name="undoDescription">Description of change.</param>
         /// <param name="undoDescription">Description of change.</param>
         public static void AddUndoChange(string property, object oldValue, object newValue, string undoDescription = "")
         public static void AddUndoChange(string property, object oldValue, object newValue, string undoDescription = "")
         {
         {
-            if (_lastChangeWasUndo == false && RedoStack.Count > 0) //Cleares RedoStack if las move wasn't redo or undo and if redo stack is greater than 0
-            {
+            if (_lastChangeWasUndo == false && RedoStack.Count > 0
+            ) //Cleares RedoStack if las move wasn't redo or undo and if redo stack is greater than 0
                 RedoStack.Clear();
                 RedoStack.Clear();
-            }
             _lastChangeWasUndo = false;
             _lastChangeWasUndo = false;
             UndoStack.Push(new Change(property, oldValue, newValue, undoDescription));
             UndoStack.Push(new Change(property, oldValue, newValue, undoDescription));
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Sets top property in UndoStack to Old Value
+        ///     Sets top property in UndoStack to Old Value
         /// </summary>
         /// </summary>
         public static void Undo()
         public static void Undo()
         {
         {
             _lastChangeWasUndo = true;
             _lastChangeWasUndo = true;
             Change change = UndoStack.Pop();
             Change change = UndoStack.Pop();
             if (change.ReverseProcess == null)
             if (change.ReverseProcess == null)
-            {
                 SetPropertyValue(MainRoot, change.Property, change.OldValue);
                 SetPropertyValue(MainRoot, change.Property, change.OldValue);
-            }
             else
             else
-            {
                 change.ReverseProcess(change.ReverseProcessArguments);
                 change.ReverseProcess(change.ReverseProcessArguments);
-            }
             RedoStack.Push(change);
             RedoStack.Push(change);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Sets top property from RedoStack to old value
+        ///     Sets top property from RedoStack to old value
         /// </summary>
         /// </summary>
         public static void Redo()
         public static void Redo()
         {
         {
             _lastChangeWasUndo = true;
             _lastChangeWasUndo = true;
             Change change = RedoStack.Pop();
             Change change = RedoStack.Pop();
             if (change.ReverseProcess == null)
             if (change.ReverseProcess == null)
-            {
                 SetPropertyValue(MainRoot, change.Property, change.NewValue);
                 SetPropertyValue(MainRoot, change.Property, change.NewValue);
-            }
             else
             else
-            {
                 change.Process(change.ProcessArguments);
                 change.Process(change.ProcessArguments);
-            }
             UndoStack.Push(change);
             UndoStack.Push(change);
-
         }
         }
-       
+
 
 
         private static void SetPropertyValue(object target, string propName, object value)
         private static void SetPropertyValue(object target, string propName, object value)
         {
         {
@@ -112,8 +90,9 @@ namespace PixiEditor.Models.Controllers
                 PropertyInfo propertyToGet = target.GetType().GetProperty(bits[i]);
                 PropertyInfo propertyToGet = target.GetType().GetProperty(bits[i]);
                 target = propertyToGet.GetValue(target, null);
                 target = propertyToGet.GetValue(target, null);
             }
             }
+
             PropertyInfo propertyToSet = target.GetType().GetProperty(bits.Last());
             PropertyInfo propertyToSet = target.GetType().GetProperty(bits.Last());
             propertyToSet.SetValue(target, value, null);
             propertyToSet.SetValue(target, value, null);
         }
         }
     }
     }
-}
+}

+ 13 - 14
PixiEditor/Models/DataHolders/Change.cs

@@ -5,18 +5,8 @@ namespace PixiEditor.Models.DataHolders
     [Serializable]
     [Serializable]
     public class Change
     public class Change
     {
     {
-        public object OldValue { get; set; }
-
-        public object NewValue { get; set; }
-
-        public string Description { get; set; }
-
-        public string Property { get; set; }
-
-        public Action<object[]> ReverseProcess { get; set; } = null;
-        public object[] ReverseProcessArguments;
-        public Action<object[]> Process { get; set; } = null;
         public object[] ProcessArguments;
         public object[] ProcessArguments;
+        public object[] ReverseProcessArguments;
 
 
 
 
         public Change(string property, object oldValue, object newValue, string description = "")
         public Change(string property, object oldValue, object newValue, string description = "")
@@ -27,7 +17,7 @@ namespace PixiEditor.Models.DataHolders
             NewValue = newValue;
             NewValue = newValue;
         }
         }
 
 
-        public Change(string property, Action<object[]> reverseProcess, object[] reverseArguments, 
+        public Change(string property, Action<object[]> reverseProcess, object[] reverseArguments,
             object newValue, string description = "")
             object newValue, string description = "")
         {
         {
             Property = property;
             Property = property;
@@ -50,8 +40,17 @@ namespace PixiEditor.Models.DataHolders
 
 
         public Change()
         public Change()
         {
         {
-
         }
         }
 
 
+        public object OldValue { get; set; }
+
+        public object NewValue { get; set; }
+
+        public string Description { get; set; }
+
+        public string Property { get; set; }
+
+        public Action<object[]> ReverseProcess { get; set; }
+        public Action<object[]> Process { get; set; }
     }
     }
-}
+}

+ 85 - 65
PixiEditor/Models/DataHolders/Document.cs

@@ -1,21 +1,31 @@
-using PixiEditor.Helpers;
-using PixiEditor.Models.Controllers;
-using PixiEditor.Models.Enums;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using System;
+using System;
 using System.Collections.ObjectModel;
 using System.Collections.ObjectModel;
 using System.Linq;
 using System.Linq;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Helpers;
+using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Enums;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
 
 
 namespace PixiEditor.Models.DataHolders
 namespace PixiEditor.Models.DataHolders
 {
 {
     public class Document : NotifyableObject
     public class Document : NotifyableObject
     {
     {
-        public event EventHandler<DocumentSizeChangedEventArgs> DocumentSizeChanged;
+        private int _activeLayerIndex;
+        private int _height;
+
+        private ObservableCollection<Layer> _layers = new ObservableCollection<Layer>();
 
 
         private int _width;
         private int _width;
+
+        public Document(int width, int height)
+        {
+            Width = width;
+            Height = height;
+        }
+
         public int Width
         public int Width
         {
         {
             get => _width;
             get => _width;
@@ -25,7 +35,7 @@ namespace PixiEditor.Models.DataHolders
                 RaisePropertyChanged("Width");
                 RaisePropertyChanged("Width");
             }
             }
         }
         }
-        private int _height;
+
         public int Height
         public int Height
         {
         {
             get => _height;
             get => _height;
@@ -36,16 +46,17 @@ namespace PixiEditor.Models.DataHolders
             }
             }
         }
         }
 
 
-        private ObservableCollection<Layer> _layers = new ObservableCollection<Layer>();
-
         public ObservableCollection<Layer> Layers
         public ObservableCollection<Layer> Layers
         {
         {
             get => _layers;
             get => _layers;
-            set { if (_layers != value) { _layers = value; } }
+            set
+            {
+                if (_layers != value) _layers = value;
+            }
         }
         }
+
         public Layer ActiveLayer => Layers.Count > 0 ? Layers[ActiveLayerIndex] : null;
         public Layer ActiveLayer => Layers.Count > 0 ? Layers[ActiveLayerIndex] : null;
 
 
-        private int _activeLayerIndex;
         public int ActiveLayerIndex
         public int ActiveLayerIndex
         {
         {
             get => _activeLayerIndex;
             get => _activeLayerIndex;
@@ -56,17 +67,13 @@ namespace PixiEditor.Models.DataHolders
                 RaisePropertyChanged("ActiveLayer");
                 RaisePropertyChanged("ActiveLayer");
             }
             }
         }
         }
-        public ObservableCollection<Color> Swatches { get; set; } = new ObservableCollection<Color>();
 
 
-        public Document(int width, int height)
-        {
-            Width = width;
-            Height = height;
-        }
+        public ObservableCollection<Color> Swatches { get; set; } = new ObservableCollection<Color>();
+        public event EventHandler<DocumentSizeChangedEventArgs> DocumentSizeChanged;
 
 
 
 
         /// <summary>
         /// <summary>
-        /// Crops canvas at specified x and y offset.
+        ///     Crops canvas at specified x and y offset.
         /// </summary>
         /// </summary>
         /// <param name="x">X offset</param>
         /// <param name="x">X offset</param>
         /// <param name="y">Y offset</param>
         /// <param name="y">Y offset</param>
@@ -74,19 +81,22 @@ namespace PixiEditor.Models.DataHolders
         /// <param name="height">New height</param>
         /// <param name="height">New height</param>
         public void Crop(int x, int y, int width, int height)
         public void Crop(int x, int y, int width, int height)
         {
         {
-            object[] reverseArgs = { 0, 0, x, y, Width, Height, width, height};
-            object[] processArgs = { x, y, 0, 0, width, height };
+            object[] reverseArgs = {0, 0, x, y, Width, Height, width, height};
+            object[] processArgs = {x, y, 0, 0, width, height};
             ResizeDocumentCanvas(processArgs);
             ResizeDocumentCanvas(processArgs);
-            UndoManager.AddUndoChange(new Change("BitmapManager.ActiveDocument", ResizeDocumentCanvas, 
+            UndoManager.AddUndoChange(new Change("BitmapManager.ActiveDocument", ResizeDocumentCanvas,
                 reverseArgs, ResizeDocumentCanvas, processArgs, "Crop document"));
                 reverseArgs, ResizeDocumentCanvas, processArgs, "Crop document"));
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Resizes canvas to specified width and height to selected anchor
+        ///     Resizes canvas to specified width and height to selected anchor
         /// </summary>
         /// </summary>
         /// <param name="width">New width of canvas</param>
         /// <param name="width">New width of canvas</param>
         /// <param name="height">New height of canvas</param>
         /// <param name="height">New height of canvas</param>
-        /// <param name="anchor">Point that will act as "starting position" of resizing. Use pipe to connect horizontal and vertical.</param>
+        /// <param name="anchor">
+        ///     Point that will act as "starting position" of resizing. Use pipe to connect horizontal and
+        ///     vertical.
+        /// </param>
         public void ResizeCanvas(int width, int height, AnchorPoint anchor)
         public void ResizeCanvas(int width, int height, AnchorPoint anchor)
         {
         {
             int oldWidth = Width;
             int oldWidth = Width;
@@ -96,18 +106,20 @@ namespace PixiEditor.Models.DataHolders
             int offsetY = GetOffsetYForAnchor(Height, height, anchor);
             int offsetY = GetOffsetYForAnchor(Height, height, anchor);
             int offsetXSrc = 0;
             int offsetXSrc = 0;
             int offsetYSrc = 0;
             int offsetYSrc = 0;
-            if(Width > width)
+            if (Width > width)
             {
             {
                 offsetXSrc = offsetX;
                 offsetXSrc = offsetX;
                 offsetX = 0;
                 offsetX = 0;
             }
             }
-            if(Height > height)
+
+            if (Height > height)
             {
             {
                 offsetYSrc = offsetY;
                 offsetYSrc = offsetY;
                 offsetY = 0;
                 offsetY = 0;
             }
             }
-            object[] processArgs = { offsetXSrc, offsetYSrc, offsetX, offsetY, width, height };
-            object[] reverseProcessArgs = {offsetX, offsetY, offsetXSrc, offsetYSrc, Width, Height };
+
+            object[] processArgs = {offsetXSrc, offsetYSrc, offsetX, offsetY, width, height};
+            object[] reverseProcessArgs = {offsetX, offsetY, offsetXSrc, offsetYSrc, Width, Height};
 
 
             ResizeCanvas(offsetX, offsetY, offsetXSrc, offsetYSrc, Width, Height, width, height);
             ResizeCanvas(offsetX, offsetY, offsetXSrc, offsetYSrc, Width, Height, width, height);
             UndoManager.AddUndoChange(new Change("BitmapManager.ActiveDocument", ResizeDocumentCanvas,
             UndoManager.AddUndoChange(new Change("BitmapManager.ActiveDocument", ResizeDocumentCanvas,
@@ -118,38 +130,28 @@ namespace PixiEditor.Models.DataHolders
         private int GetOffsetXForAnchor(int srcWidth, int destWidth, AnchorPoint anchor)
         private int GetOffsetXForAnchor(int srcWidth, int destWidth, AnchorPoint anchor)
         {
         {
             if (anchor.HasFlag(AnchorPoint.Center))
             if (anchor.HasFlag(AnchorPoint.Center))
-            {
                 return Math.Abs(destWidth / 2 - srcWidth / 2);
                 return Math.Abs(destWidth / 2 - srcWidth / 2);
-            }
-            else if (anchor.HasFlag(AnchorPoint.Right))
-            {
-                return Math.Abs(destWidth - srcWidth);
-            }
+            if (anchor.HasFlag(AnchorPoint.Right)) return Math.Abs(destWidth - srcWidth);
             return 0;
             return 0;
         }
         }
 
 
-        private int GetOffsetYForAnchor(int srcHeight, int destHeight,AnchorPoint anchor)
+        private int GetOffsetYForAnchor(int srcHeight, int destHeight, AnchorPoint anchor)
         {
         {
             if (anchor.HasFlag(AnchorPoint.Middle))
             if (anchor.HasFlag(AnchorPoint.Middle))
-            {
                 return Math.Abs(destHeight / 2 - srcHeight / 2);
                 return Math.Abs(destHeight / 2 - srcHeight / 2);
-            }
-            else if (anchor.HasFlag(AnchorPoint.Bottom))
-            {
-                return Math.Abs(destHeight - srcHeight);
-            }
+            if (anchor.HasFlag(AnchorPoint.Bottom)) return Math.Abs(destHeight - srcHeight);
             return 0;
             return 0;
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Resizes all document layers using NearestNeighbor interpolation.
+        ///     Resizes all document layers using NearestNeighbor interpolation.
         /// </summary>
         /// </summary>
         /// <param name="newWidth">New document width</param>
         /// <param name="newWidth">New document width</param>
         /// <param name="newHeight">New document height</param>
         /// <param name="newHeight">New document height</param>
         public void Resize(int newWidth, int newHeight)
         public void Resize(int newWidth, int newHeight)
         {
         {
-            object[] reverseArgs = new object[] { Width, Height};
-            object[] args = new object[] { newWidth, newHeight };
+            object[] reverseArgs = {Width, Height};
+            object[] args = {newWidth, newHeight};
             ResizeDocument(args);
             ResizeDocument(args);
             UndoManager.AddUndoChange(new Change("BitmapManager.ActiveDocument", ResizeDocument, reverseArgs,
             UndoManager.AddUndoChange(new Change("BitmapManager.ActiveDocument", ResizeDocument, reverseArgs,
                 ResizeDocument, args, "Resize document"));
                 ResizeDocument, args, "Resize document"));
@@ -160,17 +162,20 @@ namespace PixiEditor.Models.DataHolders
             int oldWidth = Width;
             int oldWidth = Width;
             int oldHeight = Height;
             int oldHeight = Height;
 
 
-            int newWidth = (int)arguments[0];
-            int newHeight = (int)arguments[1];
+            int newWidth = (int) arguments[0];
+            int newHeight = (int) arguments[1];
             for (int i = 0; i < Layers.Count; i++)
             for (int i = 0; i < Layers.Count; i++)
             {
             {
-                Layers[i].LayerBitmap = Layers[i].LayerBitmap.Resize(newWidth, newHeight, WriteableBitmapExtensions.Interpolation.NearestNeighbor);
+                Layers[i].LayerBitmap = Layers[i].LayerBitmap.Resize(newWidth, newHeight,
+                    WriteableBitmapExtensions.Interpolation.NearestNeighbor);
                 Layers[i].Width = newWidth;
                 Layers[i].Width = newWidth;
                 Layers[i].Height = newHeight;
                 Layers[i].Height = newHeight;
             }
             }
+
             Height = newHeight;
             Height = newHeight;
             Width = newWidth;
             Width = newWidth;
-            DocumentSizeChanged?.Invoke(this, new DocumentSizeChangedEventArgs(oldWidth, oldHeight, newWidth, newHeight));
+            DocumentSizeChanged?.Invoke(this,
+                new DocumentSizeChangedEventArgs(oldWidth, oldHeight, newWidth, newHeight));
         }
         }
 
 
         private void ResizeDocumentCanvas(object[] arguments)
         private void ResizeDocumentCanvas(object[] arguments)
@@ -178,25 +183,36 @@ namespace PixiEditor.Models.DataHolders
             int oldWidth = Width;
             int oldWidth = Width;
             int oldHeight = Height;
             int oldHeight = Height;
 
 
-            int x = (int)arguments[0];
-            int y = (int)arguments[1];
-            int destX = (int)arguments[2];
-            int destY = (int)arguments[3];
-            int width = (int)arguments[4];
-            int height = (int)arguments[5];
+            int x = (int) arguments[0];
+            int y = (int) arguments[1];
+            int destX = (int) arguments[2];
+            int destY = (int) arguments[3];
+            int width = (int) arguments[4];
+            int height = (int) arguments[5];
             ResizeCanvas(destX, destY, x, y, Width, Height, width, height);
             ResizeCanvas(destX, destY, x, y, Width, Height, width, height);
             Height = height;
             Height = height;
             Width = width;
             Width = width;
             DocumentSizeChanged?.Invoke(this, new DocumentSizeChangedEventArgs(oldWidth, oldHeight, width, height));
             DocumentSizeChanged?.Invoke(this, new DocumentSizeChangedEventArgs(oldWidth, oldHeight, width, height));
         }
         }
 
 
-        private void ResizeCanvas(int offsetX, int offsetY, int offsetXSrc, int offsetYSrc, int oldWidth, int oldHeight, int newWidth, int newHeight)
+        /// <summary>
+        ///     Resizes canvas
+        /// </summary>
+        /// <param name="offsetX">Offset X of content in new canvas. It will paste content to this offset X.</param>
+        /// <param name="offsetY">Offset Y of content in new canvas. It will paste content to this offset Y.</param>
+        /// <param name="offsetXSrc">Offset X of content in old canvas. It will copy the content from this offset X.</param>
+        /// <param name="offsetYSrc">Offset Y of content in old canvas. It will copy the content from this offset Y.</param>
+        /// <param name="oldWidth">Width of content to copy from source. Usually bitmap width.</param>
+        /// <param name="oldHeight">Height of content to copy from source. Usually bitmap width.</param>
+        /// <param name="newWidth">New canvas size.</param>
+        /// <param name="newHeight">New canvas height.</param>
+        private void ResizeCanvas(int offsetX, int offsetY, int offsetXSrc, int offsetYSrc, int oldWidth, int oldHeight,
+            int newWidth, int newHeight)
         {
         {
             int sizeOfArgb = 4;
             int sizeOfArgb = 4;
             int iteratorHeight = oldHeight > newHeight ? newHeight : oldHeight;
             int iteratorHeight = oldHeight > newHeight ? newHeight : oldHeight;
             int count = oldWidth > newWidth ? newWidth : oldWidth;
             int count = oldWidth > newWidth ? newWidth : oldWidth;
             for (int i = 0; i < Layers.Count; i++)
             for (int i = 0; i < Layers.Count; i++)
-            {
                 using (var srcContext = Layers[i].LayerBitmap.GetBitmapContext(ReadWriteMode.ReadOnly))
                 using (var srcContext = Layers[i].LayerBitmap.GetBitmapContext(ReadWriteMode.ReadOnly))
                 {
                 {
                     var result = BitmapFactory.New(newWidth, newHeight);
                     var result = BitmapFactory.New(newWidth, newHeight);
@@ -208,16 +224,20 @@ namespace PixiEditor.Models.DataHolders
                             var dstOff = ((offsetY + line) * newWidth + offsetX) * sizeOfArgb;
                             var dstOff = ((offsetY + line) * newWidth + offsetX) * sizeOfArgb;
                             BitmapContext.BlockCopy(srcContext, srcOff, destContext, dstOff, count * sizeOfArgb);
                             BitmapContext.BlockCopy(srcContext, srcOff, destContext, dstOff, count * sizeOfArgb);
                         }
                         }
+
                         Layers[i].LayerBitmap = result;
                         Layers[i].LayerBitmap = result;
                         Layers[i].Width = newWidth;
                         Layers[i].Width = newWidth;
                         Layers[i].Height = newHeight;
                         Layers[i].Height = newHeight;
                     }
                     }
                 }
                 }
-            }
+
             Width = newWidth;
             Width = newWidth;
             Height = newHeight;
             Height = newHeight;
         }
         }
 
 
+        /// <summary>
+        ///     Resizes canvas, so it fits exactly the size of drawn content, without any transparent pixels outside.
+        /// </summary>
         public void ClipCanvas()
         public void ClipCanvas()
         {
         {
             Coordinates[] smallestPixels = CoordinatesCalculator.GetSmallestPixels(this);
             Coordinates[] smallestPixels = CoordinatesCalculator.GetSmallestPixels(this);
@@ -231,19 +251,14 @@ namespace PixiEditor.Models.DataHolders
             if (smallestX == 0 && smallestY == 0 && biggestX == 0 && biggestY == 0)
             if (smallestX == 0 && smallestY == 0 && biggestX == 0 && biggestY == 0)
                 return;
                 return;
 
 
-                int width = biggestX - smallestX + 1;
+            int width = biggestX - smallestX + 1;
             int height = biggestY - smallestY + 1;
             int height = biggestY - smallestY + 1;
             Crop(smallestX, smallestY, width, height);
             Crop(smallestX, smallestY, width, height);
-        }     
+        }
     }
     }
 
 
     public class DocumentSizeChangedEventArgs
     public class DocumentSizeChangedEventArgs
     {
     {
-        public int OldWidth { get; set; }
-        public int OldHeight{ get; set; }
-        public int NewWidth { get; set; }
-        public int NewHeight { get; set; }
-
         public DocumentSizeChangedEventArgs(int oldWidth, int oldHeight, int newWidth, int newHeight)
         public DocumentSizeChangedEventArgs(int oldWidth, int oldHeight, int newWidth, int newHeight)
         {
         {
             OldWidth = oldWidth;
             OldWidth = oldWidth;
@@ -251,5 +266,10 @@ namespace PixiEditor.Models.DataHolders
             NewWidth = newWidth;
             NewWidth = newWidth;
             NewHeight = newHeight;
             NewHeight = newHeight;
         }
         }
+
+        public int OldWidth { get; set; }
+        public int OldHeight { get; set; }
+        public int NewWidth { get; set; }
+        public int NewHeight { get; set; }
     }
     }
-}
+}

+ 4 - 4
PixiEditor/Models/DataHolders/LayerChanges.cs

@@ -6,9 +6,6 @@ namespace PixiEditor.Models.DataHolders
 {
 {
     public class LayerChange
     public class LayerChange
     {
     {
-        public BitmapPixelChanges PixelChanges { get; set; }
-        public int LayerIndex { get; set; }
-
         public LayerChange(BitmapPixelChanges pixelChanges, int layerIndex)
         public LayerChange(BitmapPixelChanges pixelChanges, int layerIndex)
         {
         {
             PixelChanges = pixelChanges;
             PixelChanges = pixelChanges;
@@ -20,5 +17,8 @@ namespace PixiEditor.Models.DataHolders
             PixelChanges = pixelChanges;
             PixelChanges = pixelChanges;
             LayerIndex = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.IndexOf(layer);
             LayerIndex = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.IndexOf(layer);
         }
         }
+
+        public BitmapPixelChanges PixelChanges { get; set; }
+        public int LayerIndex { get; set; }
     }
     }
-}
+}

+ 22 - 24
PixiEditor/Models/DataHolders/NotifyableColor.cs

@@ -1,16 +1,28 @@
-using PixiEditor.Helpers;
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Text;
+using System;
+using System.Windows.Media;
+using PixiEditor.Helpers;
 
 
 namespace PixiEditor.Models.DataHolders
 namespace PixiEditor.Models.DataHolders
 {
 {
     public class NotifyableColor : NotifyableObject
     public class NotifyableColor : NotifyableObject
     {
     {
-        public event EventHandler ColorChanged;
-
         private byte _a;
         private byte _a;
+
+        private byte _b;
+
+
+        private byte _g;
+
+        private byte _r;
+
+        public NotifyableColor(Color color)
+        {
+            A = color.A;
+            R = color.R;
+            G = color.G;
+            B = color.B;
+        }
+
         public byte A
         public byte A
         {
         {
             get => _a;
             get => _a;
@@ -19,11 +31,9 @@ namespace PixiEditor.Models.DataHolders
                 _a = value;
                 _a = value;
                 ColorChanged?.Invoke(this, EventArgs.Empty);
                 ColorChanged?.Invoke(this, EventArgs.Empty);
                 RaisePropertyChanged("A");
                 RaisePropertyChanged("A");
-
             }
             }
         }
         }
 
 
-        private byte _r;
         public byte R
         public byte R
         {
         {
             get => _r;
             get => _r;
@@ -32,12 +42,9 @@ namespace PixiEditor.Models.DataHolders
                 _r = value;
                 _r = value;
                 ColorChanged?.Invoke(this, EventArgs.Empty);
                 ColorChanged?.Invoke(this, EventArgs.Empty);
                 RaisePropertyChanged("R");
                 RaisePropertyChanged("R");
-
             }
             }
         }
         }
 
 
-
-        private byte _g;
         public byte G
         public byte G
         {
         {
             get => _g;
             get => _g;
@@ -46,11 +53,9 @@ namespace PixiEditor.Models.DataHolders
                 _g = value;
                 _g = value;
                 ColorChanged?.Invoke(this, EventArgs.Empty);
                 ColorChanged?.Invoke(this, EventArgs.Empty);
                 RaisePropertyChanged("G");
                 RaisePropertyChanged("G");
-
             }
             }
         }
         }
 
 
-        private byte _b;
         public byte B
         public byte B
         {
         {
             get => _b;
             get => _b;
@@ -62,6 +67,8 @@ namespace PixiEditor.Models.DataHolders
             }
             }
         }
         }
 
 
+        public event EventHandler ColorChanged;
+
         public void SetArgb(byte a, byte r, byte g, byte b)
         public void SetArgb(byte a, byte r, byte g, byte b)
         {
         {
             A = a;
             A = a;
@@ -69,14 +76,5 @@ namespace PixiEditor.Models.DataHolders
             G = g;
             G = g;
             B = b;
             B = b;
         }
         }
-
-        public NotifyableColor(System.Windows.Media.Color color)
-        {
-            A = color.A;
-            R = color.R;
-            G = color.G;
-            B = color.B;
-        }
-
     }
     }
-}
+}

+ 17 - 21
PixiEditor/Models/DataHolders/Selection.cs

@@ -1,23 +1,29 @@
-using PixiEditor.Helpers;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Media;
+using PixiEditor.Helpers;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
-using System;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
 
 
 namespace PixiEditor.Models.DataHolders
 namespace PixiEditor.Models.DataHolders
 {
 {
     public class Selection : NotifyableObject
     public class Selection : NotifyableObject
     {
     {
-        public ObservableCollection<Coordinates> SelectedPoints { get; private set; }       
+        private readonly Color _selectionBlue;
         private Layer _selectionLayer;
         private Layer _selectionLayer;
-        private Color _selectionBlue;
+
+        public Selection(Coordinates[] selectedPoints)
+        {
+            SelectedPoints = new ObservableCollection<Coordinates>(selectedPoints);
+            SelectionLayer = new Layer("_selectionLayer", ViewModelMain.Current.BitmapManager.ActiveDocument.Width,
+                ViewModelMain.Current.BitmapManager.ActiveDocument.Height);
+            _selectionBlue = Color.FromArgb(127, 142, 202, 255);
+        }
+
+        public ObservableCollection<Coordinates> SelectedPoints { get; private set; }
 
 
         public Layer SelectionLayer
         public Layer SelectionLayer
         {
         {
@@ -45,10 +51,8 @@ namespace PixiEditor.Models.DataHolders
                     SelectedPoints = new ObservableCollection<Coordinates>(SelectedPoints.Except(selection));
                     SelectedPoints = new ObservableCollection<Coordinates>(SelectedPoints.Except(selection));
                     _selectionColor = System.Windows.Media.Colors.Transparent;
                     _selectionColor = System.Windows.Media.Colors.Transparent;
                     break;
                     break;
-                default:
-                    break;
             }
             }
-            
+
             SelectionLayer.ApplyPixels(BitmapPixelChanges.FromSingleColoredArray(selection, _selectionColor));
             SelectionLayer.ApplyPixels(BitmapPixelChanges.FromSingleColoredArray(selection, _selectionColor));
         }
         }
 
 
@@ -57,13 +61,5 @@ namespace PixiEditor.Models.DataHolders
             SelectionLayer.Clear();
             SelectionLayer.Clear();
             SelectedPoints.Clear();
             SelectedPoints.Clear();
         }
         }
-
-        public Selection(Coordinates[] selectedPoints)
-        {
-            SelectedPoints = new ObservableCollection<Coordinates>(selectedPoints);
-            SelectionLayer = new Layer("_selectionLayer", ViewModelMain.Current.BitmapManager.ActiveDocument.Width,
-                ViewModelMain.Current.BitmapManager.ActiveDocument.Height);
-            _selectionBlue = Color.FromArgb(127,142, 202, 255); 
-        }
     }
     }
-}
+}

+ 19 - 18
PixiEditor/Models/DataHolders/SerializableDocument.cs

@@ -1,36 +1,35 @@
-using PixiEditor.Models.Images;
-using PixiEditor.Models.Layers;
-using System;
-using System.Collections.Generic;
+using System;
 using System.Collections.ObjectModel;
 using System.Collections.ObjectModel;
 using System.Linq;
 using System.Linq;
-using System.Text;
 using System.Windows.Media;
 using System.Windows.Media;
+using PixiEditor.Models.Images;
+using PixiEditor.Models.Layers;
 
 
 namespace PixiEditor.Models.DataHolders
 namespace PixiEditor.Models.DataHolders
 {
 {
     [Serializable]
     [Serializable]
     public class SerializableDocument
     public class SerializableDocument
     {
     {
-        public int Width { get; set; }
-        public int Height { get; set; }
-        public SerializableLayer[] Layers { get; set; }
-        public Tuple<byte, byte, byte, byte>[] Swatches { get; set; }
-
         public SerializableDocument(Document document)
         public SerializableDocument(Document document)
         {
         {
             Width = document.Width;
             Width = document.Width;
             Height = document.Height;
             Height = document.Height;
             Layers = document.Layers.Select(x => new SerializableLayer(x)).ToArray();
             Layers = document.Layers.Select(x => new SerializableLayer(x)).ToArray();
-            Swatches = document.Swatches.Select(x=> new Tuple<byte,byte,byte,byte>(x.A, x.R, x.G, x.B)).ToArray();            
+            Swatches = document.Swatches.Select(x => new Tuple<byte, byte, byte, byte>(x.A, x.R, x.G, x.B)).ToArray();
         }
         }
 
 
+        public int Width { get; set; }
+        public int Height { get; set; }
+        public SerializableLayer[] Layers { get; set; }
+        public Tuple<byte, byte, byte, byte>[] Swatches { get; set; }
+
         public Document ToDocument()
         public Document ToDocument()
         {
         {
             Document document = new Document(Width, Height)
             Document document = new Document(Width, Height)
             {
             {
                 Layers = ToLayers(),
                 Layers = ToLayers(),
-                Swatches = new ObservableCollection<Color>(Swatches.Select(x => Color.FromArgb(x.Item1, x.Item2, x.Item3, x.Item4))),                
+                Swatches = new ObservableCollection<Color>(Swatches.Select(x =>
+                    Color.FromArgb(x.Item1, x.Item2, x.Item3, x.Item4)))
             };
             };
             return document;
             return document;
         }
         }
@@ -41,14 +40,16 @@ namespace PixiEditor.Models.DataHolders
             for (int i = 0; i < Layers.Length; i++)
             for (int i = 0; i < Layers.Length; i++)
             {
             {
                 SerializableLayer serLayer = Layers[i];
                 SerializableLayer serLayer = Layers[i];
-                Layer layer = new Layer(BitmapUtils.BytesToWriteableBitmap(serLayer.Width, serLayer.Height, serLayer.BitmapBytes))
-                {
-                    IsVisible = serLayer.IsVisible,
-                    Name = serLayer.Name
-                };
+                Layer layer =
+                    new Layer(BitmapUtils.BytesToWriteableBitmap(serLayer.Width, serLayer.Height, serLayer.BitmapBytes))
+                    {
+                        IsVisible = serLayer.IsVisible,
+                        Name = serLayer.Name
+                    };
                 layers.Add(layer);
                 layers.Add(layer);
             }
             }
+
             return layers;
             return layers;
         }
         }
     }
     }
-}
+}

+ 7 - 13
PixiEditor/Models/DataHolders/StackEx.cs

@@ -4,17 +4,11 @@ namespace PixiEditor.Models.DataHolders
 {
 {
     public class StackEx<T>
     public class StackEx<T>
     {
     {
-        public int Count
-        {
-            get { return items.Count; }
-        }
+        private readonly List<T> items = new List<T>();
 
 
-        public T First
-        {
-            get { return items[0]; }
-        }
+        public int Count => items.Count;
 
 
-        private List<T> items = new List<T>();
+        public T First => items[0];
 
 
         public void Clear()
         public void Clear()
         {
         {
@@ -22,7 +16,7 @@ namespace PixiEditor.Models.DataHolders
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Returns top object without deleting it.
+        ///     Returns top object without deleting it.
         /// </summary>
         /// </summary>
         /// <returns>Returns n - 1 item from stack.</returns>
         /// <returns>Returns n - 1 item from stack.</returns>
         public T Peek()
         public T Peek()
@@ -43,8 +37,8 @@ namespace PixiEditor.Models.DataHolders
                 items.RemoveAt(items.Count - 1);
                 items.RemoveAt(items.Count - 1);
                 return temp;
                 return temp;
             }
             }
-            else
-                return default;
+
+            return default;
         }
         }
 
 
         public void PushToBottom(T item)
         public void PushToBottom(T item)
@@ -57,4 +51,4 @@ namespace PixiEditor.Models.DataHolders
             items.RemoveAt(itemAtPosition);
             items.RemoveAt(itemAtPosition);
         }
         }
     }
     }
-}
+}

+ 11 - 23
PixiEditor/Models/DataHolders/Tuple.cs

@@ -4,24 +4,6 @@ namespace PixiEditor.Models.DataHolders
 {
 {
     public class Tuple<T1, T2, T3> : IEquatable<object>
     public class Tuple<T1, T2, T3> : IEquatable<object>
     {
     {
-        public T1 Item1
-        {
-            get;
-            set;
-        }
-
-        public T2 Item2
-        {
-            get;
-            set;
-        }
-
-        public T3 Item3
-        {
-            get;
-            set;
-        }
-
         public Tuple(T1 Item1, T2 Item2, T3 Item3)
         public Tuple(T1 Item1, T2 Item2, T3 Item3)
         {
         {
             this.Item1 = Item1;
             this.Item1 = Item1;
@@ -29,15 +11,21 @@ namespace PixiEditor.Models.DataHolders
             this.Item3 = Item3;
             this.Item3 = Item3;
         }
         }
 
 
+        public T1 Item1 { get; set; }
+
+        public T2 Item2 { get; set; }
+
+        public T3 Item3 { get; set; }
+
         public override bool Equals(object obj)
         public override bool Equals(object obj)
         {
         {
             if (obj == null || obj as Tuple<T1, T2, T3> == null) //if the object is null or the cast fails
             if (obj == null || obj as Tuple<T1, T2, T3> == null) //if the object is null or the cast fails
-                return false;
-            else
             {
             {
-                Tuple<T1, T2, T3> tuple = (Tuple<T1, T2, T3>)obj;
-                return Item1.Equals(tuple.Item1) && Item2.Equals(tuple.Item2) && Item3.Equals(tuple.Item3);
+                return false;
             }
             }
+
+            Tuple<T1, T2, T3> tuple = (Tuple<T1, T2, T3>) obj;
+            return Item1.Equals(tuple.Item1) && Item2.Equals(tuple.Item2) && Item3.Equals(tuple.Item3);
         }
         }
 
 
         public override int GetHashCode()
         public override int GetHashCode()
@@ -55,4 +43,4 @@ namespace PixiEditor.Models.DataHolders
             return !tuple1.Equals(tuple2);
             return !tuple1.Equals(tuple2);
         }
         }
     }
     }
-}
+}

+ 3 - 9
PixiEditor/Models/Dialogs/ConfirmationDialog.cs

@@ -1,8 +1,5 @@
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Views;
 using PixiEditor.Views;
-using System;
-using System.Collections.Generic;
-using System.Text;
 
 
 namespace PixiEditor.Models.Dialogs
 namespace PixiEditor.Models.Dialogs
 {
 {
@@ -10,15 +7,12 @@ namespace PixiEditor.Models.Dialogs
     {
     {
         public static ConfirmationType Show(string message)
         public static ConfirmationType Show(string message)
         {
         {
-            ConfirmationPopup popup = new ConfirmationPopup()
+            ConfirmationPopup popup = new ConfirmationPopup
             {
             {
                 Body = message
                 Body = message
             };
             };
-            if ((bool)popup.ShowDialog())
-            {
-                return popup.Result ? ConfirmationType.Yes : ConfirmationType.No;
-            }
+            if ((bool) popup.ShowDialog()) return popup.Result ? ConfirmationType.Yes : ConfirmationType.No;
             return ConfirmationType.Canceled;
             return ConfirmationType.Canceled;
         }
         }
     }
     }
-}
+}

+ 1 - 1
PixiEditor/Models/Dialogs/CustomDialog.cs

@@ -6,4 +6,4 @@ namespace PixiEditor.Models.Dialogs
     {
     {
         public abstract bool ShowDialog();
         public abstract bool ShowDialog();
     }
     }
-}
+}

+ 42 - 22
PixiEditor/Models/Dialogs/ExportFileDialog.cs

@@ -1,41 +1,60 @@
-using PixiEditor.Views;
-using System.Windows;
+using System.Windows;
+using PixiEditor.Views;
 
 
 namespace PixiEditor.Models.Dialogs
 namespace PixiEditor.Models.Dialogs
 {
 {
     public class ExportFileDialog : CustomDialog
     public class ExportFileDialog : CustomDialog
     {
     {
+        private int _fileHeight;
+
+
+        private string _filePath;
 
 
         private int _fileWidth;
         private int _fileWidth;
 
 
-        public int FileWidth
+        public ExportFileDialog(Size fileDimensions)
         {
         {
-            get { return _fileWidth; }
-            set { if (_fileWidth != value) { _fileWidth = value; RaisePropertyChanged("Width"); } }
+            FileHeight = (int) fileDimensions.Height;
+            FileWidth = (int) fileDimensions.Width;
         }
         }
 
 
-
-        private int _fileHeight;
-
-        public int FileHeight
+        public int FileWidth
         {
         {
-            get { return _fileHeight; }
-            set { if (_fileHeight != value) { _fileHeight = value; RaisePropertyChanged("FileHeight"); } }
+            get => _fileWidth;
+            set
+            {
+                if (_fileWidth != value)
+                {
+                    _fileWidth = value;
+                    RaisePropertyChanged("Width");
+                }
+            }
         }
         }
 
 
-
-        private string _filePath;
-
-        public string FilePath
+        public int FileHeight
         {
         {
-            get { return _filePath; }
-            set { if (_filePath != value) { _filePath = value; RaisePropertyChanged("FilePath"); } }
+            get => _fileHeight;
+            set
+            {
+                if (_fileHeight != value)
+                {
+                    _fileHeight = value;
+                    RaisePropertyChanged("FileHeight");
+                }
+            }
         }
         }
 
 
-        public ExportFileDialog(Size fileDimensions)
+        public string FilePath
         {
         {
-            FileHeight = (int)fileDimensions.Height;
-            FileWidth = (int)fileDimensions.Width;
+            get => _filePath;
+            set
+            {
+                if (_filePath != value)
+                {
+                    _filePath = value;
+                    RaisePropertyChanged("FilePath");
+                }
+            }
         }
         }
 
 
         public override bool ShowDialog()
         public override bool ShowDialog()
@@ -52,7 +71,8 @@ namespace PixiEditor.Models.Dialogs
                 FileHeight = popup.SaveHeight;
                 FileHeight = popup.SaveHeight;
                 FilePath = popup.SavePath;
                 FilePath = popup.SavePath;
             }
             }
-            return (bool)popup.DialogResult;
+
+            return (bool) popup.DialogResult;
         }
         }
     }
     }
-}
+}

+ 35 - 15
PixiEditor/Models/Dialogs/ImportFileDialog.cs

@@ -2,32 +2,51 @@
 
 
 namespace PixiEditor.Models.Dialogs
 namespace PixiEditor.Models.Dialogs
 {
 {
-    class ImportFileDialog : CustomDialog
+    internal class ImportFileDialog : CustomDialog
     {
     {
+        private int _fileHeight;
+
+
+        private string _filePath;
         private int _fileWidth;
         private int _fileWidth;
 
 
         public int FileWidth
         public int FileWidth
         {
         {
-            get { return _fileWidth; }
-            set { if (_fileWidth != value) { _fileWidth = value; RaisePropertyChanged("Width"); } }
+            get => _fileWidth;
+            set
+            {
+                if (_fileWidth != value)
+                {
+                    _fileWidth = value;
+                    RaisePropertyChanged("Width");
+                }
+            }
         }
         }
 
 
-
-        private int _fileHeight;
-
         public int FileHeight
         public int FileHeight
         {
         {
-            get { return _fileHeight; }
-            set { if (_fileHeight != value) { _fileHeight = value; RaisePropertyChanged("FileHeight"); } }
+            get => _fileHeight;
+            set
+            {
+                if (_fileHeight != value)
+                {
+                    _fileHeight = value;
+                    RaisePropertyChanged("FileHeight");
+                }
+            }
         }
         }
 
 
-
-        private string _filePath;
-
         public string FilePath
         public string FilePath
         {
         {
-            get { return _filePath; }
-            set { if (_filePath != value) { _filePath = value; RaisePropertyChanged("FilePath"); } }
+            get => _filePath;
+            set
+            {
+                if (_filePath != value)
+                {
+                    _filePath = value;
+                    RaisePropertyChanged("FilePath");
+                }
+            }
         }
         }
 
 
         public override bool ShowDialog()
         public override bool ShowDialog()
@@ -41,7 +60,8 @@ namespace PixiEditor.Models.Dialogs
                 FileWidth = popup.ImportWidth;
                 FileWidth = popup.ImportWidth;
                 FilePath = popup.FilePath;
                 FilePath = popup.FilePath;
             }
             }
-            return (bool)popup.DialogResult;
+
+            return (bool) popup.DialogResult;
         }
         }
     }
     }
-}
+}

+ 23 - 11
PixiEditor/Models/Dialogs/NewFileDialog.cs

@@ -1,26 +1,38 @@
-using PixiEditor.Views;
-using System.Windows;
+using System.Windows;
+using PixiEditor.Views;
 
 
 namespace PixiEditor.Models.Dialogs
 namespace PixiEditor.Models.Dialogs
 {
 {
     public class NewFileDialog : CustomDialog
     public class NewFileDialog : CustomDialog
     {
     {
+        private int _height;
 
 
         private int _width;
         private int _width;
 
 
         public int Width
         public int Width
         {
         {
-            get { return _width; }
-            set { if (_width != value) { _width = value; RaisePropertyChanged("Width"); } }
+            get => _width;
+            set
+            {
+                if (_width != value)
+                {
+                    _width = value;
+                    RaisePropertyChanged("Width");
+                }
+            }
         }
         }
 
 
-
-        private int _height;
-
         public int Height
         public int Height
         {
         {
-            get { return _height; }
-            set { if (_height != value) { _height = value; RaisePropertyChanged("Height"); } }
+            get => _height;
+            set
+            {
+                if (_height != value)
+                {
+                    _height = value;
+                    RaisePropertyChanged("Height");
+                }
+            }
         }
         }
 
 
         public override bool ShowDialog()
         public override bool ShowDialog()
@@ -29,7 +41,7 @@ namespace PixiEditor.Models.Dialogs
             popup.ShowDialog();
             popup.ShowDialog();
             Height = (popup as NewFilePopup).FileHeight;
             Height = (popup as NewFilePopup).FileHeight;
             Width = (popup as NewFilePopup).FileWidth;
             Width = (popup as NewFilePopup).FileWidth;
-            return (bool)popup.DialogResult;
+            return (bool) popup.DialogResult;
         }
         }
     }
     }
-}
+}

+ 33 - 21
PixiEditor/Models/Dialogs/ResizeDocumentDialog.cs

@@ -1,37 +1,47 @@
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Views;
 using PixiEditor.Views;
-using System;
-using System.Collections.Generic;
-using System.Text;
 
 
 namespace PixiEditor.Models.Dialogs
 namespace PixiEditor.Models.Dialogs
 {
 {
     public class ResizeDocumentDialog : CustomDialog
     public class ResizeDocumentDialog : CustomDialog
     {
     {
-        public bool OpenResizeCanvas { get; set; } = false;
-        public AnchorPoint ResizeAnchor { get; set; }
+        private int _height;
         private int _width;
         private int _width;
 
 
-        public int Width
+        public ResizeDocumentDialog(int currentWidth, int currentHeight, bool openResizeCanvas = false)
         {
         {
-            get { return _width; }
-            set { if (_width != value) { _width = value; RaisePropertyChanged("Width"); } }
+            Width = currentWidth;
+            Height = currentHeight;
+            OpenResizeCanvas = openResizeCanvas;
         }
         }
 
 
+        public bool OpenResizeCanvas { get; set; }
+        public AnchorPoint ResizeAnchor { get; set; }
 
 
-        private int _height;
-
-        public int Height
+        public int Width
         {
         {
-            get { return _height; }
-            set { if (_height != value) { _height = value; RaisePropertyChanged("Height"); } }
+            get => _width;
+            set
+            {
+                if (_width != value)
+                {
+                    _width = value;
+                    RaisePropertyChanged("Width");
+                }
+            }
         }
         }
 
 
-        public ResizeDocumentDialog(int currentWidth, int currentHeight, bool openResizeCanvas = false)
+        public int Height
         {
         {
-            Width = currentWidth;
-            Height = currentHeight;
-            OpenResizeCanvas = openResizeCanvas;
+            get => _height;
+            set
+            {
+                if (_height != value)
+                {
+                    _height = value;
+                    RaisePropertyChanged("Height");
+                }
+            }
         }
         }
 
 
         public override bool ShowDialog()
         public override bool ShowDialog()
@@ -49,11 +59,12 @@ namespace PixiEditor.Models.Dialogs
 
 
             popup.ShowDialog();
             popup.ShowDialog();
             if (popup.DialogResult == true)
             if (popup.DialogResult == true)
-            { 
+            {
                 Width = popup.NewWidth;
                 Width = popup.NewWidth;
                 Height = popup.NewHeight;
                 Height = popup.NewHeight;
             }
             }
-            return (bool)popup.DialogResult;
+
+            return (bool) popup.DialogResult;
         }
         }
 
 
         private bool ShowResizeCanvasDialog()
         private bool ShowResizeCanvasDialog()
@@ -71,7 +82,8 @@ namespace PixiEditor.Models.Dialogs
                 Height = popup.NewHeight;
                 Height = popup.NewHeight;
                 ResizeAnchor = popup.SelectedAnchorPoint;
                 ResizeAnchor = popup.SelectedAnchorPoint;
             }
             }
-            return (bool)popup.DialogResult;
+
+            return (bool) popup.DialogResult;
         }
         }
     }
     }
-}
+}

+ 6 - 8
PixiEditor/Models/Enums/AnchorPoint.cs

@@ -1,17 +1,15 @@
 using System;
 using System;
-using System.Collections.Generic;
-using System.Text;
 
 
 namespace PixiEditor.Models.Enums
 namespace PixiEditor.Models.Enums
 {
 {
     [Flags]
     [Flags]
     public enum AnchorPoint
     public enum AnchorPoint
     {
     {
-        Left = 1, 
-        Center = 2, 
-        Right = 4, 
-        Top = 8, 
-        Middle = 16, 
+        Left = 1,
+        Center = 2,
+        Right = 4,
+        Top = 8,
+        Middle = 16,
         Bottom = 32
         Bottom = 32
     }
     }
-}
+}

+ 5 - 7
PixiEditor/Models/Enums/ConfirmationType.cs

@@ -1,11 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace PixiEditor.Models.Enums
+namespace PixiEditor.Models.Enums
 {
 {
     public enum ConfirmationType
     public enum ConfirmationType
     {
     {
-        Yes, No, Canceled
+        Yes,
+        No,
+        Canceled
     }
     }
-}
+}

+ 2 - 2
PixiEditor/Models/Enums/FileType.cs

@@ -2,6 +2,6 @@
 {
 {
     public enum FileType
     public enum FileType
     {
     {
-        PNG = 0,
+        PNG = 0
     }
     }
-}
+}

+ 5 - 2
PixiEditor/Models/Enums/LayerAction.cs

@@ -2,6 +2,9 @@
 {
 {
     public enum LayerAction
     public enum LayerAction
     {
     {
-        Add, Remove, Move, SetActive
+        Add,
+        Remove,
+        Move,
+        SetActive
     }
     }
-}
+}

+ 5 - 7
PixiEditor/Models/Enums/SelectionType.cs

@@ -1,11 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace PixiEditor.Models.Enums
+namespace PixiEditor.Models.Enums
 {
 {
     public enum SelectionType
     public enum SelectionType
     {
     {
-        New, Add, Substract
+        New,
+        Add,
+        Substract
     }
     }
-}
+}

+ 3 - 6
PixiEditor/Models/Events/DocumentChangedEventArgs.cs

@@ -1,17 +1,14 @@
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
-using System;
-using System.Collections.Generic;
-using System.Text;
 
 
 namespace PixiEditor.Models.Events
 namespace PixiEditor.Models.Events
 {
 {
     public class DocumentChangedEventArgs
     public class DocumentChangedEventArgs
     {
     {
-        public Document NewDocument { get; set; }
-
         public DocumentChangedEventArgs(Document newDocument)
         public DocumentChangedEventArgs(Document newDocument)
         {
         {
             NewDocument = newDocument;
             NewDocument = newDocument;
         }
         }
+
+        public Document NewDocument { get; set; }
     }
     }
-}
+}

+ 2 - 2
PixiEditor/Models/IO/BinarySerialization.cs

@@ -19,8 +19,8 @@ namespace PixiEditor.Models.IO
             using (Stream stream = File.Open(path, FileMode.Open))
             using (Stream stream = File.Open(path, FileMode.Open))
             {
             {
                 BinaryFormatter formatter = new BinaryFormatter();
                 BinaryFormatter formatter = new BinaryFormatter();
-                return (T)formatter.Deserialize(stream);
+                return (T) formatter.Deserialize(stream);
             }
             }
         }
         }
     }
     }
-}
+}

+ 32 - 35
PixiEditor/Models/IO/Exporter.cs

@@ -1,43 +1,38 @@
-using Microsoft.Win32;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Dialogs;
-using PixiEditor.Models.Enums;
-using System;
+using System;
 using System.IO;
 using System.IO;
 using System.Windows;
 using System.Windows;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using Microsoft.Win32;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Dialogs;
 
 
 namespace PixiEditor.Models.IO
 namespace PixiEditor.Models.IO
 {
 {
     public class Exporter
     public class Exporter
     {
     {
-        public static string SaveDocumentPath { get; set; } = null;
         public static Size FileDimensions;
         public static Size FileDimensions;
+        public static string SaveDocumentPath { get; set; }
 
 
-        public static void SaveAsNewEditableFile(Document document, bool updateWorkspacePath = false)
-        {
-            SaveFileDialog dialog = new SaveFileDialog
-            {
-                Filter = "PixiEditor Files | *.pixi",
-                DefaultExt = "pixi"
-            };
-            if ((bool)dialog.ShowDialog())
-            {
-                SaveAsEditableFile(document, dialog.FileName, updateWorkspacePath);
-            }
+        public static void SaveAsNewEditableFile(Document document, bool updateWorkspacePath = false)
+        {
+            SaveFileDialog dialog = new SaveFileDialog
+            {
+                Filter = "PixiEditor Files | *.pixi",
+                DefaultExt = "pixi"
+            };
+            if ((bool) dialog.ShowDialog()) SaveAsEditableFile(document, dialog.FileName, updateWorkspacePath);
         }
         }
 
 
-        public static void SaveAsEditableFile(Document document, string path, bool updateWorkspacePath = false)
-        {
-
-            BinarySerialization.WriteToBinaryFile(path, new SerializableDocument(document));
-
-            if (updateWorkspacePath)
-                SaveDocumentPath = path;
+        public static void SaveAsEditableFile(Document document, string path, bool updateWorkspacePath = false)
+        {
+            BinarySerialization.WriteToBinaryFile(path, new SerializableDocument(document));
+
+            if (updateWorkspacePath)
+                SaveDocumentPath = path;
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates ExportFileDialog to get width, height and path of file.
+        ///     Creates ExportFileDialog to get width, height and path of file.
         /// </summary>
         /// </summary>
         /// <param name="type">Type of file to be saved in.</param>
         /// <param name="type">Type of file to be saved in.</param>
         /// <param name="bitmap">Bitmap to be saved as file.</param>
         /// <param name="bitmap">Bitmap to be saved as file.</param>
@@ -45,12 +40,13 @@ namespace PixiEditor.Models.IO
         {
         {
             ExportFileDialog info = new ExportFileDialog(fileDimensions);
             ExportFileDialog info = new ExportFileDialog(fileDimensions);
             //If OK on dialog has been clicked
             //If OK on dialog has been clicked
-            if (info.ShowDialog() == true)
+            if (info.ShowDialog())
             {
             {
                 //If sizes are incorrect
                 //If sizes are incorrect
                 if (info.FileWidth < bitmap.Width || info.FileHeight < bitmap.Height)
                 if (info.FileWidth < bitmap.Width || info.FileHeight < bitmap.Height)
                 {
                 {
-                    MessageBox.Show("Incorrect height or width value", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+                    MessageBox.Show("Incorrect height or width value", "Error", MessageBoxButton.OK,
+                        MessageBoxImage.Error);
                     return;
                     return;
                 }
                 }
 
 
@@ -60,7 +56,7 @@ namespace PixiEditor.Models.IO
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Saves image to PNG file
+        ///     Saves image to PNG file
         /// </summary>
         /// </summary>
         /// <param name="savePath">Save file path</param>
         /// <param name="savePath">Save file path</param>
         /// <param name="exportWidth">File width</param>
         /// <param name="exportWidth">File width</param>
@@ -69,12 +65,13 @@ namespace PixiEditor.Models.IO
         {
         {
             try
             try
             {
             {
-                bitmap = bitmap.Resize(exportWidth, exportHeight, WriteableBitmapExtensions.Interpolation.NearestNeighbor);
-                using (FileStream stream = new FileStream(savePath, FileMode.Create))
-                {
-                    PngBitmapEncoder encoder = new PngBitmapEncoder();
-                    encoder.Frames.Add(BitmapFrame.Create(bitmap));
-                    encoder.Save(stream);
+                bitmap = bitmap.Resize(exportWidth, exportHeight,
+                    WriteableBitmapExtensions.Interpolation.NearestNeighbor);
+                using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                {
+                    PngBitmapEncoder encoder = new PngBitmapEncoder();
+                    encoder.Frames.Add(BitmapFrame.Create(bitmap));
+                    encoder.Save(stream);
                 }
                 }
             }
             }
             catch (Exception err)
             catch (Exception err)
@@ -83,4 +80,4 @@ namespace PixiEditor.Models.IO
             }
             }
         }
         }
     }
     }
-}
+}

+ 11 - 23
PixiEditor/Models/IO/FilesManager.cs

@@ -1,30 +1,21 @@
-using Newtonsoft.Json;
-using System;
+using System;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.IO;
 using System.IO;
+using Newtonsoft.Json;
 
 
 namespace PixiEditor.Models.IO
 namespace PixiEditor.Models.IO
 {
 {
     public static class FilesManager
     public static class FilesManager
     {
     {
+        public static string TempFolderPath =>
+            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"PixiEditor\Temp");
 
 
-        public static string TempFolderPath
-        {
-            get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"PixiEditor\Temp"); }
-        }
+        public static string RedoStackPath => Path.Combine(TempFolderPath, @"RedoStack");
 
 
-        public static string RedoStackPath
-        {
-            get { return Path.Combine(TempFolderPath, @"RedoStack"); }
-        }
-
-        public static string UndoStackPath
-        {
-            get { return Path.Combine(TempFolderPath, @"UndoStack"); }
-        }
+        public static string UndoStackPath => Path.Combine(TempFolderPath, @"UndoStack");
 
 
         /// <summary>
         /// <summary>
-        /// Saves object to file on disk using binary formatter
+        ///     Saves object to file on disk using binary formatter
         /// </summary>
         /// </summary>
         /// <param name="obj">Object to be saved</param>
         /// <param name="obj">Object to be saved</param>
         public static void SaveObjectToJsonFile<T>(T obj, string fileName) where T : new()
         public static void SaveObjectToJsonFile<T>(T obj, string fileName) where T : new()
@@ -46,16 +37,13 @@ namespace PixiEditor.Models.IO
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Removes all files from directory
+        ///     Removes all files from directory
         /// </summary>
         /// </summary>
         /// <param name="path"></param>
         /// <param name="path"></param>
         public static void ClearDirectory(string path)
         public static void ClearDirectory(string path)
         {
         {
             string[] filesInDirectory = Directory.GetFiles(path);
             string[] filesInDirectory = Directory.GetFiles(path);
-            for (int i = 0; i < filesInDirectory.Length; i++)
-            {
-                File.Delete(filesInDirectory[i]);
-            }
+            for (int i = 0; i < filesInDirectory.Length; i++) File.Delete(filesInDirectory[i]);
         }
         }
 
 
         private static void SaveSerializedObjectToFile(object obj, string filename)
         private static void SaveSerializedObjectToFile(object obj, string filename)
@@ -77,7 +65,7 @@ namespace PixiEditor.Models.IO
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates and cleares temp directories
+        ///     Creates and cleares temp directories
         /// </summary>
         /// </summary>
         public static void InitializeTempDirectories()
         public static void InitializeTempDirectories()
         {
         {
@@ -98,4 +86,4 @@ namespace PixiEditor.Models.IO
             ClearDirectory(UndoStackPath);
             ClearDirectory(UndoStackPath);
         }
         }
     }
     }
-}
+}

+ 5 - 5
PixiEditor/Models/IO/Importer.cs

@@ -1,14 +1,14 @@
-using PixiEditor.Helpers;
-using PixiEditor.Models.DataHolders;
-using System;
+using System;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Helpers;
+using PixiEditor.Models.DataHolders;
 
 
 namespace PixiEditor.Models.IO
 namespace PixiEditor.Models.IO
 {
 {
     public class Importer : NotifyableObject
     public class Importer : NotifyableObject
     {
     {
         /// <summary>
         /// <summary>
-        /// Imports image from path and resizes it to given dimensions
+        ///     Imports image from path and resizes it to given dimensions
         /// </summary>
         /// </summary>
         /// <param name="path">Path of image.</param>
         /// <param name="path">Path of image.</param>
         /// <param name="width">New width of image.</param>
         /// <param name="width">New width of image.</param>
@@ -37,4 +37,4 @@ namespace PixiEditor.Models.IO
             return path.EndsWith(".pixi") || path.EndsWith(".png") || path.EndsWith(".jpg") || path.EndsWith(".jpeg");
             return path.EndsWith(".pixi") || path.EndsWith(".png") || path.EndsWith(".jpg") || path.EndsWith(".jpeg");
         }
         }
     }
     }
-}
+}

+ 21 - 40
PixiEditor/Models/ImageManipulation/Morphology.cs

@@ -1,13 +1,12 @@
-using PixiEditor.Models.Position;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using PixiEditor.Models.Position;
 
 
 namespace PixiEditor.Models.ImageManipulation
 namespace PixiEditor.Models.ImageManipulation
 {
 {
     public class Morphology
     public class Morphology
     {
     {
-
         public static Coordinates[] ApplyDilation(Coordinates[] points, int kernelSize, int[,] mask)
         public static Coordinates[] ApplyDilation(Coordinates[] points, int kernelSize, int[,] mask)
         {
         {
             int kernelDim = kernelSize;
             int kernelDim = kernelSize;
@@ -23,30 +22,21 @@ namespace PixiEditor.Models.ImageManipulation
             int width = byteImg.GetLength(0);
             int width = byteImg.GetLength(0);
             int height = byteImg.GetLength(1);
             int height = byteImg.GetLength(1);
             for (int y = kernelOffset; y < height - kernelOffset; y++)
             for (int y = kernelOffset; y < height - kernelOffset; y++)
+            for (int x = kernelOffset; x < width - kernelOffset; x++)
             {
             {
-                for (int x = kernelOffset; x < width - kernelOffset; x++)
-                {
-                    byte value = 0;
+                byte value = 0;
 
 
-                    //Apply dilation
-                    for (int ykernel = -kernelOffset; ykernel <= kernelOffset; ykernel++)
-                    {
-                        for (int xkernel = -kernelOffset; xkernel <= kernelOffset; xkernel++)
-                        {
-                            if (mask[xkernel + kernelOffset, ykernel + kernelOffset] == 1)
-                            {
-                                value = Math.Max(value, byteImg[x + xkernel, y + ykernel]);
-                            }
-                            else
-                            {
-                                continue;
-                            }
-                        }
-                    }
-                    //Write processed data into the second array
-                    outputArray[x, y] = value;
-                }
+                //Apply dilation
+                for (int ykernel = -kernelOffset; ykernel <= kernelOffset; ykernel++)
+                for (int xkernel = -kernelOffset; xkernel <= kernelOffset; xkernel++)
+                    if (mask[xkernel + kernelOffset, ykernel + kernelOffset] == 1)
+                        value = Math.Max(value, byteImg[x + xkernel, y + ykernel]);
+                    else
+                        continue;
+                //Write processed data into the second array
+                outputArray[x, y] = value;
             }
             }
+
             return ToCoordinates(outputArray, offset).Distinct().ToArray();
             return ToCoordinates(outputArray, offset).Distinct().ToArray();
         }
         }
 
 
@@ -56,16 +46,9 @@ namespace PixiEditor.Models.ImageManipulation
             int width = byteArray.GetLength(0);
             int width = byteArray.GetLength(0);
 
 
             for (int y = 0; y < byteArray.GetLength(1); y++)
             for (int y = 0; y < byteArray.GetLength(1); y++)
-            {
-                for (int x = 0; x < width; x++)
-                {
-                    if (byteArray[x, y] == 1)
-                    {
-                        output.Add(new Coordinates(x + offset.X, y + offset.Y));
-                    }
-
-                }
-            }
+            for (int x = 0; x < width; x++)
+                if (byteArray[x, y] == 1)
+                    output.Add(new Coordinates(x + offset.X, y + offset.Y));
             return output.ToArray();
             return output.ToArray();
         }
         }
 
 
@@ -78,12 +61,10 @@ namespace PixiEditor.Models.ImageManipulation
             //Debug.Write("----------\n");
             //Debug.Write("----------\n");
 
 
             for (int y = 0; y < dimensions.Item2 + margin; y++)
             for (int y = 0; y < dimensions.Item2 + margin; y++)
+            for (int x = 0; x < dimensions.Item1 + margin; x++)
             {
             {
-                for (int x = 0; x < dimensions.Item1 + margin; x++)
-                {
-                    Coordinates cords = new Coordinates(x + minX, y + minY);
-                    array[x + margin, y + margin] = points.Contains(cords) ? (byte)1 : (byte)0;
-                }
+                Coordinates cords = new Coordinates(x + minX, y + minY);
+                array[x + margin, y + margin] = points.Contains(cords) ? (byte) 1 : (byte) 0;
             }
             }
 
 
             //for (int y = 0; y < array.GetLength(1); y++)
             //for (int y = 0; y < array.GetLength(1); y++)
@@ -105,4 +86,4 @@ namespace PixiEditor.Models.ImageManipulation
             return new Tuple<int, int>(width + 1, height + 1);
             return new Tuple<int, int>(width + 1, height + 1);
         }
         }
     }
     }
-}
+}

+ 2 - 4
PixiEditor/Models/ImageManipulation/Transform.cs

@@ -5,7 +5,7 @@ namespace PixiEditor.Models.ImageManipulation
     public static class Transform
     public static class Transform
     {
     {
         /// <summary>
         /// <summary>
-        /// Returns translation between two coordinates.
+        ///     Returns translation between two coordinates.
         /// </summary>
         /// </summary>
         /// <param name="from">Starting coordinate</param>
         /// <param name="from">Starting coordinate</param>
         /// <param name="to">New coordinate</param>
         /// <param name="to">New coordinate</param>
@@ -21,10 +21,8 @@ namespace PixiEditor.Models.ImageManipulation
         {
         {
             Coordinates[] translatedPoints = new Coordinates[points.Length];
             Coordinates[] translatedPoints = new Coordinates[points.Length];
             for (int i = 0; i < translatedPoints.Length; i++)
             for (int i = 0; i < translatedPoints.Length; i++)
-            {
                 translatedPoints[i] = new Coordinates(points[i].X + vector.X, points[i].Y + vector.Y);
                 translatedPoints[i] = new Coordinates(points[i].X + vector.X, points[i].Y + vector.Y);
-            }
             return translatedPoints;
             return translatedPoints;
         }
         }
     }
     }
-}
+}

+ 24 - 27
PixiEditor/Models/Images/BitmapUtils.cs

@@ -1,19 +1,20 @@
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Drawing;
 using System.Drawing;
 using System.Linq;
 using System.Linq;
 using System.Windows;
 using System.Windows;
-using System.Windows.Media;
+using System.Windows.Interop;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
+using Color = System.Windows.Media.Color;
 
 
 namespace PixiEditor.Models.Images
 namespace PixiEditor.Models.Images
 {
 {
     public static class BitmapUtils
     public static class BitmapUtils
     {
     {
-        public static WriteableBitmap BytesToWriteableBitmap(int currentBitmapWidth, int currentBitmapHeight, byte[] byteArray)
+        public static WriteableBitmap BytesToWriteableBitmap(int currentBitmapWidth, int currentBitmapHeight,
+            byte[] byteArray)
         {
         {
             WriteableBitmap bitmap = BitmapFactory.New(currentBitmapWidth, currentBitmapHeight);
             WriteableBitmap bitmap = BitmapFactory.New(currentBitmapWidth, currentBitmapHeight);
             bitmap.FromByteArray(byteArray);
             bitmap.FromByteArray(byteArray);
@@ -22,11 +23,11 @@ namespace PixiEditor.Models.Images
 
 
         public static BitmapSource BitmapToBitmapSource(Bitmap bitmap)
         public static BitmapSource BitmapToBitmapSource(Bitmap bitmap)
         {
         {
-            return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
-                  bitmap.GetHbitmap(),
-                  IntPtr.Zero,
-                  Int32Rect.Empty,
-                  BitmapSizeOptions.FromEmptyOptions());
+            return Imaging.CreateBitmapSourceFromHBitmap(
+                bitmap.GetHbitmap(),
+                IntPtr.Zero,
+                Int32Rect.Empty,
+                BitmapSizeOptions.FromEmptyOptions());
         }
         }
 
 
         public static WriteableBitmap CombineBitmaps(Layer[] layers)
         public static WriteableBitmap CombineBitmaps(Layer[] layers)
@@ -41,40 +42,36 @@ namespace PixiEditor.Models.Images
             using (finalBitmap.GetBitmapContext())
             using (finalBitmap.GetBitmapContext())
             {
             {
                 for (int i = 1; i < bitmaps.Length; i++)
                 for (int i = 1; i < bitmaps.Length; i++)
+                for (int y = 0; y < finalBitmap.Height; y++)
+                for (int x = 0; x < finalBitmap.Width; x++)
                 {
                 {
-                    for (int y = 0; y < finalBitmap.Height; y++)
-                    {
-                        for (int x = 0; x < finalBitmap.Width; x++)
-                        {
-                            System.Windows.Media.Color color = bitmaps[i].GetPixel(x, y);
-                            if (color.A != 0 || color.R != 0 || color.B != 0 || color.G != 0)
-                            {
-                                finalBitmap.SetPixel(x, y, color);
-                            }
-                        }
-                    }
+                    Color color = bitmaps[i].GetPixel(x, y);
+                    if (color.A != 0 || color.R != 0 || color.B != 0 || color.G != 0) finalBitmap.SetPixel(x, y, color);
                 }
                 }
             }
             }
+
             finalBitmap.Unlock();
             finalBitmap.Unlock();
             return finalBitmap;
             return finalBitmap;
         }
         }
 
 
-        public static Dictionary<Layer, System.Windows.Media.Color[]> GetPixelsForSelection(Layer[] layers, Coordinates[] selection)
+        public static Dictionary<Layer, Color[]> GetPixelsForSelection(Layer[] layers, Coordinates[] selection)
         {
         {
-            Dictionary<Layer, System.Windows.Media.Color[]> result = new Dictionary<Layer, System.Windows.Media.Color[]>();
+            Dictionary<Layer, Color[]> result = new Dictionary<Layer, Color[]>();
 
 
             for (int i = 0; i < layers.Length; i++)
             for (int i = 0; i < layers.Length; i++)
             {
             {
-                System.Windows.Media.Color[] pixels = new System.Windows.Media.Color[selection.Length];
+                Color[] pixels = new Color[selection.Length];
                 layers[i].LayerBitmap.Lock();
                 layers[i].LayerBitmap.Lock();
 
 
                 for (int j = 0; j < pixels.Length; j++)
                 for (int j = 0; j < pixels.Length; j++)
                 {
                 {
                     Coordinates position = selection[j];
                     Coordinates position = selection[j];
-                    if (position.X < 0 || position.X > layers[i].Width - 1 || position.Y < 0 || position.Y > layers[i].Height - 1)
+                    if (position.X < 0 || position.X > layers[i].Width - 1 || position.Y < 0 ||
+                        position.Y > layers[i].Height - 1)
                         continue;
                         continue;
                     pixels[j] = layers[i].LayerBitmap.GetPixel(position.X, position.Y);
                     pixels[j] = layers[i].LayerBitmap.GetPixel(position.X, position.Y);
                 }
                 }
+
                 layers[i].LayerBitmap.Unlock();
                 layers[i].LayerBitmap.Unlock();
 
 
                 result[layers[i]] = pixels;
                 result[layers[i]] = pixels;
@@ -83,4 +80,4 @@ namespace PixiEditor.Models.Images
             return result;
             return result;
         }
         }
     }
     }
-}
+}

+ 1 - 1
PixiEditor/Models/Images/ImageGenerator.cs

@@ -16,4 +16,4 @@ namespace PixiEditor.Models.Images
             return image;
             return image;
         }
         }
     }
     }
-}
+}

+ 16 - 9
PixiEditor/Models/Layers/BasicLayer.cs

@@ -1,26 +1,33 @@
-using PixiEditor.Helpers;
-using System;
+using System;
+using PixiEditor.Helpers;
 
 
 namespace PixiEditor.Models.Layers
 namespace PixiEditor.Models.Layers
 {
 {
     [Serializable]
     [Serializable]
     public class BasicLayer : NotifyableObject
     public class BasicLayer : NotifyableObject
     {
     {
+        private int _height;
 
 
         private int _width;
         private int _width;
 
 
         public int Width
         public int Width
         {
         {
-            get { return _width; }
-            set { _width = value; RaisePropertyChanged("Width"); }
+            get => _width;
+            set
+            {
+                _width = value;
+                RaisePropertyChanged("Width");
+            }
         }
         }
 
 
-        private int _height;
-
         public int Height
         public int Height
         {
         {
-            get { return _height; }
-            set { _height = value; RaisePropertyChanged("Height"); }
+            get => _height;
+            set
+            {
+                _height = value;
+                RaisePropertyChanged("Height");
+            }
         }
         }
     }
     }
-}
+}

+ 78 - 79
PixiEditor/Models/Layers/Layer.cs

@@ -1,70 +1,18 @@
-using PixiEditor.Models.Images;
-using PixiEditor.Models.Tools;
-using System;
+using System;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Models.Tools;
 
 
 namespace PixiEditor.Models.Layers
 namespace PixiEditor.Models.Layers
 {
 {
     public class Layer : BasicLayer
     public class Layer : BasicLayer
     {
     {
-        private WriteableBitmap _layerBitmap;
+        private bool _isActive;
 
 
-        private string _name;
-
-        public string Name
-        {
-            get { return _name; }
-            set
-            {
-                _name = value;
-                RaisePropertyChanged("Name");
-            }
-        }
-
-
-        private bool _isActive = false;
-        public bool IsActive
-        {
-            get => _isActive;
-            set
-            {
-                _isActive = value;
-                RaisePropertyChanged("IsActive");
-            }
-        }
+        private bool _isRenaming;
         private bool _isVisible = true;
         private bool _isVisible = true;
-        public bool IsVisible
-        {
-            get => _isVisible;
-            set
-            {
-                _isVisible = value;
-                RaisePropertyChanged("IsVisible");
-            }
-        }
+        private WriteableBitmap _layerBitmap;
 
 
-        private bool _isRenaming = false;
-
-        public bool IsRenaming
-        {
-            get { return _isRenaming; }
-            set
-            {
-                _isRenaming = value;
-                RaisePropertyChanged("IsRenaming");
-            }
-        }
-
-
-        public WriteableBitmap LayerBitmap
-        {
-            get => _layerBitmap;
-            set
-            {
-                _layerBitmap = value;
-                RaisePropertyChanged("LayerBitmap");
-            }
-        }
+        private string _name;
 
 
         public Layer(string name, int width, int height)
         public Layer(string name, int width, int height)
         {
         {
@@ -79,38 +27,90 @@ namespace PixiEditor.Models.Layers
         public Layer(WriteableBitmap layerBitmap)
         public Layer(WriteableBitmap layerBitmap)
         {
         {
             LayerBitmap = layerBitmap;
             LayerBitmap = layerBitmap;
-            Width = (int)layerBitmap.Width;
-            Height = (int)layerBitmap.Height;
+            Width = (int) layerBitmap.Width;
+            Height = (int) layerBitmap.Height;
+        }
+
+        public string Name
+        {
+            get => _name;
+            set
+            {
+                _name = value;
+                RaisePropertyChanged("Name");
+            }
+        }
+
+        public bool IsActive
+        {
+            get => _isActive;
+            set
+            {
+                _isActive = value;
+                RaisePropertyChanged("IsActive");
+            }
+        }
+
+        public bool IsVisible
+        {
+            get => _isVisible;
+            set
+            {
+                _isVisible = value;
+                RaisePropertyChanged("IsVisible");
+            }
+        }
+
+        public bool IsRenaming
+        {
+            get => _isRenaming;
+            set
+            {
+                _isRenaming = value;
+                RaisePropertyChanged("IsRenaming");
+            }
+        }
+
+
+        public WriteableBitmap LayerBitmap
+        {
+            get => _layerBitmap;
+            set
+            {
+                _layerBitmap = value;
+                RaisePropertyChanged("LayerBitmap");
+            }
         }
         }
 
 
-        /// <summary>
-        /// Applies pixels to layer
-        /// </summary>
+        /// <summary>
+        ///     Applies pixels to layer
+        /// </summary>
         /// <param name="pixels"></param>
         /// <param name="pixels"></param>
         public void ApplyPixels(BitmapPixelChanges pixels)
         public void ApplyPixels(BitmapPixelChanges pixels)
         {
         {
             if (pixels.ChangedPixels == null) return;
             if (pixels.ChangedPixels == null) return;
-            using (LayerBitmap.GetBitmapContext())
-            {
-
-                foreach (var coords in pixels.ChangedPixels)
-                {
-                    if (coords.Key.X > Width - 1 || coords.Key.X < 0 || coords.Key.Y < 0 || coords.Key.Y > Height - 1) continue;
-                    LayerBitmap.SetPixel(Math.Clamp(coords.Key.X, 0, Width - 1), Math.Clamp(coords.Key.Y, 0, Height - 1),
-                        coords.Value);
+            using (LayerBitmap.GetBitmapContext())
+            {
+                foreach (var coords in pixels.ChangedPixels)
+                {
+                    if (coords.Key.X > Width - 1 || coords.Key.X < 0 || coords.Key.Y < 0 ||
+                        coords.Key.Y > Height - 1) continue;
+                    LayerBitmap.SetPixel(Math.Clamp(coords.Key.X, 0, Width - 1),
+                        Math.Clamp(coords.Key.Y, 0, Height - 1),
+                        coords.Value);
                 }
                 }
             }
             }
         }
         }
 
 
-        public void Clear()
-        {
-            LayerBitmap.Lock();
-            LayerBitmap.Clear();
-            LayerBitmap.Unlock();
+        public void Clear()
+        {
+            LayerBitmap.Lock();
+            LayerBitmap.Clear();
+            LayerBitmap.Unlock();
         }
         }
 
 
         public byte[] ConvertBitmapToBytes()
         public byte[] ConvertBitmapToBytes()
-        {
+        {
             LayerBitmap.Lock();
             LayerBitmap.Lock();
             byte[] byteArray = LayerBitmap.ToByteArray();
             byte[] byteArray = LayerBitmap.ToByteArray();
             LayerBitmap.Unlock();
             LayerBitmap.Unlock();
@@ -131,6 +131,5 @@ namespace PixiEditor.Models.Layers
             Height = newHeight;
             Height = newHeight;
             Width = newWidth;
             Width = newWidth;
         }
         }
-
     }
     }
-}
+}

+ 3 - 4
PixiEditor/Models/Layers/LayerGenerator.cs

@@ -5,7 +5,7 @@ namespace PixiEditor.Models.Layers
     public static class LayerGenerator
     public static class LayerGenerator
     {
     {
         /// <summary>
         /// <summary>
-        /// Generating useable layer with image and bitmap
+        ///     Generating useable layer with image and bitmap
         /// </summary>
         /// </summary>
         /// <param name="imageWidth">Width of layer.</param>
         /// <param name="imageWidth">Width of layer.</param>
         /// <param name="imageHeight">Height of layer.</param>
         /// <param name="imageHeight">Height of layer.</param>
@@ -16,7 +16,7 @@ namespace PixiEditor.Models.Layers
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Generates bitmap ready to work with
+        ///     Generates bitmap ready to work with
         /// </summary>
         /// </summary>
         /// <param name="bitmapWidth">Width of bitmap.</param>
         /// <param name="bitmapWidth">Width of bitmap.</param>
         /// <param name="imageHeight">Height of bitmap.</param>
         /// <param name="imageHeight">Height of bitmap.</param>
@@ -27,6 +27,5 @@ namespace PixiEditor.Models.Layers
             bitmap.Clear(System.Windows.Media.Colors.Transparent);
             bitmap.Clear(System.Windows.Media.Colors.Transparent);
             return bitmap;
             return bitmap;
         }
         }
-
     }
     }
-}
+}

+ 9 - 11
PixiEditor/Models/Layers/SerializableLayer.cs

@@ -1,19 +1,11 @@
-using PixiEditor.Models.Layers;
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System;
+using PixiEditor.Models.Layers;
 
 
 namespace PixiEditor.Models.DataHolders
 namespace PixiEditor.Models.DataHolders
 {
 {
     [Serializable]
     [Serializable]
     public class SerializableLayer
     public class SerializableLayer
     {
     {
-        public string Name { get; set; }
-        public int Width { get; set; }
-        public int Height { get; set; }
-        public byte[] BitmapBytes { get; set; }
-        public bool IsVisible { get; set; }
-
         public SerializableLayer(Layer layer)
         public SerializableLayer(Layer layer)
         {
         {
             Name = layer.Name;
             Name = layer.Name;
@@ -22,5 +14,11 @@ namespace PixiEditor.Models.DataHolders
             BitmapBytes = layer.ConvertBitmapToBytes();
             BitmapBytes = layer.ConvertBitmapToBytes();
             IsVisible = layer.IsVisible;
             IsVisible = layer.IsVisible;
         }
         }
+
+        public string Name { get; set; }
+        public int Width { get; set; }
+        public int Height { get; set; }
+        public byte[] BitmapBytes { get; set; }
+        public bool IsVisible { get; set; }
     }
     }
-}
+}

+ 8 - 8
PixiEditor/Models/Position/Coordinates.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-
-namespace PixiEditor.Models.Position
+namespace PixiEditor.Models.Position
 {
 {
     public struct Coordinates
     public struct Coordinates
     {
     {
@@ -15,7 +12,10 @@ namespace PixiEditor.Models.Position
             Y = y;
             Y = y;
         }
         }
 
 
-        public override string ToString() => $"x: {X}, y: {Y}";
+        public override string ToString()
+        {
+            return $"x: {X}, y: {Y}";
+        }
 
 
         public static bool operator ==(Coordinates c1, Coordinates c2)
         public static bool operator ==(Coordinates c1, Coordinates c2)
         {
         {
@@ -31,14 +31,14 @@ namespace PixiEditor.Models.Position
         public override bool Equals(object obj)
         public override bool Equals(object obj)
         {
         {
             if (obj.GetType() != typeof(Coordinates)) return false;
             if (obj.GetType() != typeof(Coordinates)) return false;
-            return this == (Coordinates)obj;
+            return this == (Coordinates) obj;
         }
         }
 
 
         public override int GetHashCode()
         public override int GetHashCode()
         {
         {
             unchecked
             unchecked
             {
             {
-                const int HashingBase = (int)2166136261;
+                const int HashingBase = (int) 2166136261;
                 const int HashingMultiplier = 16777619;
                 const int HashingMultiplier = 16777619;
 
 
                 int hash = HashingBase;
                 int hash = HashingBase;
@@ -48,4 +48,4 @@ namespace PixiEditor.Models.Position
             }
             }
         }
         }
     }
     }
-}
+}

+ 106 - 118
PixiEditor/Models/Position/CoordinatesCalculator.cs

@@ -1,168 +1,153 @@
-using PixiEditor.Models.DataHolders;
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Security.Cryptography.X509Certificates;
+using System;
+using System.Collections.Generic;
+using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Models.DataHolders;
+
+namespace PixiEditor.Models.Position
+{
+    public static class CoordinatesCalculator
+    {
+        /// <summary>
+        ///     Calculates center of thickness * thickness rectangle
+        /// </summary>
+        /// <param name="startPosition">Top left position of rectangle</param>
+        /// <param name="thickness">Thickness of rectangle</param>
+        /// <returns></returns>
+        public static DoubleCords CalculateThicknessCenter(Coordinates startPosition, int thickness)
+        {
+            int x1, x2, y1, y2;
+            if (thickness % 2 == 0)
+            {
+                x2 = startPosition.X + thickness / 2;
+                y2 = startPosition.Y + thickness / 2;
+                x1 = x2 - thickness;
+                y1 = y2 - thickness;
+            }
+            else
+            {
+                x2 = startPosition.X + (thickness - 1) / 2 + 1;
+                y2 = startPosition.Y + (thickness - 1) / 2 + 1;
+                x1 = x2 - thickness;
+                y1 = y2 - thickness;
+            }
+
+            return new DoubleCords(new Coordinates(x1, y1), new Coordinates(x2 - 1, y2 - 1));
+        }
 
 
-namespace PixiEditor.Models.Position
-{
-    public static class CoordinatesCalculator
-    {
-        /// <summary>
-        /// Calculates center of thickness * thickness rectangle
-        /// </summary>
-        /// <param name="startPosition">Top left position of rectangle</param>
-        /// <param name="thickness">Thickness of rectangle</param>
-        /// <returns></returns>
-        public static DoubleCords CalculateThicknessCenter(Coordinates startPosition, int thickness)
-        {
-            int x1, x2, y1, y2;
-            if (thickness % 2 == 0)
-            {
-                x2 = startPosition.X + thickness / 2;
-                y2 = startPosition.Y + thickness / 2;
-                x1 = x2 - thickness;
-                y1 = y2 - thickness;
-            }
-            else
-            {
-                x2 = startPosition.X + (thickness - 1) / 2 + 1;
-                y2 = startPosition.Y + (thickness - 1) / 2 + 1;
-                x1 = x2 - thickness;
-                y1 = y2 - thickness;
-            }
-            return new DoubleCords(new Coordinates(x1, y1), new Coordinates(x2 - 1, y2 - 1));
-        }
-
         public static Coordinates GetCenterPoint(Coordinates startingPoint, Coordinates endPoint)
         public static Coordinates GetCenterPoint(Coordinates startingPoint, Coordinates endPoint)
         {
         {
-            int x = (int)Math.Floor((startingPoint.X + endPoint.X) / 2f);
-            int y = (int)Math.Floor((startingPoint.Y + endPoint.Y) / 2f);
+            int x = (int) Math.Floor((startingPoint.X + endPoint.X) / 2f);
+            int y = (int) Math.Floor((startingPoint.Y + endPoint.Y) / 2f);
             return new Coordinates(x, y);
             return new Coordinates(x, y);
-        }
-
-        public static Coordinates[] RectangleToCoordinates(int x1, int y1, int x2, int y2)
-        {
-            x2++;
-            y2++;
-            List<Coordinates> coordinates = new List<Coordinates>();
-            for (int y = y1; y < y1 + (y2 - y1); y++)
-            {
-                for (int x = x1; x < x1 + (x2 - x1); x++)
-                {
-                    coordinates.Add(new Coordinates(x, y));
-                }
-            }
-            return coordinates.ToArray();
-        }
-
-        public static Coordinates[] RectangleToCoordinates(DoubleCords coordinates)
-        {
-            return RectangleToCoordinates(coordinates.Coords1.X, coordinates.Coords1.Y, coordinates.Coords2.X, coordinates.Coords2.Y);
-        }
-
+        }
+
+        public static Coordinates[] RectangleToCoordinates(int x1, int y1, int x2, int y2)
+        {
+            x2++;
+            y2++;
+            List<Coordinates> coordinates = new List<Coordinates>();
+            for (int y = y1; y < y1 + (y2 - y1); y++)
+            for (int x = x1; x < x1 + (x2 - x1); x++)
+                coordinates.Add(new Coordinates(x, y));
+            return coordinates.ToArray();
+        }
+
+        public static Coordinates[] RectangleToCoordinates(DoubleCords coordinates)
+        {
+            return RectangleToCoordinates(coordinates.Coords1.X, coordinates.Coords1.Y, coordinates.Coords2.X,
+                coordinates.Coords2.Y);
+        }
+
         /// <summary>
         /// <summary>
-        /// Returns first pixel coordinates in bitmap that is most top left on canvas
+        ///     Returns first pixel coordinates in bitmap that is most top left on canvas
         /// </summary>
         /// </summary>
         /// <param name="bitmap"></param>
         /// <param name="bitmap"></param>
-        /// <returns></returns>
+        /// <returns></returns>
         public static Coordinates FindMinEdgeNonTransparentPixel(WriteableBitmap bitmap)
         public static Coordinates FindMinEdgeNonTransparentPixel(WriteableBitmap bitmap)
         {
         {
             return new Coordinates(FindMinXNonTransparent(bitmap), FindMinYNonTransparent(bitmap));
             return new Coordinates(FindMinXNonTransparent(bitmap), FindMinYNonTransparent(bitmap));
-        }
-
+        }
+
         /// <summary>
         /// <summary>
-        /// Returns last pixel coordinates that is most bottom right
+        ///     Returns last pixel coordinates that is most bottom right
         /// </summary>
         /// </summary>
         /// <param name="bitmap"></param>
         /// <param name="bitmap"></param>
-        /// <returns></returns>
+        /// <returns></returns>
         public static Coordinates FindMostEdgeNonTransparentPixel(WriteableBitmap bitmap)
         public static Coordinates FindMostEdgeNonTransparentPixel(WriteableBitmap bitmap)
         {
         {
             return new Coordinates(FindMaxXNonTransparent(bitmap), FindMaxYNonTransparent(bitmap));
             return new Coordinates(FindMaxXNonTransparent(bitmap), FindMaxYNonTransparent(bitmap));
-        }
-
+        }
+
         public static int FindMinYNonTransparent(WriteableBitmap bitmap)
         public static int FindMinYNonTransparent(WriteableBitmap bitmap)
         {
         {
-            System.Windows.Media.Color transparent = System.Windows.Media.Color.FromArgb(0, 0, 0, 0);
+            Color transparent = Color.FromArgb(0, 0, 0, 0);
             bitmap.Lock();
             bitmap.Lock();
             for (int y = 0; y < bitmap.Height; y++)
             for (int y = 0; y < bitmap.Height; y++)
-            {
-                for (int x = 0; x < bitmap.Width; x++)
+            for (int x = 0; x < bitmap.Width; x++)
+                if (bitmap.GetPixel(x, y) != transparent)
                 {
                 {
-                    if (bitmap.GetPixel(x, y) != transparent)
-                    {
-                        bitmap.Unlock();
-                        return y;
-                    }
+                    bitmap.Unlock();
+                    return y;
                 }
                 }
-            }
+
             bitmap.Unlock();
             bitmap.Unlock();
             return -1;
             return -1;
-        }
-
+        }
+
         public static int FindMinXNonTransparent(WriteableBitmap bitmap)
         public static int FindMinXNonTransparent(WriteableBitmap bitmap)
         {
         {
-            System.Windows.Media.Color transparent = System.Windows.Media.Color.FromArgb(0, 0, 0, 0);
+            Color transparent = Color.FromArgb(0, 0, 0, 0);
             bitmap.Lock();
             bitmap.Lock();
             for (int x = 0; x < bitmap.Width; x++)
             for (int x = 0; x < bitmap.Width; x++)
-            {
-                for (int y = 0; y < bitmap.Height; y++)
+            for (int y = 0; y < bitmap.Height; y++)
+                if (bitmap.GetPixel(x, y) != transparent)
                 {
                 {
-                    if (bitmap.GetPixel(x, y) != transparent)
-                    {
-                        bitmap.Unlock();
-                        return x;
-                    }
+                    bitmap.Unlock();
+                    return x;
                 }
                 }
-            }
+
             bitmap.Unlock();
             bitmap.Unlock();
             return -1;
             return -1;
-        }
-
+        }
+
         public static int FindMaxYNonTransparent(WriteableBitmap bitmap)
         public static int FindMaxYNonTransparent(WriteableBitmap bitmap)
         {
         {
-            System.Windows.Media.Color transparent = System.Windows.Media.Color.FromArgb(0, 0, 0, 0);
+            Color transparent = Color.FromArgb(0, 0, 0, 0);
             bitmap.Lock();
             bitmap.Lock();
-            for (int y = (int)bitmap.Height - 1; y >= 0; y--)
-            {
-                for (int x = (int)bitmap.Width - 1; x >= 0; x--)
+            for (int y = (int) bitmap.Height - 1; y >= 0; y--)
+            for (int x = (int) bitmap.Width - 1; x >= 0; x--)
+                if (bitmap.GetPixel(x, y) != transparent)
                 {
                 {
-                    if (bitmap.GetPixel(x, y) != transparent)
-                    {
-                        bitmap.Unlock();
-                        return y;
-                    }
+                    bitmap.Unlock();
+                    return y;
                 }
                 }
-            }
+
             bitmap.Unlock();
             bitmap.Unlock();
             return -1;
             return -1;
-        }
-
+        }
+
         public static int FindMaxXNonTransparent(WriteableBitmap bitmap)
         public static int FindMaxXNonTransparent(WriteableBitmap bitmap)
         {
         {
-            System.Windows.Media.Color transparent = System.Windows.Media.Color.FromArgb(0, 0, 0, 0);
+            Color transparent = Color.FromArgb(0, 0, 0, 0);
             bitmap.Lock();
             bitmap.Lock();
-            for (int x = (int)bitmap.Width - 1; x >= 0; x--)
-            {
-                for (int y = (int)bitmap.Height - 1; y >= 0; y--)
+            for (int x = (int) bitmap.Width - 1; x >= 0; x--)
+            for (int y = (int) bitmap.Height - 1; y >= 0; y--)
+                if (bitmap.GetPixel(x, y) != transparent)
                 {
                 {
-                    if (bitmap.GetPixel(x, y) != transparent)
-                    {
-                        bitmap.Unlock();
-                        return x;
-                    }
+                    bitmap.Unlock();
+                    return x;
                 }
                 }
-            }
+
             bitmap.Unlock();
             bitmap.Unlock();
             return -1;
             return -1;
-        }
-
+        }
+
         /// <summary>
         /// <summary>
-        /// Finds most top-left pixel on each layer.
+        ///     Finds most top-left pixel on each layer.
         /// </summary>
         /// </summary>
         /// <param name="document"></param>
         /// <param name="document"></param>
-        /// <returns>Most top-left pixel in each layer</returns>
+        /// <returns>Most top-left pixel in each layer</returns>
         public static Coordinates[] GetSmallestPixels(Document document)
         public static Coordinates[] GetSmallestPixels(Document document)
         {
         {
             Coordinates[] smallestPixels = new Coordinates[document.Layers.Count];
             Coordinates[] smallestPixels = new Coordinates[document.Layers.Count];
@@ -172,10 +157,12 @@ namespace PixiEditor.Models.Position
                 if (point.X >= 0 && point.Y >= 0)
                 if (point.X >= 0 && point.Y >= 0)
                     smallestPixels[i] = point;
                     smallestPixels[i] = point;
             }
             }
+
             return smallestPixels;
             return smallestPixels;
         }
         }
+
         /// <summary>
         /// <summary>
-        /// Finds most bottom-right pixel on each layer.
+        ///     Finds most bottom-right pixel on each layer.
         /// </summary>
         /// </summary>
         /// <param name="document"></param>
         /// <param name="document"></param>
         /// <returns>Most bottom-right pixel in each layer</returns>
         /// <returns>Most bottom-right pixel in each layer</returns>
@@ -188,7 +175,8 @@ namespace PixiEditor.Models.Position
                 if (point.X >= 0 && point.Y >= 0)
                 if (point.X >= 0 && point.Y >= 0)
                     biggestPixels[i] = point;
                     biggestPixels[i] = point;
             }
             }
+
             return biggestPixels;
             return biggestPixels;
-        }
-    }
+        }
+    }
 }
 }

+ 1 - 1
PixiEditor/Models/Position/DoubleCords.cs

@@ -11,4 +11,4 @@
             Coords2 = cords2;
             Coords2 = cords2;
         }
         }
     }
     }
-}
+}

+ 12 - 12
PixiEditor/Models/Position/MousePositionConverter.cs

@@ -1,6 +1,6 @@
-using PixiEditor.Models.Layers;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
 using System.Windows;
 using System.Windows;
+using PixiEditor.Models.Layers;
 
 
 namespace PixiEditor.Models.Position
 namespace PixiEditor.Models.Position
 {
 {
@@ -10,19 +10,19 @@ namespace PixiEditor.Models.Position
 
 
         public static Coordinates MousePositionToCoordinates(Layer baseLayer, Point mousePosition)
         public static Coordinates MousePositionToCoordinates(Layer baseLayer, Point mousePosition)
         {
         {
-            int xCoord = (int)(mousePosition.X / baseLayer.Width);
-            int yCoord = (int)(mousePosition.Y / baseLayer.Height);
+            int xCoord = (int) (mousePosition.X / baseLayer.Width);
+            int yCoord = (int) (mousePosition.Y / baseLayer.Height);
             return new Coordinates(xCoord, yCoord);
             return new Coordinates(xCoord, yCoord);
         }
         }
 
 
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        private static extern bool GetCursorPos(out System.Drawing.Point point);
-
-        public static System.Drawing.Point GetCursorPosition()
-        {
-            System.Drawing.Point point;
-            GetCursorPos(out point);
-            return point;
+        private static extern bool GetCursorPos(out System.Drawing.Point point);
+
+        public static System.Drawing.Point GetCursorPosition()
+        {
+            System.Drawing.Point point;
+            GetCursorPos(out point);
+            return point;
         }
         }
     }
     }
-}
+}

+ 4 - 5
PixiEditor/Models/Tools/BitmapOperationTool.cs

@@ -1,15 +1,14 @@
-using PixiEditor.Models.DataHolders;
+using System.Windows.Media;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
-using System.Windows.Media;
 
 
 namespace PixiEditor.Models.Tools
 namespace PixiEditor.Models.Tools
 {
 {
     public abstract class BitmapOperationTool : Tool
     public abstract class BitmapOperationTool : Tool
     {
     {
-        public abstract LayerChange[] Use(Layer layer, Coordinates[] mouseMove, Color color);
         public bool RequiresPreviewLayer { get; set; }
         public bool RequiresPreviewLayer { get; set; }
         public bool UseDefaultUndoMethod { get; set; } = true;
         public bool UseDefaultUndoMethod { get; set; } = true;
-
+        public abstract LayerChange[] Use(Layer layer, Coordinates[] mouseMove, Color color);
     }
     }
-}
+}

+ 13 - 24
PixiEditor/Models/Tools/BitmapPixelChanges.cs

@@ -1,10 +1,10 @@
-using PixiEditor.Exceptions;
-using PixiEditor.Helpers.Extensions;
-using PixiEditor.Models.Position;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Windows.Media;
 using System.Windows.Media;
+using PixiEditor.Exceptions;
+using PixiEditor.Helpers.Extensions;
+using PixiEditor.Models.Position;
 
 
 namespace PixiEditor.Models.Tools
 namespace PixiEditor.Models.Tools
 {
 {
@@ -17,8 +17,9 @@ namespace PixiEditor.Models.Tools
         {
         {
             ChangedPixels = changedPixels;
             ChangedPixels = changedPixels;
         }
         }
+
         /// <summary>
         /// <summary>
-        /// Builds BitmapPixelChanges with only one color for specified coordinates
+        ///     Builds BitmapPixelChanges with only one color for specified coordinates
         /// </summary>
         /// </summary>
         /// <param name="coordinates"></param>
         /// <param name="coordinates"></param>
         /// <param name="color"></param>
         /// <param name="color"></param>
@@ -26,15 +27,12 @@ namespace PixiEditor.Models.Tools
         public static BitmapPixelChanges FromSingleColoredArray(Coordinates[] coordinates, Color color)
         public static BitmapPixelChanges FromSingleColoredArray(Coordinates[] coordinates, Color color)
         {
         {
             Dictionary<Coordinates, Color> dict = new Dictionary<Coordinates, Color>();
             Dictionary<Coordinates, Color> dict = new Dictionary<Coordinates, Color>();
-            for (int i = 0; i < coordinates.Length; i++)
-            {
-                dict.Add(coordinates[i], color);
-            }
+            for (int i = 0; i < coordinates.Length; i++) dict.Add(coordinates[i], color);
             return new BitmapPixelChanges(dict);
             return new BitmapPixelChanges(dict);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Combines pixel changes array with overriding values.
+        ///     Combines pixel changes array with overriding values.
         /// </summary>
         /// </summary>
         /// <param name="changes">BitmapPixelChanges to combine</param>
         /// <param name="changes">BitmapPixelChanges to combine</param>
         /// <returns>Combined BitmapPixelChanges</returns>
         /// <returns>Combined BitmapPixelChanges</returns>
@@ -43,15 +41,12 @@ namespace PixiEditor.Models.Tools
             if (changes == null || changes.Length == 0) throw new ArgumentException();
             if (changes == null || changes.Length == 0) throw new ArgumentException();
             BitmapPixelChanges output = Empty;
             BitmapPixelChanges output = Empty;
 
 
-            for (int i = 0; i < changes.Length; i++)
-            {
-                output.ChangedPixels.AddRangeOverride(changes[i].ChangedPixels);
-            }
+            for (int i = 0; i < changes.Length; i++) output.ChangedPixels.AddRangeOverride(changes[i].ChangedPixels);
             return output;
             return output;
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Builds BitmapPixelChanges using 2 same-length enumerables of coordinates and colors
+        ///     Builds BitmapPixelChanges using 2 same-length enumerables of coordinates and colors
         /// </summary>
         /// </summary>
         /// <param name="coordinates"></param>
         /// <param name="coordinates"></param>
         /// <param name="color"></param>
         /// <param name="color"></param>
@@ -60,16 +55,10 @@ namespace PixiEditor.Models.Tools
         {
         {
             var coordinateArray = coordinates.ToArray();
             var coordinateArray = coordinates.ToArray();
             var colorArray = color.ToArray();
             var colorArray = color.ToArray();
-            if (coordinateArray.Length != colorArray.Length)
-            {
-                throw new ArrayLengthMismatchException();
-            }
+            if (coordinateArray.Length != colorArray.Length) throw new ArrayLengthMismatchException();
             Dictionary<Coordinates, Color> dict = new Dictionary<Coordinates, Color>();
             Dictionary<Coordinates, Color> dict = new Dictionary<Coordinates, Color>();
-            for (int i = 0; i < coordinateArray.Length; i++)
-            {
-                dict.Add(coordinateArray[i], colorArray[i]);
-            }
+            for (int i = 0; i < coordinateArray.Length; i++) dict.Add(coordinateArray[i], colorArray[i]);
             return new BitmapPixelChanges(dict);
             return new BitmapPixelChanges(dict);
         }
         }
     }
     }
-}
+}

+ 1 - 1
PixiEditor/Models/Tools/ReadonlyTool.cs

@@ -6,4 +6,4 @@ namespace PixiEditor.Models.Tools
     {
     {
         public abstract void Use(Coordinates[] pixels);
         public abstract void Use(Coordinates[] pixels);
     }
     }
-}
+}

+ 38 - 44
PixiEditor/Models/Tools/ShapeTool.cs

@@ -1,62 +1,56 @@
-using PixiEditor.Models.DataHolders;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Input;
+using System.Windows.Media;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
-using PixiEditor.Models.Tools.ToolSettings;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Input;
-using System.Windows.Media;
+using PixiEditor.Models.Tools.ToolSettings;
 
 
 namespace PixiEditor.Models.Tools
 namespace PixiEditor.Models.Tools
 {
 {
     public abstract class ShapeTool : BitmapOperationTool
     public abstract class ShapeTool : BitmapOperationTool
     {
     {
-        public override abstract ToolType ToolType { get; }
+        public ShapeTool()
+        {
+            RequiresPreviewLayer = true;
+            Cursor = Cursors.Cross;
+            Toolbar = new BasicShapeToolbar();
+        }
+
+        public abstract override ToolType ToolType { get; }
 
 
         public abstract override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color);
         public abstract override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color);
 
 
-        public ShapeTool()
-        {
-            RequiresPreviewLayer = true;
-            Cursor = Cursors.Cross;
-            Toolbar = new BasicShapeToolbar();
+        protected Coordinates[] GetThickShape(Coordinates[] shape, int thickness)
+        {
+            List<Coordinates> output = new List<Coordinates>();
+            for (int i = 0; i < shape.Length; i++)
+                output.AddRange(
+                    CoordinatesCalculator.RectangleToCoordinates(
+                        CoordinatesCalculator.CalculateThicknessCenter(shape[i], thickness)));
+            return output.Distinct().ToArray();
         }
         }
 
 
-        protected Coordinates[] GetThickShape(Coordinates[] shape, int thickness)
-        {
-            List<Coordinates> output = new List<Coordinates>();
-            for (int i = 0; i < shape.Length; i++)
-            {
-                output.AddRange(CoordinatesCalculator.RectangleToCoordinates(CoordinatesCalculator.CalculateThicknessCenter(shape[i], thickness)));
-            }
-            return output.Distinct().ToArray();
-        }
-
-
-        protected DoubleCords CalculateCoordinatesForShapeRotation(Coordinates startingCords, Coordinates secondCoordinates)
+
+        protected DoubleCords CalculateCoordinatesForShapeRotation(Coordinates startingCords,
+            Coordinates secondCoordinates)
         {
         {
             Coordinates currentCoordinates = secondCoordinates;
             Coordinates currentCoordinates = secondCoordinates;
 
 
             if (startingCords.X > currentCoordinates.X && startingCords.Y > currentCoordinates.Y)
             if (startingCords.X > currentCoordinates.X && startingCords.Y > currentCoordinates.Y)
-            {
-                return new DoubleCords(new Coordinates(currentCoordinates.X, currentCoordinates.Y), new Coordinates(startingCords.X, startingCords.Y));
-            }
-            else if (startingCords.X < currentCoordinates.X && startingCords.Y < currentCoordinates.Y)
-            {
-                return new DoubleCords(new Coordinates(startingCords.X, startingCords.Y), new Coordinates(currentCoordinates.X, currentCoordinates.Y));
-            }
-            else if (startingCords.Y > currentCoordinates.Y)
-            {
-                return new DoubleCords(new Coordinates(startingCords.X, currentCoordinates.Y), new Coordinates(currentCoordinates.X, startingCords.Y));
-            }
-            else if (startingCords.X > currentCoordinates.X && startingCords.Y <= currentCoordinates.Y)
-            {
-                return new DoubleCords(new Coordinates(currentCoordinates.X, startingCords.Y), new Coordinates(startingCords.X, currentCoordinates.Y));
-            }
-            else
-            {
-                return new DoubleCords(startingCords, secondCoordinates);
-            }
+                return new DoubleCords(new Coordinates(currentCoordinates.X, currentCoordinates.Y),
+                    new Coordinates(startingCords.X, startingCords.Y));
+            if (startingCords.X < currentCoordinates.X && startingCords.Y < currentCoordinates.Y)
+                return new DoubleCords(new Coordinates(startingCords.X, startingCords.Y),
+                    new Coordinates(currentCoordinates.X, currentCoordinates.Y));
+            if (startingCords.Y > currentCoordinates.Y)
+                return new DoubleCords(new Coordinates(startingCords.X, currentCoordinates.Y),
+                    new Coordinates(currentCoordinates.X, startingCords.Y));
+            if (startingCords.X > currentCoordinates.X && startingCords.Y <= currentCoordinates.Y)
+                return new DoubleCords(new Coordinates(currentCoordinates.X, startingCords.Y),
+                    new Coordinates(startingCords.X, currentCoordinates.Y));
+            return new DoubleCords(startingCords, secondCoordinates);
         }
         }
     }
     }
-}
+}

+ 28 - 19
PixiEditor/Models/Tools/Tool.cs

@@ -1,31 +1,40 @@
-using PixiEditor.Helpers;
-using PixiEditor.Models.Tools.ToolSettings;
-using System.Windows.Input;
+using System.Windows.Input;
+using PixiEditor.Helpers;
+using PixiEditor.Models.Tools.ToolSettings;
 
 
 namespace PixiEditor.Models.Tools
 namespace PixiEditor.Models.Tools
 {
 {
     public abstract class Tool : NotifyableObject
     public abstract class Tool : NotifyableObject
-    {
+    {
+        private bool _isActive;
         public abstract ToolType ToolType { get; }
         public abstract ToolType ToolType { get; }
         public string ImagePath => $"/Images/{ToolType}Image.png";
         public string ImagePath => $"/Images/{ToolType}Image.png";
-        public virtual void OnMouseDown() { }
-        public virtual void OnMouseUp() { }
-        public virtual void AfterAddedUndo() { }
         public bool HideHighlight { get; set; } = false;
         public bool HideHighlight { get; set; } = false;
         public string Tooltip { get; set; }
         public string Tooltip { get; set; }
 
 
-        private bool _isActive = false;
-        public bool IsActive
-        {
-            get { return _isActive; }
-            set
-            {
-                _isActive = value;
-                RaisePropertyChanged("IsActive");
-            }
-        }
-
+        public bool IsActive
+        {
+            get => _isActive;
+            set
+            {
+                _isActive = value;
+                RaisePropertyChanged("IsActive");
+            }
+        }
+
         public Cursor Cursor { get; set; } = Cursors.Arrow;
         public Cursor Cursor { get; set; } = Cursors.Arrow;
         public Toolbar Toolbar { get; set; } = new EmptyToolbar();
         public Toolbar Toolbar { get; set; } = new EmptyToolbar();
+
+        public virtual void OnMouseDown()
+        {
+        }
+
+        public virtual void OnMouseUp()
+        {
+        }
+
+        public virtual void AfterAddedUndo()
+        {
+        }
     }
     }
-}
+}

+ 8 - 6
PixiEditor/Models/Tools/ToolSettings/Settings/BoolSetting.cs

@@ -1,4 +1,6 @@
-using System.Windows.Controls;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using System.Windows.Data;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
@@ -21,10 +23,10 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
 
 
         private Control GenerateCheckBox()
         private Control GenerateCheckBox()
         {
         {
-            CheckBox checkBox = new CheckBox()
+            CheckBox checkBox = new CheckBox
             {
             {
-                IsChecked = (bool)Value,
-                VerticalAlignment = System.Windows.VerticalAlignment.Center
+                IsChecked = (bool) Value,
+                VerticalAlignment = VerticalAlignment.Center
             };
             };
 
 
             Binding binding = new Binding("Value")
             Binding binding = new Binding("Value")
@@ -32,9 +34,9 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
                 Mode = BindingMode.TwoWay
                 Mode = BindingMode.TwoWay
             };
             };
 
 
-            checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
+            checkBox.SetBinding(ToggleButton.IsCheckedProperty, binding);
 
 
             return checkBox;
             return checkBox;
         }
         }
     }
     }
-}
+}

+ 4 - 4
PixiEditor/Models/Tools/ToolSettings/Settings/ColorSetting.cs

@@ -1,6 +1,6 @@
-using PixiEditor.Views;
-using System.Windows.Data;
+using System.Windows.Data;
 using System.Windows.Media;
 using System.Windows.Media;
+using PixiEditor.Views;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 {
 {
@@ -18,10 +18,10 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
             PortableColorPicker picker = new PortableColorPicker();
             PortableColorPicker picker = new PortableColorPicker();
             Binding binding = new Binding("Value")
             Binding binding = new Binding("Value")
             {
             {
-                Mode = BindingMode.TwoWay,
+                Mode = BindingMode.TwoWay
             };
             };
             picker.SetBinding(PortableColorPicker.SelectedColorProperty, binding);
             picker.SetBinding(PortableColorPicker.SelectedColorProperty, binding);
             return picker;
             return picker;
         }
         }
     }
     }
-}
+}

+ 8 - 11
PixiEditor/Models/Tools/ToolSettings/Settings/DropdownSetting.cs

@@ -1,28 +1,26 @@
-using PixiEditor.Helpers;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using System.Windows.Data;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 {
 {
     public class DropdownSetting : Setting
     public class DropdownSetting : Setting
     {
     {
-        public string[] Values { get; set; }
         public DropdownSetting(string name, string[] values, string label) : base(name)
         public DropdownSetting(string name, string[] values, string label) : base(name)
         {
         {
             Values = values;
             Values = values;
             SettingControl = GenerateDropdown();
             SettingControl = GenerateDropdown();
-            Value = ((ComboBox)SettingControl).Items[0];
+            Value = ((ComboBox) SettingControl).Items[0];
             Label = label;
             Label = label;
         }
         }
 
 
+        public string[] Values { get; set; }
+
 
 
         private ComboBox GenerateDropdown()
         private ComboBox GenerateDropdown()
         {
         {
-            ComboBox combobox = new ComboBox()
+            ComboBox combobox = new ComboBox
             {
             {
                 VerticalAlignment = VerticalAlignment.Center
                 VerticalAlignment = VerticalAlignment.Center
             };
             };
@@ -32,7 +30,7 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
             {
             {
                 Mode = BindingMode.TwoWay
                 Mode = BindingMode.TwoWay
             };
             };
-            combobox.SetBinding(ComboBox.SelectedValueProperty, binding);
+            combobox.SetBinding(Selector.SelectedValueProperty, binding);
             return combobox;
             return combobox;
         }
         }
 
 
@@ -47,6 +45,5 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
                 comboBox.Items.Add(item);
                 comboBox.Items.Add(item);
             }
             }
         }
         }
-
     }
     }
-}
+}

+ 9 - 10
PixiEditor/Models/Tools/ToolSettings/Settings/FloatSetting.cs

@@ -1,13 +1,10 @@
-using PixiEditor.Views;
-using System.Windows.Data;
+using System.Windows.Data;
+using PixiEditor.Views;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 {
 {
     public class FloatSetting : Setting
     public class FloatSetting : Setting
     {
     {
-        public float Min { get; set; }
-        public float Max { get; set; }
-
         public FloatSetting(string name, float initialValue, string label = "",
         public FloatSetting(string name, float initialValue, string label = "",
             float min = float.NegativeInfinity, float max = float.PositiveInfinity) : base(name)
             float min = float.NegativeInfinity, float max = float.PositiveInfinity) : base(name)
         {
         {
@@ -18,22 +15,24 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
             SettingControl = GenerateNumberInput();
             SettingControl = GenerateNumberInput();
         }
         }
 
 
+        public float Min { get; set; }
+        public float Max { get; set; }
+
         private NumberInput GenerateNumberInput()
         private NumberInput GenerateNumberInput()
         {
         {
-            NumberInput numbrInput = new NumberInput()
+            NumberInput numbrInput = new NumberInput
             {
             {
                 Width = 40,
                 Width = 40,
                 Height = 20,
                 Height = 20,
                 Min = Min,
                 Min = Min,
-                Max = Max,
-
+                Max = Max
             };
             };
             Binding binding = new Binding("Value")
             Binding binding = new Binding("Value")
             {
             {
-                Mode = BindingMode.TwoWay,
+                Mode = BindingMode.TwoWay
             };
             };
             numbrInput.SetBinding(NumberInput.ValueProperty, binding);
             numbrInput.SetBinding(NumberInput.ValueProperty, binding);
             return numbrInput;
             return numbrInput;
         }
         }
     }
     }
-}
+}

+ 12 - 9
PixiEditor/Models/Tools/ToolSettings/Settings/Setting.cs

@@ -1,14 +1,21 @@
-using PixiEditor.Helpers;
-using System.Windows.Controls;
+using System.Windows.Controls;
+using PixiEditor.Helpers;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings
 namespace PixiEditor.Models.Tools.ToolSettings
 {
 {
     public abstract class Setting : NotifyableObject
     public abstract class Setting : NotifyableObject
     {
     {
+        private object value;
+
+        public Setting(string name)
+        {
+            Name = name;
+        }
+
         public string Name { get; protected set; }
         public string Name { get; protected set; }
         public string Label { get; set; }
         public string Label { get; set; }
         public bool HasLabel => !string.IsNullOrEmpty(Label);
         public bool HasLabel => !string.IsNullOrEmpty(Label);
-        private object value;
+
         public object Value
         public object Value
         {
         {
             get => value;
             get => value;
@@ -18,11 +25,7 @@ namespace PixiEditor.Models.Tools.ToolSettings
                 RaisePropertyChanged("Value");
                 RaisePropertyChanged("Value");
             }
             }
         }
         }
-        public Control SettingControl { get; set; }
 
 
-        public Setting(string name)
-        {
-            Name = name;
-        }
+        public Control SettingControl { get; set; }
     }
     }
-}
+}

+ 6 - 6
PixiEditor/Models/Tools/ToolSettings/Settings/SizeSetting.cs

@@ -1,9 +1,9 @@
-using PixiEditor.Helpers;
-using PixiEditor.Helpers.Behaviours;
-using System.Windows;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Data;
 using System.Windows.Interactivity;
 using System.Windows.Interactivity;
+using PixiEditor.Helpers;
+using PixiEditor.Helpers.Behaviours;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 namespace PixiEditor.Models.Tools.ToolSettings.Settings
 {
 {
@@ -18,7 +18,7 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
 
 
         private TextBox GenerateTextBox()
         private TextBox GenerateTextBox()
         {
         {
-            TextBox tb = new TextBox()
+            TextBox tb = new TextBox
             {
             {
                 Style = Application.Current.FindResource("DarkTextBoxStyle") as Style,
                 Style = Application.Current.FindResource("DarkTextBoxStyle") as Style,
                 TextAlignment = TextAlignment.Center,
                 TextAlignment = TextAlignment.Center,
@@ -29,7 +29,7 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
             Binding binding = new Binding("Value")
             Binding binding = new Binding("Value")
             {
             {
                 Converter = new ToolSizeToIntConverter(),
                 Converter = new ToolSizeToIntConverter(),
-                Mode = BindingMode.TwoWay,
+                Mode = BindingMode.TwoWay
             };
             };
             tb.SetBinding(TextBox.TextProperty, binding);
             tb.SetBinding(TextBox.TextProperty, binding);
             TextBoxFocusBehavior behavor = new TextBoxFocusBehavior
             TextBoxFocusBehavior behavor = new TextBoxFocusBehavior
@@ -40,4 +40,4 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
             return tb;
             return tb;
         }
         }
     }
     }
-}
+}

+ 1 - 1
PixiEditor/Models/Tools/ToolSettings/Toolbars/BasicShapeToolbar.cs

@@ -10,4 +10,4 @@ namespace PixiEditor.Models.Tools.ToolSettings
             Settings.Add(new ColorSetting("FillColor", "Fill color"));
             Settings.Add(new ColorSetting("FillColor", "Fill color"));
         }
         }
     }
     }
-}
+}

+ 1 - 1
PixiEditor/Models/Tools/ToolSettings/Toolbars/BasicToolbar.cs

@@ -9,4 +9,4 @@ namespace PixiEditor.Models.Tools.ToolSettings
             Settings.Add(new SizeSetting("ToolSize", "Tool size:"));
             Settings.Add(new SizeSetting("ToolSize", "Tool size:"));
         }
         }
     }
     }
-}
+}

+ 1 - 1
PixiEditor/Models/Tools/ToolSettings/Toolbars/BrightnessToolToolbar.cs

@@ -9,4 +9,4 @@ namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
             Settings.Add(new FloatSetting("CorrectionFactor", initialValue, "Strength:", 0f, 100f));
             Settings.Add(new FloatSetting("CorrectionFactor", initialValue, "Strength:", 0f, 100f));
         }
         }
     }
     }
-}
+}

+ 1 - 2
PixiEditor/Models/Tools/ToolSettings/Toolbars/EmptyToolbar.cs

@@ -2,6 +2,5 @@
 {
 {
     public class EmptyToolbar : Toolbar
     public class EmptyToolbar : Toolbar
     {
     {
-
     }
     }
-}
+}

+ 2 - 5
PixiEditor/Models/Tools/ToolSettings/Toolbars/SelectToolToolbar.cs

@@ -1,7 +1,4 @@
 using PixiEditor.Models.Tools.ToolSettings.Settings;
 using PixiEditor.Models.Tools.ToolSettings.Settings;
-using System;
-using System.Collections.Generic;
-using System.Text;
 
 
 namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
 namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
 {
 {
@@ -9,7 +6,7 @@ namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
     {
     {
         public SelectToolToolbar()
         public SelectToolToolbar()
         {
         {
-            Settings.Add(new DropdownSetting("Mode", new string[] {"New", "Add", "Substract"}, "Selection type"));
+            Settings.Add(new DropdownSetting("Mode", new[] {"New", "Add", "Substract"}, "Selection type"));
         }
         }
     }
     }
-}
+}

+ 3 - 15
PixiEditor/Models/Tools/ToolSettings/Toolbars/Toolbar.cs

@@ -6,8 +6,8 @@ namespace PixiEditor.Models.Tools.ToolSettings
 {
 {
     public abstract class Toolbar
     public abstract class Toolbar
     {
     {
+        private static readonly List<Setting> _sharedSettings = new List<Setting>();
         public ObservableCollection<Setting> Settings { get; set; } = new ObservableCollection<Setting>();
         public ObservableCollection<Setting> Settings { get; set; } = new ObservableCollection<Setting>();
-        private static List<Setting> _sharedSettings = new List<Setting>();
 
 
         public virtual Setting GetSetting(string name)
         public virtual Setting GetSetting(string name)
         {
         {
@@ -20,34 +20,22 @@ namespace PixiEditor.Models.Tools.ToolSettings
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Saves current toolbar state, so other toolbars with common settings can load them.
+        ///     Saves current toolbar state, so other toolbars with common settings can load them.
         /// </summary>
         /// </summary>
         public void SaveToolbarSettings()
         public void SaveToolbarSettings()
         {
         {
             for (int i = 0; i < Settings.Count; i++)
             for (int i = 0; i < Settings.Count; i++)
-            {
                 if (_sharedSettings.Any(x => x.Name == Settings[i].Name))
                 if (_sharedSettings.Any(x => x.Name == Settings[i].Name))
-                {
                     _sharedSettings.First(x => x.Name == Settings[i].Name).Value = Settings[i].Value;
                     _sharedSettings.First(x => x.Name == Settings[i].Name).Value = Settings[i].Value;
-                }
                 else
                 else
-                {
                     _sharedSettings.Add(Settings[i]);
                     _sharedSettings.Add(Settings[i]);
-                }
-
-
-            }
         }
         }
 
 
         public void LoadSharedSettings()
         public void LoadSharedSettings()
         {
         {
             for (int i = 0; i < _sharedSettings.Count; i++)
             for (int i = 0; i < _sharedSettings.Count; i++)
-            {
                 if (Settings.Any(x => x.Name == _sharedSettings[i].Name))
                 if (Settings.Any(x => x.Name == _sharedSettings[i].Name))
-                {
                     Settings.First(x => x.Name == _sharedSettings[i].Name).Value = _sharedSettings[i].Value;
                     Settings.First(x => x.Name == _sharedSettings[i].Name).Value = _sharedSettings[i].Value;
-                }
-            }
         }
         }
     }
     }
-}
+}

+ 12 - 2
PixiEditor/Models/Tools/ToolType.cs

@@ -2,6 +2,16 @@
 {
 {
     public enum ToolType
     public enum ToolType
     {
     {
-        None, Move, Pen, Select, Bucket, Line, Circle, Rectangle, Earser, Brightness, ColorPicker
+        None,
+        Move,
+        Pen,
+        Select,
+        Bucket,
+        Line,
+        Circle,
+        Rectangle,
+        Earser,
+        Brightness,
+        ColorPicker
     }
     }
-}
+}

+ 36 - 33
PixiEditor/Models/Tools/Tools/BrightnessTool.cs

@@ -1,57 +1,60 @@
-using PixiEditor.Models.Colors;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using PixiEditor.Models.Tools.ToolSettings;
-using PixiEditor.Models.Tools.ToolSettings.Toolbars;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Windows.Input;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Models.Colors;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
+using PixiEditor.Models.Tools.ToolSettings.Toolbars;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
 {
 {
     public class BrightnessTool : BitmapOperationTool
     public class BrightnessTool : BitmapOperationTool
     {
     {
-        public override ToolType ToolType => ToolType.Brightness;
-        private const float CorrectionFactor = 5f; //Initial correction factor
-
-        public BrightnessTool()
-        {
-            Tooltip = "Makes pixel brighter or darker pixel (U)";
-            Toolbar = new BrightnessToolToolbar(CorrectionFactor);
+        private const float CorrectionFactor = 5f; //Initial correction factor
+
+        public BrightnessTool()
+        {
+            Tooltip = "Makes pixel brighter or darker pixel (U)";
+            Toolbar = new BrightnessToolToolbar(CorrectionFactor);
         }
         }
 
 
+        public override ToolType ToolType => ToolType.Brightness;
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
-            int toolSize = (int)Toolbar.GetSetting("ToolSize").Value;
-            float correctionFactor = (float)Toolbar.GetSetting("CorrectionFactor").Value;
+            int toolSize = (int) Toolbar.GetSetting("ToolSize").Value;
+            float correctionFactor = (float) Toolbar.GetSetting("CorrectionFactor").Value;
             LayerChange[] layersChanges = new LayerChange[1];
             LayerChange[] layersChanges = new LayerChange[1];
             if (Keyboard.IsKeyDown(Key.LeftCtrl))
             if (Keyboard.IsKeyDown(Key.LeftCtrl))
-            {
-                layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, -correctionFactor), layer);
-            }
-            else
-            {
-                layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, correctionFactor), layer);
-            }
+                layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, -correctionFactor),
+                    layer);
+            else
+                layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, correctionFactor),
+                    layer);
             return layersChanges;
             return layersChanges;
-        }
-
-        private BitmapPixelChanges ChangeBrightness(Layer layer, Coordinates coordinates, int toolSize, float correctionFactor)
+        }
+
+        private BitmapPixelChanges ChangeBrightness(Layer layer, Coordinates coordinates, int toolSize,
+            float correctionFactor)
         {
         {
             DoubleCords centeredCoords = CoordinatesCalculator.CalculateThicknessCenter(coordinates, toolSize);
             DoubleCords centeredCoords = CoordinatesCalculator.CalculateThicknessCenter(coordinates, toolSize);
-            Coordinates[] rectangleCoordinates = CoordinatesCalculator.RectangleToCoordinates(centeredCoords.Coords1.X, centeredCoords.Coords1.Y,
+            Coordinates[] rectangleCoordinates = CoordinatesCalculator.RectangleToCoordinates(centeredCoords.Coords1.X,
+                centeredCoords.Coords1.Y,
                 centeredCoords.Coords2.X, centeredCoords.Coords2.Y);
                 centeredCoords.Coords2.X, centeredCoords.Coords2.Y);
             BitmapPixelChanges changes = new BitmapPixelChanges(new Dictionary<Coordinates, Color>());
             BitmapPixelChanges changes = new BitmapPixelChanges(new Dictionary<Coordinates, Color>());
 
 
-            for (int i = 0; i < rectangleCoordinates.Length; i++)
-            {
-                Color pixel = layer.LayerBitmap.GetPixel(rectangleCoordinates[i].X, rectangleCoordinates[i].Y);
-                Color newColor = ExColor.ChangeColorBrightness(Color.FromArgb(pixel.A, pixel.R, pixel.G, pixel.B), correctionFactor);
-                changes.ChangedPixels.Add(new Coordinates(rectangleCoordinates[i].X, rectangleCoordinates[i].Y), newColor);
+            for (int i = 0; i < rectangleCoordinates.Length; i++)
+            {
+                Color pixel = layer.LayerBitmap.GetPixel(rectangleCoordinates[i].X, rectangleCoordinates[i].Y);
+                Color newColor = ExColor.ChangeColorBrightness(Color.FromArgb(pixel.A, pixel.R, pixel.G, pixel.B),
+                    correctionFactor);
+                changes.ChangedPixels.Add(new Coordinates(rectangleCoordinates[i].X, rectangleCoordinates[i].Y),
+                    newColor);
             }
             }
+
             return changes;
             return changes;
         }
         }
     }
     }
-}
+}

+ 47 - 53
PixiEditor/Models/Tools/Tools/CircleTool.cs

@@ -1,38 +1,39 @@
-using PixiEditor.Helpers.Extensions;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
-using System.Windows.Media;
-
-namespace PixiEditor.Models.Tools.Tools
-{
-    public class CircleTool : ShapeTool
-    {
-        public override ToolType ToolType => ToolType.Circle;
-
+using System.Windows.Media;
+using PixiEditor.Helpers.Extensions;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
+
+namespace PixiEditor.Models.Tools.Tools
+{
+    public class CircleTool : ShapeTool
+    {
         public CircleTool()
         public CircleTool()
         {
         {
             Tooltip = "Draws circle on cavnas (C)";
             Tooltip = "Draws circle on cavnas (C)";
-        }
-
-        public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
+        }
+
+        public override ToolType ToolType => ToolType.Circle;
+
+        public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
-            int thickness = (int)Toolbar.GetSetting("ToolSize").Value;
+            int thickness = (int) Toolbar.GetSetting("ToolSize").Value;
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
             Coordinates[] outline = CreateEllipse(fixedCoordinates.Coords1, fixedCoordinates.Coords2, thickness);
             Coordinates[] outline = CreateEllipse(fixedCoordinates.Coords1, fixedCoordinates.Coords2, thickness);
             BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(outline, color);
             BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(outline, color);
-            if ((bool)Toolbar.GetSetting("Fill").Value)
+            if ((bool) Toolbar.GetSetting("Fill").Value)
             {
             {
-                Color fillColor = (Color)Toolbar.GetSetting("FillColor").Value;
+                Color fillColor = (Color) Toolbar.GetSetting("FillColor").Value;
                 pixels.ChangedPixels.AddRangeNewOnly(
                 pixels.ChangedPixels.AddRangeNewOnly(
-                    BitmapPixelChanges.FromSingleColoredArray(CalculateFillForEllipse(outline), fillColor).ChangedPixels);
+                    BitmapPixelChanges.FromSingleColoredArray(CalculateFillForEllipse(outline), fillColor)
+                        .ChangedPixels);
             }
             }
 
 
-            return new LayerChange[] { new LayerChange(pixels, layer) };
-        }
-
+            return new[] {new LayerChange(pixels, layer)};
+        }
+
         public Coordinates[] CreateEllipse(Coordinates startCoordinates, Coordinates endCoordinates, int thickness)
         public Coordinates[] CreateEllipse(Coordinates startCoordinates, Coordinates endCoordinates, int thickness)
         {
         {
             Coordinates centerCoordinates = CoordinatesCalculator.GetCenterPoint(startCoordinates, endCoordinates);
             Coordinates centerCoordinates = CoordinatesCalculator.GetCenterPoint(startCoordinates, endCoordinates);
@@ -41,16 +42,12 @@ namespace PixiEditor.Models.Tools.Tools
             List<Coordinates> output = new List<Coordinates>();
             List<Coordinates> output = new List<Coordinates>();
             Coordinates[] ellipse = MidpointEllipse(radiusX, radiusY, centerCoordinates.X, centerCoordinates.Y);
             Coordinates[] ellipse = MidpointEllipse(radiusX, radiusY, centerCoordinates.X, centerCoordinates.Y);
             if (thickness == 1)
             if (thickness == 1)
-            {
                 output.AddRange(ellipse);
                 output.AddRange(ellipse);
-            }
             else
             else
-            {
                 output.AddRange(GetThickShape(ellipse, thickness));
                 output.AddRange(GetThickShape(ellipse, thickness));
-            }
             return output.Distinct().ToArray();
             return output.Distinct().ToArray();
-        }
-
+        }
+
         public Coordinates[] MidpointEllipse(double rx, double ry, double xc, double yc)
         public Coordinates[] MidpointEllipse(double rx, double ry, double xc, double yc)
         {
         {
             List<Coordinates> outputCoordinates = new List<Coordinates>();
             List<Coordinates> outputCoordinates = new List<Coordinates>();
@@ -58,7 +55,7 @@ namespace PixiEditor.Models.Tools.Tools
             x = 0;
             x = 0;
             y = ry;
             y = ry;
 
 
-            d1 = (ry * ry) - (rx * rx * ry) + (0.25f * rx * rx);
+            d1 = ry * ry - rx * rx * ry + 0.25f * rx * rx;
             dx = 2 * ry * ry * x;
             dx = 2 * ry * ry * x;
             dy = 2 * rx * rx * y;
             dy = 2 * rx * rx * y;
 
 
@@ -68,21 +65,21 @@ namespace PixiEditor.Models.Tools.Tools
                 if (d1 < 0)
                 if (d1 < 0)
                 {
                 {
                     x++;
                     x++;
-                    dx += (2 * ry * ry);
-                    d1 = d1 + dx + (ry * ry);
+                    dx += 2 * ry * ry;
+                    d1 = d1 + dx + ry * ry;
                 }
                 }
                 else
                 else
                 {
                 {
                     x++;
                     x++;
                     y--;
                     y--;
-                    dx += (2 * ry * ry);
-                    dy -= (2 * rx * rx);
-                    d1 = d1 + dx - dy + (ry * ry);
+                    dx += 2 * ry * ry;
+                    dy -= 2 * rx * rx;
+                    d1 = d1 + dx - dy + ry * ry;
                 }
                 }
             }
             }
 
 
             //Decision parameter of region 2
             //Decision parameter of region 2
-            d2 = ((ry * ry) * ((x + 0.5f) * (x + 0.5f))) + ((rx * rx) * ((y - 1) * (y - 1))) - (rx * rx * ry * ry);
+            d2 = ry * ry * ((x + 0.5f) * (x + 0.5f)) + rx * rx * ((y - 1) * (y - 1)) - rx * rx * ry * ry;
 
 
             while (y >= 0)
             while (y >= 0)
             {
             {
@@ -91,23 +88,22 @@ namespace PixiEditor.Models.Tools.Tools
                 if (d2 > 0)
                 if (d2 > 0)
                 {
                 {
                     y--;
                     y--;
-                    dy -= (2 * rx * rx);
-                    d2 = d2 + (rx * rx) - dy;
+                    dy -= 2 * rx * rx;
+                    d2 = d2 + rx * rx - dy;
                 }
                 }
                 else
                 else
                 {
                 {
                     y--;
                     y--;
                     x++;
                     x++;
-                    dx += (2 * ry * ry);
-                    dy -= (2 * rx * rx);
-                    d2 = d2 + dx - dy + (rx * rx);
+                    dx += 2 * ry * ry;
+                    dy -= 2 * rx * rx;
+                    d2 = d2 + dx - dy + rx * rx;
                 }
                 }
             }
             }
 
 
             return outputCoordinates.Distinct().ToArray();
             return outputCoordinates.Distinct().ToArray();
+        }
 
 
-        }
-
         private Coordinates[] CalculateFillForEllipse(Coordinates[] outlineCoordinates)
         private Coordinates[] CalculateFillForEllipse(Coordinates[] outlineCoordinates)
         {
         {
             List<Coordinates> finalCoordinates = new List<Coordinates>();
             List<Coordinates> finalCoordinates = new List<Coordinates>();
@@ -118,22 +114,20 @@ namespace PixiEditor.Models.Tools.Tools
                 var rowCords = outlineCoordinates.Where(x => x.Y == i);
                 var rowCords = outlineCoordinates.Where(x => x.Y == i);
                 int right = rowCords.Max(x => x.X);
                 int right = rowCords.Max(x => x.X);
                 int left = rowCords.Min(x => x.X);
                 int left = rowCords.Min(x => x.X);
-                for (int j = left + 1; j < right; j++)
-                {
-                    finalCoordinates.Add(new Coordinates(j, i));
-                }
+                for (int j = left + 1; j < right; j++) finalCoordinates.Add(new Coordinates(j, i));
             }
             }
+
             return finalCoordinates.ToArray();
             return finalCoordinates.ToArray();
         }
         }
 
 
         private Coordinates[] GetRegionPoints(double x, double xc, double y, double yc)
         private Coordinates[] GetRegionPoints(double x, double xc, double y, double yc)
         {
         {
             Coordinates[] outputCoordinates = new Coordinates[4];
             Coordinates[] outputCoordinates = new Coordinates[4];
-            outputCoordinates[0] = (new Coordinates((int)x + (int)xc, (int)y + (int)yc));
-            outputCoordinates[1] = (new Coordinates((int)-x + (int)xc, (int)y + (int)yc));
-            outputCoordinates[2] = (new Coordinates((int)x + (int)xc, (int)-y + (int)yc));
-            outputCoordinates[3] = (new Coordinates((int)-x + (int)xc, (int)-y + (int)yc));
+            outputCoordinates[0] = new Coordinates((int) x + (int) xc, (int) y + (int) yc);
+            outputCoordinates[1] = new Coordinates((int) -x + (int) xc, (int) y + (int) yc);
+            outputCoordinates[2] = new Coordinates((int) x + (int) xc, (int) -y + (int) yc);
+            outputCoordinates[3] = new Coordinates((int) -x + (int) xc, (int) -y + (int) yc);
             return outputCoordinates;
             return outputCoordinates;
         }
         }
-    }
-}
+    }
+}

+ 12 - 8
PixiEditor/Models/Tools/Tools/ColorPickerTool.cs

@@ -1,19 +1,20 @@
-using PixiEditor.Models.Position;
+using System.Drawing;
+using PixiEditor.Models.Position;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
-using System.Windows.Media;
+using Color = System.Windows.Media.Color;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
 {
 {
     public class ColorPickerTool : ReadonlyTool
     public class ColorPickerTool : ReadonlyTool
     {
     {
-        public override ToolType ToolType => ToolType.ColorPicker;
-
         public ColorPickerTool()
         public ColorPickerTool()
         {
         {
             HideHighlight = true;
             HideHighlight = true;
             Tooltip = "Swaps primary color with selected on canvas. (O)";
             Tooltip = "Swaps primary color with selected on canvas. (O)";
         }
         }
 
 
+        public override ToolType ToolType => ToolType.ColorPicker;
+
         public override void Use(Coordinates[] coordinates)
         public override void Use(Coordinates[] coordinates)
         {
         {
             ViewModelMain.Current.PrimaryColor = GetColorUnderMouse();
             ViewModelMain.Current.PrimaryColor = GetColorUnderMouse();
@@ -22,15 +23,18 @@ namespace PixiEditor.Models.Tools.Tools
         public Color GetColorUnderMouse()
         public Color GetColorUnderMouse()
         {
         {
             System.Drawing.Color color;
             System.Drawing.Color color;
-            using (var bitmap = new System.Drawing.Bitmap(1, 1))
+            using (var bitmap = new Bitmap(1, 1))
             {
             {
-                using (var graphics = System.Drawing.Graphics.FromImage(bitmap))
+                using (var graphics = Graphics.FromImage(bitmap))
                 {
                 {
-                    graphics.CopyFromScreen(MousePositionConverter.GetCursorPosition(), new System.Drawing.Point(0, 0), new System.Drawing.Size(1, 1));
+                    graphics.CopyFromScreen(MousePositionConverter.GetCursorPosition(), new Point(0, 0),
+                        new Size(1, 1));
                 }
                 }
+
                 color = bitmap.GetPixel(0, 0);
                 color = bitmap.GetPixel(0, 0);
             }
             }
+
             return Color.FromArgb(color.A, color.R, color.G, color.B);
             return Color.FromArgb(color.A, color.R, color.G, color.B);
         }
         }
     }
     }
-}
+}

+ 7 - 7
PixiEditor/Models/Tools/Tools/EarserTool.cs

@@ -1,31 +1,31 @@
-using PixiEditor.Models.DataHolders;
+using System.Windows.Media;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.ToolSettings;
 using PixiEditor.Models.Tools.ToolSettings;
-using System.Windows.Media;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
 {
 {
     public class EarserTool : BitmapOperationTool
     public class EarserTool : BitmapOperationTool
     {
     {
-        public override ToolType ToolType => ToolType.Earser;
-
         public EarserTool()
         public EarserTool()
         {
         {
             Tooltip = "Earsers color from pixel (E)";
             Tooltip = "Earsers color from pixel (E)";
             Toolbar = new BasicToolbar();
             Toolbar = new BasicToolbar();
         }
         }
 
 
+        public override ToolType ToolType => ToolType.Earser;
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
-            return Earse(layer, coordinates, (int)Toolbar.GetSetting("ToolSize").Value);
+            return Earse(layer, coordinates, (int) Toolbar.GetSetting("ToolSize").Value);
         }
         }
 
 
         public LayerChange[] Earse(Layer layer, Coordinates[] coordinates, int toolSize)
         public LayerChange[] Earse(Layer layer, Coordinates[] coordinates, int toolSize)
         {
         {
             PenTool pen = new PenTool();
             PenTool pen = new PenTool();
             var pixels = pen.Draw(coordinates[0], System.Windows.Media.Colors.Transparent, toolSize);
             var pixels = pen.Draw(coordinates[0], System.Windows.Media.Colors.Transparent, toolSize);
-            return new LayerChange[] { new LayerChange(pixels, layer) };
+            return new[] {new LayerChange(pixels, layer)};
         }
         }
     }
     }
-}
+}

+ 13 - 12
PixiEditor/Models/Tools/Tools/FloodFill.cs

@@ -1,25 +1,25 @@
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
 {
 {
     public class FloodFill : BitmapOperationTool
     public class FloodFill : BitmapOperationTool
     {
     {
-        public override ToolType ToolType => ToolType.Bucket;
-
-        public FloodFill()
-        {
-            Tooltip = "Fills area with color (G)";
+        public FloodFill()
+        {
+            Tooltip = "Fills area with color (G)";
         }
         }
 
 
+        public override ToolType ToolType => ToolType.Bucket;
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
-        {
-            return new LayerChange[] { new LayerChange(ForestFire(layer, coordinates[0], color), layer) };
+        {
+            return new[] {new LayerChange(ForestFire(layer, coordinates[0], color), layer)};
         }
         }
 
 
         public BitmapPixelChanges ForestFire(Layer layer, Coordinates startingCoords, Color newColor)
         public BitmapPixelChanges ForestFire(Layer layer, Coordinates startingCoords, Color newColor)
@@ -50,8 +50,9 @@ namespace PixiEditor.Models.Tools.Tools
                     stack.Push(Tuple.Create(point.Item1 - 1, point.Item2));
                     stack.Push(Tuple.Create(point.Item1 - 1, point.Item2));
                 }
                 }
             }
             }
+
             bitmap.Unlock();
             bitmap.Unlock();
             return BitmapPixelChanges.FromSingleColoredArray(changedCoords.ToArray(), newColor);
             return BitmapPixelChanges.FromSingleColoredArray(changedCoords.ToArray(), newColor);
         }
         }
     }
     }
-}
+}

+ 41 - 47
PixiEditor/Models/Tools/Tools/LineTool.cs

@@ -1,47 +1,46 @@
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
+using System.Collections.Generic;
+using System.Windows.Media;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.ToolSettings;
 using PixiEditor.Models.Tools.ToolSettings;
-using System.Collections.Generic;
-using System.Windows.Media;
 
 
-namespace PixiEditor.Models.Tools.Tools
+namespace PixiEditor.Models.Tools.Tools
 {
 {
-    public class LineTool : ShapeTool
-    {
-
-        public override ToolType ToolType => ToolType.Line;
-
+    public class LineTool : ShapeTool
+    {
         public LineTool()
         public LineTool()
         {
         {
             Tooltip = "Draws line on canvas (L)";
             Tooltip = "Draws line on canvas (L)";
             Toolbar = new BasicToolbar();
             Toolbar = new BasicToolbar();
-        }
-
-        public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
-        {
-            var pixels = BitmapPixelChanges.FromSingleColoredArray(CreateLine(coordinates, (int)Toolbar.GetSetting("ToolSize").Value), color);
-            return new LayerChange[] { new LayerChange(pixels, layer) };
-        }
-
-        public Coordinates[] CreateLine(Coordinates[] coordinates, int thickness)
-        {
-            Coordinates startingCoordinates = coordinates[^1];
+        }
+
+        public override ToolType ToolType => ToolType.Line;
+
+        public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
+        {
+            var pixels =
+                BitmapPixelChanges.FromSingleColoredArray(
+                    CreateLine(coordinates, (int) Toolbar.GetSetting("ToolSize").Value), color);
+            return new[] {new LayerChange(pixels, layer)};
+        }
+
+        public Coordinates[] CreateLine(Coordinates[] coordinates, int thickness)
+        {
+            Coordinates startingCoordinates = coordinates[^1];
             Coordinates latestCoordinates = coordinates[0];
             Coordinates latestCoordinates = coordinates[0];
             if (thickness == 1)
             if (thickness == 1)
-            {
-                return BresenhamLine(startingCoordinates.X, startingCoordinates.Y, latestCoordinates.X, latestCoordinates.Y);
-            }
-            return GetThickShape(BresenhamLine(startingCoordinates.X, startingCoordinates.Y, latestCoordinates.X, latestCoordinates.Y), thickness);
+                return BresenhamLine(startingCoordinates.X, startingCoordinates.Y, latestCoordinates.X,
+                    latestCoordinates.Y);
+            return GetThickShape(
+                BresenhamLine(startingCoordinates.X, startingCoordinates.Y, latestCoordinates.X, latestCoordinates.Y),
+                thickness);
         }
         }
 
 
         private Coordinates[] BresenhamLine(int x1, int y1, int x2, int y2)
         private Coordinates[] BresenhamLine(int x1, int y1, int x2, int y2)
         {
         {
             List<Coordinates> coordinates = new List<Coordinates>();
             List<Coordinates> coordinates = new List<Coordinates>();
-            if (x1 == x2 && y1 == y2)
-            {
-                return new Coordinates[] { new Coordinates(x1, y1) };
-            }
+            if (x1 == x2 && y1 == y2) return new[] {new Coordinates(x1, y1)};
 
 
             int d, dx, dy, ai, bi, xi, yi;
             int d, dx, dy, ai, bi, xi, yi;
             int x = x1, y = y1;
             int x = x1, y = y1;
@@ -67,6 +66,7 @@ namespace PixiEditor.Models.Tools.Tools
                 yi = -1;
                 yi = -1;
                 dy = y1 - y2;
                 dy = y1 - y2;
             }
             }
+
             coordinates.Add(new Coordinates(x, y));
             coordinates.Add(new Coordinates(x, y));
 
 
             if (dx > dy)
             if (dx > dy)
@@ -77,7 +77,6 @@ namespace PixiEditor.Models.Tools.Tools
 
 
                 while (x != x2)
                 while (x != x2)
                 {
                 {
-
                     if (d >= 0)
                     if (d >= 0)
                     {
                     {
                         x += xi;
                         x += xi;
@@ -89,6 +88,7 @@ namespace PixiEditor.Models.Tools.Tools
                         d += bi;
                         d += bi;
                         x += xi;
                         x += xi;
                     }
                     }
+
                     coordinates.Add(new Coordinates(x, y));
                     coordinates.Add(new Coordinates(x, y));
                 }
                 }
             }
             }
@@ -100,7 +100,6 @@ namespace PixiEditor.Models.Tools.Tools
 
 
                 while (y != y2)
                 while (y != y2)
                 {
                 {
-
                     if (d >= 0)
                     if (d >= 0)
                     {
                     {
                         x += xi;
                         x += xi;
@@ -112,34 +111,29 @@ namespace PixiEditor.Models.Tools.Tools
                         d += bi;
                         d += bi;
                         y += yi;
                         y += yi;
                     }
                     }
+
                     coordinates.Add(new Coordinates(x, y));
                     coordinates.Add(new Coordinates(x, y));
                 }
                 }
             }
             }
 
 
             return coordinates.ToArray();
             return coordinates.ToArray();
-
         }
         }
 
 
         private int[,] GetMaskForThickness(int thickness)
         private int[,] GetMaskForThickness(int thickness)
         {
         {
             if (thickness == 2)
             if (thickness == 2)
-            {
-                return new int[,] {
-                {0,0,0 },
-                {0,1,1 },
-                {0,1,1 }
+                return new[,]
+                {
+                    {0, 0, 0},
+                    {0, 1, 1},
+                    {0, 1, 1}
                 };
                 };
-            }
             int[,] mask = new int[thickness, thickness];
             int[,] mask = new int[thickness, thickness];
 
 
             for (int i = 0; i < thickness; i++)
             for (int i = 0; i < thickness; i++)
-            {
-                for (int j = 0; j < thickness; j++)
-                {
-                    mask[i, j] = 1;
-                }
-            }
+            for (int j = 0; j < thickness; j++)
+                mask[i, j] = 1;
             return mask;
             return mask;
         }
         }
-    }
-}
+    }
+}

+ 40 - 41
PixiEditor/Models/Tools/Tools/MoveTool.cs

@@ -1,30 +1,30 @@
-using PixiEditor.Helpers.Extensions;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Input;
+using System.Windows.Media;
+using PixiEditor.Helpers.Extensions;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Enums;
 using PixiEditor.Models.Images;
 using PixiEditor.Models.Images;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
+using Transform = PixiEditor.Models.ImageManipulation.Transform;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
 {
 {
     public class MoveTool : BitmapOperationTool
     public class MoveTool : BitmapOperationTool
     {
     {
-        public override ToolType ToolType => ToolType.Move;
-        private Coordinates[] _startSelection;
-        private Coordinates _lastStartMousePos;
-        private Coordinates _lastMouseMove;
-        private Dictionary<Layer, Color[]> _startPixelColors;
+        private Layer[] _affectedLayers;
         private Dictionary<Layer, bool> _clearedPixels = new Dictionary<Layer, bool>();
         private Dictionary<Layer, bool> _clearedPixels = new Dictionary<Layer, bool>();
+        private BitmapPixelChanges _clearedPixelsChange;
         private Coordinates[] _currentSelection;
         private Coordinates[] _currentSelection;
+        private Coordinates _lastMouseMove;
+        private Coordinates _lastStartMousePos;
+        private Dictionary<Layer, Color[]> _startPixelColors;
+        private Coordinates[] _startSelection;
         private bool _updateViewModelSelection = true;
         private bool _updateViewModelSelection = true;
-        private BitmapPixelChanges _clearedPixelsChange;
-        private Layer[] _affectedLayers;
 
 
         public MoveTool()
         public MoveTool()
         {
         {
@@ -35,31 +35,34 @@ namespace PixiEditor.Models.Tools.Tools
             UseDefaultUndoMethod = true;
             UseDefaultUndoMethod = true;
         }
         }
 
 
+        public override ToolType ToolType => ToolType.Move;
+
         public override void AfterAddedUndo()
         public override void AfterAddedUndo()
         {
         {
             //Inject to default undo system change custom changes made by this tool
             //Inject to default undo system change custom changes made by this tool
-            foreach(var item in _startPixelColors)
+            foreach (var item in _startPixelColors)
             {
             {
-                BitmapPixelChanges beforeMovePixels = BitmapPixelChanges.
-                    FromArrays(_startSelection, item.Value);
+                BitmapPixelChanges beforeMovePixels = BitmapPixelChanges.FromArrays(_startSelection, item.Value);
                 Change changes = UndoManager.UndoStack.Peek();
                 Change changes = UndoManager.UndoStack.Peek();
                 int layerIndex = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.IndexOf(item.Key);
                 int layerIndex = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.IndexOf(item.Key);
 
 
-                (changes.OldValue as LayerChange[])[layerIndex].PixelChanges.ChangedPixels.
-                    AddRangeOverride(beforeMovePixels.ChangedPixels);
+                (changes.OldValue as LayerChange[])[layerIndex].PixelChanges.ChangedPixels
+                    .AddRangeOverride(beforeMovePixels.ChangedPixels);
 
 
-                (changes.NewValue as LayerChange[])[layerIndex].PixelChanges.ChangedPixels.
-                    AddRangeOverride(_clearedPixelsChange.ChangedPixels);
-            }     
+                (changes.NewValue as LayerChange[])[layerIndex].PixelChanges.ChangedPixels
+                    .AddRangeOverride(_clearedPixelsChange.ChangedPixels);
+            }
         }
         }
 
 
         public override LayerChange[] Use(Layer layer, Coordinates[] mouseMove, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] mouseMove, Color color)
         {
         {
             Coordinates start = mouseMove[^1];
             Coordinates start = mouseMove[^1];
-            if (_lastStartMousePos != start) //I am aware that this could be moved to OnMouseDown, but it is executed before Use, so I didn't want to complicate for now
+            if (_lastStartMousePos != start
+            ) //I am aware that this could be moved to OnMouseDown, but it is executed before Use, so I didn't want to complicate for now
             {
             {
                 ResetSelectionValues(start);
                 ResetSelectionValues(start);
-                if (ViewModelMain.Current.ActiveSelection.SelectedPoints.Count == 0) //Move every pixel if none is selected
+                if (ViewModelMain.Current.ActiveSelection.SelectedPoints.Count == 0
+                ) //Move every pixel if none is selected
                 {
                 {
                     SelectTool select = new SelectTool();
                     SelectTool select = new SelectTool();
                     _currentSelection = select.GetAllSelection();
                     _currentSelection = select.GetAllSelection();
@@ -71,13 +74,10 @@ namespace PixiEditor.Models.Tools.Tools
                 }
                 }
 
 
                 if (Keyboard.IsKeyDown(Key.LeftCtrl))
                 if (Keyboard.IsKeyDown(Key.LeftCtrl))
-                {
-                    _affectedLayers = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.Where(x=> x.IsVisible).ToArray();
-                }
+                    _affectedLayers = ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.Where(x => x.IsVisible)
+                        .ToArray();
                 else
                 else
-                {
-                    _affectedLayers = new Layer[] { layer };
-                }
+                    _affectedLayers = new[] {layer};
 
 
                 _startSelection = _currentSelection;
                 _startSelection = _currentSelection;
                 _startPixelColors = BitmapUtils.GetPixelsForSelection(_affectedLayers, _startSelection);
                 _startPixelColors = BitmapUtils.GetPixelsForSelection(_affectedLayers, _startSelection);
@@ -89,18 +89,17 @@ namespace PixiEditor.Models.Tools.Tools
             {
             {
                 var changes = MoveSelection(_affectedLayers[i], mouseMove);
                 var changes = MoveSelection(_affectedLayers[i], mouseMove);
                 changes = RemoveTransparentPixels(changes);
                 changes = RemoveTransparentPixels(changes);
-                
+
                 result[i] = new LayerChange(changes, _affectedLayers[i]);
                 result[i] = new LayerChange(changes, _affectedLayers[i]);
             }
             }
+
             return result;
             return result;
         }
         }
 
 
         private BitmapPixelChanges RemoveTransparentPixels(BitmapPixelChanges pixels)
         private BitmapPixelChanges RemoveTransparentPixels(BitmapPixelChanges pixels)
         {
         {
             foreach (var item in pixels.ChangedPixels.Where(x => x.Value.A == 0).ToList())
             foreach (var item in pixels.ChangedPixels.Where(x => x.Value.A == 0).ToList())
-            {
                 pixels.ChangedPixels.Remove(item.Key);
                 pixels.ChangedPixels.Remove(item.Key);
-            }
             return pixels;
             return pixels;
         }
         }
 
 
@@ -110,9 +109,7 @@ namespace PixiEditor.Models.Tools.Tools
 
 
             _currentSelection = TranslateSelection(end, out Coordinates[] previousSelection);
             _currentSelection = TranslateSelection(end, out Coordinates[] previousSelection);
             if (_updateViewModelSelection)
             if (_updateViewModelSelection)
-            {
-                ViewModelMain.Current.ActiveSelection.SetSelection(_currentSelection, Enums.SelectionType.New);
-            }
+                ViewModelMain.Current.ActiveSelection.SetSelection(_currentSelection, SelectionType.New);
             ClearSelectedPixels(layer, previousSelection);
             ClearSelectedPixels(layer, previousSelection);
 
 
 
 
@@ -130,20 +127,22 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         private Coordinates[] TranslateSelection(Coordinates end, out Coordinates[] previousSelection)
         private Coordinates[] TranslateSelection(Coordinates end, out Coordinates[] previousSelection)
         {
         {
-            Coordinates translation = ImageManipulation.Transform.GetTranslation(_lastMouseMove, end);
+            Coordinates translation = Transform.GetTranslation(_lastMouseMove, end);
             previousSelection = _currentSelection.ToArray();
             previousSelection = _currentSelection.ToArray();
-            return ImageManipulation.Transform.Translate(previousSelection, translation);
+            return Transform.Translate(previousSelection, translation);
         }
         }
 
 
         private void ClearSelectedPixels(Layer layer, Coordinates[] selection)
         private void ClearSelectedPixels(Layer layer, Coordinates[] selection)
         {
         {
             if (!_clearedPixels.ContainsKey(layer) || _clearedPixels[layer] == false)
             if (!_clearedPixels.ContainsKey(layer) || _clearedPixels[layer] == false)
             {
             {
-                _clearedPixelsChange = BitmapPixelChanges.FromSingleColoredArray(selection, System.Windows.Media.Colors.Transparent);
-                ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.First(x=> x == layer).ApplyPixels(_clearedPixelsChange);
+                _clearedPixelsChange =
+                    BitmapPixelChanges.FromSingleColoredArray(selection, System.Windows.Media.Colors.Transparent);
+                ViewModelMain.Current.BitmapManager.ActiveDocument.Layers.First(x => x == layer)
+                    .ApplyPixels(_clearedPixelsChange);
 
 
                 _clearedPixels[layer] = true;
                 _clearedPixels[layer] = true;
             }
             }
-        }       
+        }
     }
     }
-}
+}

+ 18 - 16
PixiEditor/Models/Tools/Tools/PenTool.cs

@@ -1,29 +1,30 @@
-using PixiEditor.Models.DataHolders;
+using System.Windows.Input;
+using System.Windows.Media;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
-using PixiEditor.Models.Tools.ToolSettings;
-using System.Windows.Input;
-using System.Windows.Media;
+using PixiEditor.Models.Tools.ToolSettings;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
 {
 {
     public class PenTool : BitmapOperationTool
     public class PenTool : BitmapOperationTool
     {
     {
-        public override ToolType ToolType => ToolType.Pen;
-        private int _toolSizeIndex;
+        private readonly int _toolSizeIndex;
 
 
-        public PenTool()
-        {
-            Cursor = Cursors.Pen;
-            Tooltip = "Standard brush (B)";
-            Toolbar = new BasicToolbar();
-            _toolSizeIndex = Toolbar.Settings.IndexOf(Toolbar.GetSetting("ToolSize"));
+        public PenTool()
+        {
+            Cursor = Cursors.Pen;
+            Tooltip = "Standard brush (B)";
+            Toolbar = new BasicToolbar();
+            _toolSizeIndex = Toolbar.Settings.IndexOf(Toolbar.GetSetting("ToolSize"));
         }
         }
 
 
+        public override ToolType ToolType => ToolType.Pen;
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
-            var pixels = Draw(coordinates[0], color, (int)Toolbar.Settings[_toolSizeIndex].Value);
-            return new LayerChange[] { new LayerChange(pixels, layer) };
+            var pixels = Draw(coordinates[0], color, (int) Toolbar.Settings[_toolSizeIndex].Value);
+            return new[] {new LayerChange(pixels, layer)};
         }
         }
 
 
         public BitmapPixelChanges Draw(Coordinates startingCoords, Color color, int toolSize)
         public BitmapPixelChanges Draw(Coordinates startingCoords, Color color, int toolSize)
@@ -34,7 +35,8 @@ namespace PixiEditor.Models.Tools.Tools
             y1 = centeredCoords.Coords1.Y;
             y1 = centeredCoords.Coords1.Y;
             x2 = centeredCoords.Coords2.X;
             x2 = centeredCoords.Coords2.X;
             y2 = centeredCoords.Coords2.Y;
             y2 = centeredCoords.Coords2.Y;
-            return BitmapPixelChanges.FromSingleColoredArray(CoordinatesCalculator.RectangleToCoordinates(x1, y1, x2, y2), color);
+            return BitmapPixelChanges.FromSingleColoredArray(
+                CoordinatesCalculator.RectangleToCoordinates(x1, y1, x2, y2), color);
         }
         }
     }
     }
-}
+}

+ 56 - 56
PixiEditor/Models/Tools/Tools/RectangleTool.cs

@@ -1,66 +1,65 @@
-using PixiEditor.Helpers.Extensions;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
-using System.Windows.Media;
-
-namespace PixiEditor.Models.Tools.Tools
-{
-    public class RectangleTool : ShapeTool
-    {
-        public override ToolType ToolType => ToolType.Rectangle;
-        public bool Filled { get; set; } = false;
-
+using System.Windows.Media;
+using PixiEditor.Helpers.Extensions;
+using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Layers;
+using PixiEditor.Models.Position;
+
+namespace PixiEditor.Models.Tools.Tools
+{
+    public class RectangleTool : ShapeTool
+    {
         public RectangleTool()
         public RectangleTool()
         {
         {
             Tooltip = "Draws rectanlge on cavnas (R)";
             Tooltip = "Draws rectanlge on cavnas (R)";
-        }
-
-        public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
-        {
-            int thickness = (int)Toolbar.GetSetting("ToolSize").Value;
-            BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(CreateRectangle(coordinates, thickness), color);
-            if ((bool)Toolbar.GetSetting("Fill").Value)
+        }
+
+        public override ToolType ToolType => ToolType.Rectangle;
+        public bool Filled { get; set; } = false;
+
+        public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
+        {
+            int thickness = (int) Toolbar.GetSetting("ToolSize").Value;
+            BitmapPixelChanges pixels =
+                BitmapPixelChanges.FromSingleColoredArray(CreateRectangle(coordinates, thickness), color);
+            if ((bool) Toolbar.GetSetting("Fill").Value)
             {
             {
-                Color fillColor = (Color)Toolbar.GetSetting("FillColor").Value;
+                Color fillColor = (Color) Toolbar.GetSetting("FillColor").Value;
                 pixels.ChangedPixels.AddRangeOverride(
                 pixels.ChangedPixels.AddRangeOverride(
                     BitmapPixelChanges.FromSingleColoredArray
                     BitmapPixelChanges.FromSingleColoredArray
-                    (CalculateFillForRectangle(coordinates[^1], coordinates[0], thickness), fillColor).ChangedPixels);
+                            (CalculateFillForRectangle(coordinates[^1], coordinates[0], thickness), fillColor)
+                        .ChangedPixels);
             }
             }
-            return new LayerChange[] { new LayerChange(pixels, layer) };
-        }
-
-        public Coordinates[] CreateRectangle(Coordinates[] coordinates, int thickness)
-        {
-            DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
-            List<Coordinates> output = new List<Coordinates>();
-            Coordinates[] rectangle = CalculateRectanglePoints(fixedCoordinates);
+
+            return new[] {new LayerChange(pixels, layer)};
+        }
+
+        public Coordinates[] CreateRectangle(Coordinates[] coordinates, int thickness)
+        {
+            DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
+            List<Coordinates> output = new List<Coordinates>();
+            Coordinates[] rectangle = CalculateRectanglePoints(fixedCoordinates);
             output.AddRange(rectangle);
             output.AddRange(rectangle);
 
 
-            for (int i = 1; i < (int)Math.Floor(thickness / 2f) + 1; i++)
-            {
+            for (int i = 1; i < (int) Math.Floor(thickness / 2f) + 1; i++)
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                     new Coordinates(fixedCoordinates.Coords1.X - i, fixedCoordinates.Coords1.Y - i),
                     new Coordinates(fixedCoordinates.Coords1.X - i, fixedCoordinates.Coords1.Y - i),
                     new Coordinates(fixedCoordinates.Coords2.X + i, fixedCoordinates.Coords2.Y + i))));
                     new Coordinates(fixedCoordinates.Coords2.X + i, fixedCoordinates.Coords2.Y + i))));
-            }
-            for (int i = 1; i < (int)Math.Ceiling(thickness / 2f); i++)
-            {
+            for (int i = 1; i < (int) Math.Ceiling(thickness / 2f); i++)
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                     new Coordinates(fixedCoordinates.Coords1.X + i, fixedCoordinates.Coords1.Y + i),
                     new Coordinates(fixedCoordinates.Coords1.X + i, fixedCoordinates.Coords1.Y + i),
                     new Coordinates(fixedCoordinates.Coords2.X - i, fixedCoordinates.Coords2.Y - i))));
                     new Coordinates(fixedCoordinates.Coords2.X - i, fixedCoordinates.Coords2.Y - i))));
-            }
 
 
-            return output.Distinct().ToArray();
-        }
-
-        public Coordinates[] CreateRectangle(Coordinates start, Coordinates end, int thickness)
-        {
-            return CreateRectangle(new Coordinates[] { start, end }, thickness);
-        }
-
+            return output.Distinct().ToArray();
+        }
+
+        public Coordinates[] CreateRectangle(Coordinates start, Coordinates end, int thickness)
+        {
+            return CreateRectangle(new[] {start, end}, thickness);
+        }
+
         private Coordinates[] CalculateRectanglePoints(DoubleCords coordinates)
         private Coordinates[] CalculateRectanglePoints(DoubleCords coordinates)
         {
         {
             List<Coordinates> finalCoordinates = new List<Coordinates>();
             List<Coordinates> finalCoordinates = new List<Coordinates>();
@@ -70,17 +69,19 @@ namespace PixiEditor.Models.Tools.Tools
                 finalCoordinates.Add(new Coordinates(i, coordinates.Coords1.Y));
                 finalCoordinates.Add(new Coordinates(i, coordinates.Coords1.Y));
                 finalCoordinates.Add(new Coordinates(i, coordinates.Coords2.Y));
                 finalCoordinates.Add(new Coordinates(i, coordinates.Coords2.Y));
             }
             }
+
             for (int i = coordinates.Coords1.Y + 1; i <= coordinates.Coords2.Y - 1; i++)
             for (int i = coordinates.Coords1.Y + 1; i <= coordinates.Coords2.Y - 1; i++)
             {
             {
                 finalCoordinates.Add(new Coordinates(coordinates.Coords1.X, i));
                 finalCoordinates.Add(new Coordinates(coordinates.Coords1.X, i));
                 finalCoordinates.Add(new Coordinates(coordinates.Coords2.X, i));
                 finalCoordinates.Add(new Coordinates(coordinates.Coords2.X, i));
             }
             }
+
             return finalCoordinates.ToArray();
             return finalCoordinates.ToArray();
-        }
-
+        }
+
         public Coordinates[] CalculateFillForRectangle(Coordinates start, Coordinates end, int thickness)
         public Coordinates[] CalculateFillForRectangle(Coordinates start, Coordinates end, int thickness)
         {
         {
-            int offset = (int)Math.Ceiling(thickness / 2f);
+            int offset = (int) Math.Ceiling(thickness / 2f);
             DoubleCords fixedCords = CalculateCoordinatesForShapeRotation(start, end);
             DoubleCords fixedCords = CalculateCoordinatesForShapeRotation(start, end);
 
 
             DoubleCords innerCords = new DoubleCords
             DoubleCords innerCords = new DoubleCords
@@ -96,14 +97,13 @@ namespace PixiEditor.Models.Tools.Tools
             Coordinates[] filledCoordinates = new Coordinates[width * height];
             Coordinates[] filledCoordinates = new Coordinates[width * height];
             int i = 0;
             int i = 0;
             for (int y = 0; y < height; y++)
             for (int y = 0; y < height; y++)
+            for (int x = 0; x < width; x++)
             {
             {
-                for (int x = 0; x < width; x++)
-                {
-                    filledCoordinates[i] = new Coordinates(innerCords.Coords1.X + x, innerCords.Coords1.Y + y);
-                    i++;
-                }
+                filledCoordinates[i] = new Coordinates(innerCords.Coords1.X + x, innerCords.Coords1.Y + y);
+                i++;
             }
             }
+
             return filledCoordinates.Distinct().ToArray();
             return filledCoordinates.Distinct().ToArray();
-        }
-    }
-}
+        }
+    }
+}

+ 14 - 16
PixiEditor/Models/Tools/Tools/SelectTool.cs

@@ -1,39 +1,38 @@
-using PixiEditor.Models.Controllers;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Controls;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.ToolSettings.Toolbars;
 using PixiEditor.Models.Tools.ToolSettings.Toolbars;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Controls;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
 {
 {
     public class SelectTool : ReadonlyTool
     public class SelectTool : ReadonlyTool
     {
     {
-        public override ToolType ToolType => ToolType.Select;
+        private Selection _oldSelection;
         public SelectionType SelectionType = SelectionType.Add;
         public SelectionType SelectionType = SelectionType.Add;
 
 
-        Selection _oldSelection = null;
-
         public SelectTool()
         public SelectTool()
         {
         {
             Tooltip = "Selects area. (M)";
             Tooltip = "Selects area. (M)";
             Toolbar = new SelectToolToolbar();
             Toolbar = new SelectToolToolbar();
         }
         }
 
 
+        public override ToolType ToolType => ToolType.Select;
+
         public override void OnMouseDown()
         public override void OnMouseDown()
         {
         {
             Enum.TryParse((Toolbar.GetSetting("Mode").Value as ComboBoxItem).Content as string, out SelectionType);
             Enum.TryParse((Toolbar.GetSetting("Mode").Value as ComboBoxItem).Content as string, out SelectionType);
 
 
             _oldSelection = null;
             _oldSelection = null;
-            if (ViewModelMain.Current.ActiveSelection != null && ViewModelMain.Current.ActiveSelection.SelectedPoints != null)
-            {
+            if (ViewModelMain.Current.ActiveSelection != null &&
+                ViewModelMain.Current.ActiveSelection.SelectedPoints != null)
                 _oldSelection = ViewModelMain.Current.ActiveSelection;
                 _oldSelection = ViewModelMain.Current.ActiveSelection;
-            }
         }
         }
 
 
         public override void OnMouseUp()
         public override void OnMouseUp()
@@ -43,7 +42,7 @@ namespace PixiEditor.Models.Tools.Tools
         }
         }
 
 
         public override void Use(Coordinates[] pixels)
         public override void Use(Coordinates[] pixels)
-        {            
+        {
             Select(pixels);
             Select(pixels);
         }
         }
 
 
@@ -62,17 +61,16 @@ namespace PixiEditor.Models.Tools.Tools
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Gets coordinates of every pixel in root layer
+        ///     Gets coordinates of every pixel in root layer
         /// </summary>
         /// </summary>
         /// <returns>Coordinates array of pixels</returns>
         /// <returns>Coordinates array of pixels</returns>
         public Coordinates[] GetAllSelection()
         public Coordinates[] GetAllSelection()
         {
         {
-
             return GetAllSelection(ViewModelMain.Current.BitmapManager.ActiveDocument.Layers[0]);
             return GetAllSelection(ViewModelMain.Current.BitmapManager.ActiveDocument.Layers[0]);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Gets coordinates of every pixel in choosen layer
+        ///     Gets coordinates of every pixel in choosen layer
         /// </summary>
         /// </summary>
         /// <param name="layer"></param>
         /// <param name="layer"></param>
         /// <returns>Coordinates array of pixels</returns>
         /// <returns>Coordinates array of pixels</returns>
@@ -81,4 +79,4 @@ namespace PixiEditor.Models.Tools.Tools
             return GetRectangleSelectionForPoints(new Coordinates(0, 0), new Coordinates(layer.Width, layer.Height));
             return GetRectangleSelectionForPoints(new Coordinates(0, 0), new Coordinates(layer.Width, layer.Height));
         }
         }
     }
     }
-}
+}

+ 5 - 5
PixiEditor/Properties/AssemblyInfo.cs

@@ -31,11 +31,11 @@ using System.Windows;
 
 
 [assembly: ThemeInfo(
 [assembly: ThemeInfo(
     ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
     ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
-                                     //(used if a resource is not found in the page,
-                                     // or application resource dictionaries)
+    //(used if a resource is not found in the page,
+    // or application resource dictionaries)
     ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
     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)
+    //(used if a resource is not found in the page,
+    // app, or any theme specific resource dictionaries)
 )]
 )]
 
 
 
 
@@ -51,4 +51,4 @@ using System.Windows;
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
 
 
 [assembly: AssemblyVersion("0.0.4.1")]
 [assembly: AssemblyVersion("0.0.4.1")]
-[assembly: AssemblyFileVersion("0.0.4.1")]
+[assembly: AssemblyFileVersion("0.0.4.1")]

+ 1 - 0
PixiEditor/Properties/Settings.settings

@@ -1,4 +1,5 @@
 <?xml version='1.0' encoding='utf-8'?>
 <?xml version='1.0' encoding='utf-8'?>
+
 <SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
 <SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
   <Profiles>
   <Profiles>
     <Profile Name="(Default)" />
     <Profile Name="(Default)" />

+ 32 - 24
PixiEditor/Styles/AnchorPointToggleButtonStyle.xaml

@@ -1,49 +1,57 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:local="clr-namespace:PixiEditor">
                     xmlns:local="clr-namespace:PixiEditor">
-    
+
     <Style x:Key="FocusVisual">
     <Style x:Key="FocusVisual">
         <Setter Property="Control.Template">
         <Setter Property="Control.Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate>
                 <ControlTemplate>
-                    <Rectangle Margin="2" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
+                    <Rectangle Margin="2" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1"
+                               Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
                 </ControlTemplate>
                 </ControlTemplate>
             </Setter.Value>
             </Setter.Value>
         </Setter>
         </Setter>
     </Style>
     </Style>
-    <SolidColorBrush x:Key="Button.Static.Background" Color="#FFDDDDDD"/>
-    <SolidColorBrush x:Key="Button.Static.Border" Color="#FF707070"/>
-    <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/>
-    <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/>
-    <SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/>
-    <SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/>
-    <SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
-    <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
-    <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>
+    <SolidColorBrush x:Key="Button.Static.Background" Color="#FFDDDDDD" />
+    <SolidColorBrush x:Key="Button.Static.Border" Color="#FF707070" />
+    <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD" />
+    <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1" />
+    <SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6" />
+    <SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B" />
+    <SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4" />
+    <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5" />
+    <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383" />
     <Style x:Key="AnchorPointToggleButtonStyle" TargetType="{x:Type ToggleButton}">
     <Style x:Key="AnchorPointToggleButtonStyle" TargetType="{x:Type ToggleButton}">
-        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
-        <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
-        <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
-        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
-        <Setter Property="BorderThickness" Value="1"/>
-        <Setter Property="HorizontalContentAlignment" Value="Center"/>
-        <Setter Property="VerticalContentAlignment" Value="Center"/>
-        <Setter Property="Padding" Value="1"/>
+        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
+        <Setter Property="Background" Value="{StaticResource Button.Static.Background}" />
+        <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}" />
+        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
+        <Setter Property="BorderThickness" Value="1" />
+        <Setter Property="HorizontalContentAlignment" Value="Center" />
+        <Setter Property="VerticalContentAlignment" Value="Center" />
+        <Setter Property="Padding" Value="1" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type ToggleButton}">
                 <ControlTemplate TargetType="{x:Type ToggleButton}">
-                    <Border x:Name="border" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="true">
-                        <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+                    <Border x:Name="border" Background="{TemplateBinding Background}"
+                            BorderThickness="{TemplateBinding BorderThickness}"
+                            BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="true">
+                        <ContentPresenter x:Name="contentPresenter" Focusable="False"
+                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                          Margin="{TemplateBinding Padding}" RecognizesAccessKey="True"
+                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
+                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                     </Border>
                     </Border>
                     <ControlTemplate.Triggers>
                     <ControlTemplate.Triggers>
                         <Trigger Property="Button.IsDefaulted" Value="true">
                         <Trigger Property="Button.IsDefaulted" Value="true">
-                            <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
+                            <Setter Property="BorderBrush" TargetName="border"
+                                    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                         </Trigger>
                         </Trigger>
                         <Trigger Property="IsMouseOver" Value="true">
                         <Trigger Property="IsMouseOver" Value="true">
-                            <Setter Property="BorderBrush" TargetName="border" Value="DimGray"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value="DimGray" />
                         </Trigger>
                         </Trigger>
                         <Trigger Property="ToggleButton.IsChecked" Value="True">
                         <Trigger Property="ToggleButton.IsChecked" Value="True">
-                            <Setter Property="BorderBrush" TargetName="border" Value="White"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value="White" />
                         </Trigger>
                         </Trigger>
                     </ControlTemplate.Triggers>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
                 </ControlTemplate>

+ 71 - 56
PixiEditor/Styles/ColorSliderStyle.xaml

@@ -1,42 +1,43 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:local="clr-namespace:PixiEditor.Helpers.UI">
                     xmlns:local="clr-namespace:PixiEditor.Helpers.UI">
-    
+
     <Style x:Key="RepeatButtonTransparent" TargetType="{x:Type RepeatButton}">
     <Style x:Key="RepeatButtonTransparent" TargetType="{x:Type RepeatButton}">
-        <Setter Property="OverridesDefaultStyle" Value="true"/>
-        <Setter Property="Background" Value="Transparent"/>
-        <Setter Property="Focusable" Value="false"/>
-        <Setter Property="IsTabStop" Value="false"/>
+        <Setter Property="OverridesDefaultStyle" Value="true" />
+        <Setter Property="Background" Value="Transparent" />
+        <Setter Property="Focusable" Value="false" />
+        <Setter Property="IsTabStop" Value="false" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type RepeatButton}">
                 <ControlTemplate TargetType="{x:Type RepeatButton}">
-                    <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
+                    <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}"
+                               Width="{TemplateBinding Width}" />
                 </ControlTemplate>
                 </ControlTemplate>
             </Setter.Value>
             </Setter.Value>
         </Setter>
         </Setter>
     </Style>
     </Style>
-    <SolidColorBrush x:Key="SliderThumb.Static.Background" Color="#FFF0F0F0"/>
-    <SolidColorBrush x:Key="SliderThumb.Static.Border" Color="White"/>
-    <SolidColorBrush x:Key="SliderThumb.MouseOver.Background" Color="#FFDCECFC"/>
-    <SolidColorBrush x:Key="SliderThumb.MouseOver.Border" Color="#FF7Eb4EA"/>
-    <SolidColorBrush x:Key="SliderThumb.Pressed.Background" Color="#FFDAECFC"/>
-    <SolidColorBrush x:Key="SliderThumb.Pressed.Border" Color="#FF569DE5"/>
-    <SolidColorBrush x:Key="SliderThumb.Disabled.Background" Color="#FFF0F0F0"/>
-    <SolidColorBrush x:Key="SliderThumb.Disabled.Border" Color="#FFD9D9D9"/>
-    <SolidColorBrush x:Key="SliderThumb.Track.Background" Color="#FFE7EAEA"/>
-    <SolidColorBrush x:Key="SliderThumb.Track.Border" Color="#FFD6D6D6"/>
+    <SolidColorBrush x:Key="SliderThumb.Static.Background" Color="#FFF0F0F0" />
+    <SolidColorBrush x:Key="SliderThumb.Static.Border" Color="White" />
+    <SolidColorBrush x:Key="SliderThumb.MouseOver.Background" Color="#FFDCECFC" />
+    <SolidColorBrush x:Key="SliderThumb.MouseOver.Border" Color="#FF7Eb4EA" />
+    <SolidColorBrush x:Key="SliderThumb.Pressed.Background" Color="#FFDAECFC" />
+    <SolidColorBrush x:Key="SliderThumb.Pressed.Border" Color="#FF569DE5" />
+    <SolidColorBrush x:Key="SliderThumb.Disabled.Background" Color="#FFF0F0F0" />
+    <SolidColorBrush x:Key="SliderThumb.Disabled.Border" Color="#FFD9D9D9" />
+    <SolidColorBrush x:Key="SliderThumb.Track.Background" Color="#FFE7EAEA" />
+    <SolidColorBrush x:Key="SliderThumb.Track.Border" Color="#FFD6D6D6" />
     <ControlTemplate x:Key="SliderThumbHorizontalDefault" TargetType="{x:Type Thumb}">
     <ControlTemplate x:Key="SliderThumbHorizontalDefault" TargetType="{x:Type Thumb}">
         <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
         <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
             <Ellipse x:Name="grip" Width="12" Height="12" ClipToBounds="False">
             <Ellipse x:Name="grip" Width="12" Height="12" ClipToBounds="False">
                 <Ellipse.Fill>
                 <Ellipse.Fill>
-                    <ImageBrush ImageSource="../Images/ColorCircle.png"/>
+                    <ImageBrush ImageSource="../Images/ColorCircle.png" />
                 </Ellipse.Fill>
                 </Ellipse.Fill>
             </Ellipse>
             </Ellipse>
         </Grid>
         </Grid>
         <ControlTemplate.Triggers>
         <ControlTemplate.Triggers>
             <Trigger Property="IsEnabled" Value="false">
             <Trigger Property="IsEnabled" Value="false">
-                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
-                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
+                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}" />
+                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
             </Trigger>
             </Trigger>
         </ControlTemplate.Triggers>
         </ControlTemplate.Triggers>
     </ControlTemplate>
     </ControlTemplate>
@@ -44,98 +45,112 @@
         <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
         <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
             <Ellipse x:Name="grip" Width="12" Height="12" ClipToBounds="False">
             <Ellipse x:Name="grip" Width="12" Height="12" ClipToBounds="False">
                 <Ellipse.Fill>
                 <Ellipse.Fill>
-                    <ImageBrush ImageSource="../Images/ColorCircle.png"/>
+                    <ImageBrush ImageSource="../Images/ColorCircle.png" />
                 </Ellipse.Fill>
                 </Ellipse.Fill>
             </Ellipse>
             </Ellipse>
         </Grid>
         </Grid>
         <ControlTemplate.Triggers>
         <ControlTemplate.Triggers>
             <Trigger Property="IsMouseOver" Value="true">
             <Trigger Property="IsMouseOver" Value="true">
-                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
-                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
+                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
+                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
             </Trigger>
             </Trigger>
             <Trigger Property="IsDragging" Value="true">
             <Trigger Property="IsDragging" Value="true">
-                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
-                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
+                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}" />
+                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}" />
             </Trigger>
             </Trigger>
             <Trigger Property="IsEnabled" Value="false">
             <Trigger Property="IsEnabled" Value="false">
-                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
-                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
+                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}" />
+                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
             </Trigger>
             </Trigger>
         </ControlTemplate.Triggers>
         </ControlTemplate.Triggers>
     </ControlTemplate>
     </ControlTemplate>
     <ControlTemplate x:Key="SliderThumbHorizontalBottom" TargetType="{x:Type Thumb}">
     <ControlTemplate x:Key="SliderThumbHorizontalBottom" TargetType="{x:Type Thumb}">
         <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
         <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
-            <Path x:Name="grip" Data="M -1,0 A 1,1 0 1 1 1,0 M -1,0 A 1,1 0 1 0 1,0" Fill="{StaticResource SliderThumb.Static.Background}" SnapsToDevicePixels="True" StrokeThickness="1" Stretch="Fill" Stroke="{StaticResource SliderThumb.Static.Border}" UseLayoutRounding="True" VerticalAlignment="Center"/>
+            <Path x:Name="grip" Data="M -1,0 A 1,1 0 1 1 1,0 M -1,0 A 1,1 0 1 0 1,0"
+                  Fill="{StaticResource SliderThumb.Static.Background}" SnapsToDevicePixels="True" StrokeThickness="1"
+                  Stretch="Fill" Stroke="{StaticResource SliderThumb.Static.Border}" UseLayoutRounding="True"
+                  VerticalAlignment="Center" />
         </Grid>
         </Grid>
         <ControlTemplate.Triggers>
         <ControlTemplate.Triggers>
             <Trigger Property="IsMouseOver" Value="true">
             <Trigger Property="IsMouseOver" Value="true">
-                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}"/>
-                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}"/>
+                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Background}" />
+                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.MouseOver.Border}" />
             </Trigger>
             </Trigger>
             <Trigger Property="IsDragging" Value="true">
             <Trigger Property="IsDragging" Value="true">
-                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}"/>
-                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}"/>
+                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Background}" />
+                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Pressed.Border}" />
             </Trigger>
             </Trigger>
             <Trigger Property="IsEnabled" Value="false">
             <Trigger Property="IsEnabled" Value="false">
-                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}"/>
-                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}"/>
+                <Setter Property="Fill" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Background}" />
+                <Setter Property="Stroke" TargetName="grip" Value="{StaticResource SliderThumb.Disabled.Border}" />
             </Trigger>
             </Trigger>
         </ControlTemplate.Triggers>
         </ControlTemplate.Triggers>
     </ControlTemplate>
     </ControlTemplate>
     <ControlTemplate x:Key="RgbColorSliderTemplate1" TargetType="{x:Type Slider}">
     <ControlTemplate x:Key="RgbColorSliderTemplate1" TargetType="{x:Type Slider}">
-        <Border x:Name="border" CornerRadius="5" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="True">
+        <Border x:Name="border" CornerRadius="5" Background="{TemplateBinding Background}"
+                BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
+                SnapsToDevicePixels="True">
             <Grid>
             <Grid>
                 <Grid.RowDefinitions>
                 <Grid.RowDefinitions>
-                    <RowDefinition Height="Auto"/>
-                    <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
-                    <RowDefinition Height="Auto"/>
+                    <RowDefinition Height="Auto" />
+                    <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
+                    <RowDefinition Height="Auto" />
                 </Grid.RowDefinitions>
                 </Grid.RowDefinitions>
-                <TickBar x:Name="TopTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,0,0,2" Placement="Top" Grid.Row="0" Visibility="Collapsed"/>
-                <TickBar x:Name="BottomTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,2,0,0" Placement="Bottom" Grid.Row="2" Visibility="Collapsed"/>
-                <Border x:Name="TrackBackground" Background="Transparent" BorderThickness="0" Height="0" Margin="5,0" Grid.Row="1" VerticalAlignment="center">
+                <TickBar x:Name="TopTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,0,0,2"
+                         Placement="Top" Grid.Row="0" Visibility="Collapsed" />
+                <TickBar x:Name="BottomTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,2,0,0"
+                         Placement="Bottom" Grid.Row="2" Visibility="Collapsed" />
+                <Border x:Name="TrackBackground" Background="Transparent" BorderThickness="0" Height="0" Margin="5,0"
+                        Grid.Row="1" VerticalAlignment="center">
                     <Canvas Margin="-6,-1">
                     <Canvas Margin="-6,-1">
-                        <Rectangle x:Name="PART_SelectionRange" Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Height="4.0" Visibility="Hidden"/>
+                        <Rectangle x:Name="PART_SelectionRange"
+                                   Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Height="4.0"
+                                   Visibility="Hidden" />
                     </Canvas>
                     </Canvas>
                 </Border>
                 </Border>
                 <Track x:Name="PART_Track" Grid.Row="1">
                 <Track x:Name="PART_Track" Grid.Row="1">
                     <Track.DecreaseRepeatButton>
                     <Track.DecreaseRepeatButton>
-                        <RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
+                        <RepeatButton Command="{x:Static Slider.DecreaseLarge}"
+                                      Style="{StaticResource RepeatButtonTransparent}" />
                     </Track.DecreaseRepeatButton>
                     </Track.DecreaseRepeatButton>
                     <Track.IncreaseRepeatButton>
                     <Track.IncreaseRepeatButton>
-                        <RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
+                        <RepeatButton Command="{x:Static Slider.IncreaseLarge}"
+                                      Style="{StaticResource RepeatButtonTransparent}" />
                     </Track.IncreaseRepeatButton>
                     </Track.IncreaseRepeatButton>
                     <Track.Thumb>
                     <Track.Thumb>
-                        <Thumb x:Name="Thumb" Focusable="False" Height="12" OverridesDefaultStyle="True" Template="{StaticResource SliderThumbHorizontalDefault}" VerticalAlignment="Center" Width="12"/>
+                        <Thumb x:Name="Thumb" Focusable="False" Height="12" OverridesDefaultStyle="True"
+                               Template="{StaticResource SliderThumbHorizontalDefault}" VerticalAlignment="Center"
+                               Width="12" />
                     </Track.Thumb>
                     </Track.Thumb>
                 </Track>
                 </Track>
             </Grid>
             </Grid>
         </Border>
         </Border>
         <ControlTemplate.Triggers>
         <ControlTemplate.Triggers>
             <Trigger Property="TickPlacement" Value="TopLeft">
             <Trigger Property="TickPlacement" Value="TopLeft">
-                <Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
-                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalTop}"/>
-                <Setter Property="Margin" TargetName="TrackBackground" Value="5,2,5,0"/>
+                <Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
+                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalTop}" />
+                <Setter Property="Margin" TargetName="TrackBackground" Value="5,2,5,0" />
             </Trigger>
             </Trigger>
             <Trigger Property="TickPlacement" Value="BottomRight">
             <Trigger Property="TickPlacement" Value="BottomRight">
-                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
-                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalBottom}"/>
-                <Setter Property="Margin" TargetName="TrackBackground" Value="5,0,5,2"/>
+                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
+                <Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalBottom}" />
+                <Setter Property="Margin" TargetName="TrackBackground" Value="5,0,5,2" />
             </Trigger>
             </Trigger>
             <Trigger Property="TickPlacement" Value="Both">
             <Trigger Property="TickPlacement" Value="Both">
-                <Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
-                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
+                <Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
+                <Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
             </Trigger>
             </Trigger>
             <Trigger Property="IsSelectionRangeEnabled" Value="true">
             <Trigger Property="IsSelectionRangeEnabled" Value="true">
-                <Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible"/>
+                <Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible" />
             </Trigger>
             </Trigger>
             <Trigger Property="IsKeyboardFocused" Value="true">
             <Trigger Property="IsKeyboardFocused" Value="true">
-                <Setter Property="Foreground" TargetName="Thumb" Value="Blue"/>
+                <Setter Property="Foreground" TargetName="Thumb" Value="Blue" />
             </Trigger>
             </Trigger>
         </ControlTemplate.Triggers>
         </ControlTemplate.Triggers>
     </ControlTemplate>
     </ControlTemplate>
 
 
     <Style TargetType="{x:Type local:RgbColorSlider}">
     <Style TargetType="{x:Type local:RgbColorSlider}">
-        <Setter Property="Template" Value="{StaticResource RgbColorSliderTemplate1}"/>
+        <Setter Property="Template" Value="{StaticResource RgbColorSliderTemplate1}" />
     </Style>
     </Style>
-    
+
 </ResourceDictionary>
 </ResourceDictionary>

+ 3 - 3
PixiEditor/Styles/ColorToggleButton.xaml

@@ -2,16 +2,16 @@
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
 
     <Style TargetType="ToggleButton" x:Key="ColorToggleButtonStyle">
     <Style TargetType="ToggleButton" x:Key="ColorToggleButtonStyle">
-        <Setter Property="OverridesDefaultStyle" Value="True"/>
+        <Setter Property="OverridesDefaultStyle" Value="True" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="ToggleButton">
                 <ControlTemplate TargetType="ToggleButton">
                     <Border BorderThickness="0" Background="{TemplateBinding Background}">
                     <Border BorderThickness="0" Background="{TemplateBinding Background}">
-                        <ContentPresenter Content="{TemplateBinding Content}"/>
+                        <ContentPresenter Content="{TemplateBinding Content}" />
                     </Border>
                     </Border>
                 </ControlTemplate>
                 </ControlTemplate>
             </Setter.Value>
             </Setter.Value>
         </Setter>
         </Setter>
     </Style>
     </Style>
-    
+
 </ResourceDictionary>
 </ResourceDictionary>

+ 185 - 105
PixiEditor/Styles/ComboBoxDarkStyle.xaml

@@ -1,124 +1,177 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:local="clr-namespace:PixiEditor"
                     xmlns:local="clr-namespace:PixiEditor"
-    xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2">
+                    xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2">
 
 
-    <SolidColorBrush x:Key="ComboBox.Static.Background" Color="#333333"/>
-    <SolidColorBrush x:Key="ComboBox.Static.Border" Color="#2F2F37"/>
-    <SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF606060"/>
-    <SolidColorBrush x:Key="ComboBox.Static.Editable.Background" Color="#333333"/>
-    <SolidColorBrush x:Key="ComboBox.Static.Editable.Border" Color="#2F2F37"/>
-    <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Background" Color="Transparent"/>
-    <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Border" Color="Transparent"/>
-    <SolidColorBrush x:Key="ComboBox.MouseOver.Background" Color="#333333"/>
-    <SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#007ACC"/>
-    <SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#007ACC"/>
-    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#333333"/>
-    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#007ACC"/>
-    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" Color="#333333"/>
-    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/>
-    <SolidColorBrush x:Key="ComboBox.Pressed.Background" Color="#333333"/>
-    <SolidColorBrush x:Key="ComboBox.Pressed.Border" Color="#007ACC"/>
-    <SolidColorBrush x:Key="ComboBox.Pressed.Glyph" Color="#007ACC"/>
-    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Background" Color="#202020"/>
-    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Border" Color="#007ACC"/>
-    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Button.Background" Color="#007ACC"/>
-    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Button.Border" Color="#FF569DE5"/>
-    <SolidColorBrush x:Key="ComboBox.Disabled.Background" Color="#FFF0F0F0"/>
-    <SolidColorBrush x:Key="ComboBox.Disabled.Border" Color="#FFD9D9D9"/>
-    <SolidColorBrush x:Key="ComboBox.Disabled.Glyph" Color="#FFBFBFBF"/>
-    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Background" Color="#FFFFFFFF"/>
-    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Border" Color="#FFBFBFBF"/>
-    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Background" Color="Transparent"/>
-    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Border" Color="Transparent"/>
+    <SolidColorBrush x:Key="ComboBox.Static.Background" Color="#333333" />
+    <SolidColorBrush x:Key="ComboBox.Static.Border" Color="#2F2F37" />
+    <SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF606060" />
+    <SolidColorBrush x:Key="ComboBox.Static.Editable.Background" Color="#333333" />
+    <SolidColorBrush x:Key="ComboBox.Static.Editable.Border" Color="#2F2F37" />
+    <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Background" Color="Transparent" />
+    <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Border" Color="Transparent" />
+    <SolidColorBrush x:Key="ComboBox.MouseOver.Background" Color="#333333" />
+    <SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#007ACC" />
+    <SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#007ACC" />
+    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#333333" />
+    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#007ACC" />
+    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" Color="#333333" />
+    <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA" />
+    <SolidColorBrush x:Key="ComboBox.Pressed.Background" Color="#333333" />
+    <SolidColorBrush x:Key="ComboBox.Pressed.Border" Color="#007ACC" />
+    <SolidColorBrush x:Key="ComboBox.Pressed.Glyph" Color="#007ACC" />
+    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Background" Color="#202020" />
+    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Border" Color="#007ACC" />
+    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Button.Background" Color="#007ACC" />
+    <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Button.Border" Color="#FF569DE5" />
+    <SolidColorBrush x:Key="ComboBox.Disabled.Background" Color="#FFF0F0F0" />
+    <SolidColorBrush x:Key="ComboBox.Disabled.Border" Color="#FFD9D9D9" />
+    <SolidColorBrush x:Key="ComboBox.Disabled.Glyph" Color="#FFBFBFBF" />
+    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Background" Color="#FFFFFFFF" />
+    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Border" Color="#FFBFBFBF" />
+    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Background" Color="Transparent" />
+    <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Border" Color="Transparent" />
     <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
     <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
-        <Setter Property="OverridesDefaultStyle" Value="true"/>
-        <Setter Property="IsTabStop" Value="false"/>
-        <Setter Property="Focusable" Value="false"/>
-        <Setter Property="ClickMode" Value="Press"/>
+        <Setter Property="OverridesDefaultStyle" Value="true" />
+        <Setter Property="IsTabStop" Value="false" />
+        <Setter Property="Focusable" Value="false" />
+        <Setter Property="ClickMode" Value="Press" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type ToggleButton}">
                 <ControlTemplate TargetType="{x:Type ToggleButton}">
-                    <Border x:Name="templateRoot" Background="{StaticResource ComboBox.Static.Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{StaticResource ComboBox.Static.Border}" SnapsToDevicePixels="true">
-                        <Border x:Name="splitBorder" BorderThickness="1" BorderBrush="Transparent" HorizontalAlignment="Right" Margin="0" SnapsToDevicePixels="true" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
-                            <Path x:Name="arrow" Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z" Fill="{StaticResource ComboBox.Static.Glyph}" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center"/>
+                    <Border x:Name="templateRoot" Background="{StaticResource ComboBox.Static.Background}"
+                            BorderThickness="{TemplateBinding BorderThickness}"
+                            BorderBrush="{StaticResource ComboBox.Static.Border}" SnapsToDevicePixels="true">
+                        <Border x:Name="splitBorder" BorderThickness="1" BorderBrush="Transparent"
+                                HorizontalAlignment="Right" Margin="0" SnapsToDevicePixels="true"
+                                Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
+                            <Path x:Name="arrow"
+                                  Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"
+                                  Fill="{StaticResource ComboBox.Static.Glyph}" HorizontalAlignment="Center" Margin="0"
+                                  VerticalAlignment="Center" />
                         </Border>
                         </Border>
                     </Border>
                     </Border>
                     <ControlTemplate.Triggers>
                     <ControlTemplate.Triggers>
                         <MultiDataTrigger>
                         <MultiDataTrigger>
                             <MultiDataTrigger.Conditions>
                             <MultiDataTrigger.Conditions>
-                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
-                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="false"/>
-                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="false"/>
-                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="true"/>
+                                <Condition
+                                    Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
+                                    Value="true" />
+                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
+                                           Value="false" />
+                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}"
+                                           Value="false" />
+                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}"
+                                           Value="true" />
                             </MultiDataTrigger.Conditions>
                             </MultiDataTrigger.Conditions>
-                            <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Border}"/>
-                            <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Border}"/>
+                            <Setter Property="Background" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Static.Editable.Background}" />
+                            <Setter Property="BorderBrush" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Static.Editable.Border}" />
+                            <Setter Property="Background" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.Static.Editable.Button.Background}" />
+                            <Setter Property="BorderBrush" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.Static.Editable.Button.Border}" />
                         </MultiDataTrigger>
                         </MultiDataTrigger>
                         <Trigger Property="IsMouseOver" Value="true">
                         <Trigger Property="IsMouseOver" Value="true">
-                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.MouseOver.Glyph}"/>
+                            <Setter Property="Fill" TargetName="arrow"
+                                    Value="{StaticResource ComboBox.MouseOver.Glyph}" />
                         </Trigger>
                         </Trigger>
                         <MultiDataTrigger>
                         <MultiDataTrigger>
                             <MultiDataTrigger.Conditions>
                             <MultiDataTrigger.Conditions>
-                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
-                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
+                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
+                                           Value="true" />
+                                <Condition
+                                    Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
+                                    Value="false" />
                             </MultiDataTrigger.Conditions>
                             </MultiDataTrigger.Conditions>
-                            <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Border}"/>
+                            <Setter Property="Background" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.MouseOver.Background}" />
+                            <Setter Property="BorderBrush" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.MouseOver.Border}" />
                         </MultiDataTrigger>
                         </MultiDataTrigger>
                         <MultiDataTrigger>
                         <MultiDataTrigger>
                             <MultiDataTrigger.Conditions>
                             <MultiDataTrigger.Conditions>
-                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
-                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
+                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
+                                           Value="true" />
+                                <Condition
+                                    Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
+                                    Value="true" />
                             </MultiDataTrigger.Conditions>
                             </MultiDataTrigger.Conditions>
-                            <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Border}"/>
-                            <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Border}"/>
+                            <Setter Property="Background" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.MouseOver.Editable.Background}" />
+                            <Setter Property="BorderBrush" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.MouseOver.Editable.Border}" />
+                            <Setter Property="Background" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.MouseOver.Editable.Button.Background}" />
+                            <Setter Property="BorderBrush" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.MouseOver.Editable.Button.Border}" />
                         </MultiDataTrigger>
                         </MultiDataTrigger>
                         <Trigger Property="IsPressed" Value="true">
                         <Trigger Property="IsPressed" Value="true">
-                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Pressed.Glyph}"/>
+                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Pressed.Glyph}" />
                         </Trigger>
                         </Trigger>
                         <MultiDataTrigger>
                         <MultiDataTrigger>
                             <MultiDataTrigger.Conditions>
                             <MultiDataTrigger.Conditions>
-                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
-                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
+                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}"
+                                           Value="true" />
+                                <Condition
+                                    Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
+                                    Value="false" />
                             </MultiDataTrigger.Conditions>
                             </MultiDataTrigger.Conditions>
-                            <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Border}"/>
+                            <Setter Property="Background" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Pressed.Background}" />
+                            <Setter Property="BorderBrush" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Pressed.Border}" />
                         </MultiDataTrigger>
                         </MultiDataTrigger>
                         <MultiDataTrigger>
                         <MultiDataTrigger>
                             <MultiDataTrigger.Conditions>
                             <MultiDataTrigger.Conditions>
-                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
-                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
+                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}"
+                                           Value="true" />
+                                <Condition
+                                    Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
+                                    Value="true" />
                             </MultiDataTrigger.Conditions>
                             </MultiDataTrigger.Conditions>
-                            <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Border}"/>
-                            <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Border}"/>
+                            <Setter Property="Background" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Pressed.Editable.Background}" />
+                            <Setter Property="BorderBrush" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Pressed.Editable.Border}" />
+                            <Setter Property="Background" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.Pressed.Editable.Button.Background}" />
+                            <Setter Property="BorderBrush" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.Pressed.Editable.Button.Border}" />
                         </MultiDataTrigger>
                         </MultiDataTrigger>
                         <Trigger Property="IsEnabled" Value="false">
                         <Trigger Property="IsEnabled" Value="false">
-                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Disabled.Glyph}"/>
+                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Disabled.Glyph}" />
                         </Trigger>
                         </Trigger>
                         <MultiDataTrigger>
                         <MultiDataTrigger>
                             <MultiDataTrigger.Conditions>
                             <MultiDataTrigger.Conditions>
-                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
-                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
+                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}"
+                                           Value="false" />
+                                <Condition
+                                    Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
+                                    Value="false" />
                             </MultiDataTrigger.Conditions>
                             </MultiDataTrigger.Conditions>
-                            <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Border}"/>
+                            <Setter Property="Background" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Disabled.Background}" />
+                            <Setter Property="BorderBrush" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Disabled.Border}" />
                         </MultiDataTrigger>
                         </MultiDataTrigger>
                         <MultiDataTrigger>
                         <MultiDataTrigger>
                             <MultiDataTrigger.Conditions>
                             <MultiDataTrigger.Conditions>
-                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
-                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
+                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}"
+                                           Value="false" />
+                                <Condition
+                                    Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
+                                    Value="true" />
                             </MultiDataTrigger.Conditions>
                             </MultiDataTrigger.Conditions>
-                            <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Border}"/>
-                            <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Border}"/>
+                            <Setter Property="Background" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Disabled.Editable.Background}" />
+                            <Setter Property="BorderBrush" TargetName="templateRoot"
+                                    Value="{StaticResource ComboBox.Disabled.Editable.Border}" />
+                            <Setter Property="Background" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.Disabled.Editable.Button.Background}" />
+                            <Setter Property="BorderBrush" TargetName="splitBorder"
+                                    Value="{StaticResource ComboBox.Disabled.Editable.Button.Border}" />
                         </MultiDataTrigger>
                         </MultiDataTrigger>
                     </ControlTemplate.Triggers>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
                 </ControlTemplate>
@@ -128,70 +181,97 @@
     <ControlTemplate x:Key="DarkComboBox" TargetType="{x:Type ComboBox}">
     <ControlTemplate x:Key="DarkComboBox" TargetType="{x:Type ComboBox}">
         <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
         <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
             <Grid.ColumnDefinitions>
             <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="*"/>
-                <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
+                <ColumnDefinition Width="*" />
+                <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
+                                  Width="0" />
             </Grid.ColumnDefinitions>
             </Grid.ColumnDefinitions>
-            <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Bottom">
-                <theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
-                    <Border x:Name="dropDownBorder" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}">
+            <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2"
+                   IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
+                   Margin="1" Placement="Bottom">
+                <theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent"
+                                              MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
+                                              MaxHeight="{TemplateBinding MaxDropDownHeight}">
+                    <Border x:Name="dropDownBorder"
+                            Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderThickness="1"
+                            BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}">
                         <ScrollViewer x:Name="DropDownScrollViewer">
                         <ScrollViewer x:Name="DropDownScrollViewer">
                             <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
                             <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
-                                <Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
-                                    <Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
+                                <Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top"
+                                        Width="0">
+                                    <Rectangle x:Name="opaqueRect"
+                                               Fill="{Binding Background, ElementName=dropDownBorder}"
+                                               Height="{Binding ActualHeight, ElementName=dropDownBorder}"
+                                               Width="{Binding ActualWidth, ElementName=dropDownBorder}" />
                                 </Canvas>
                                 </Canvas>
-                                <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
+                                <ItemsPresenter x:Name="ItemsPresenter"
+                                                KeyboardNavigation.DirectionalNavigation="Contained"
+                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                             </Grid>
                             </Grid>
                         </ScrollViewer>
                         </ScrollViewer>
                     </Border>
                     </Border>
                 </theme:SystemDropShadowChrome>
                 </theme:SystemDropShadowChrome>
             </Popup>
             </Popup>
-            <ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/>
-            <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+            <ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}"
+                          BorderThickness="{TemplateBinding BorderThickness}"
+                          BorderBrush="{TemplateBinding BorderBrush}" Grid.ColumnSpan="2"
+                          IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
+                          Style="{StaticResource ComboBoxToggleButton}" />
+            <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
+                              Content="{TemplateBinding SelectionBoxItem}"
+                              ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
+                              ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
+                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                              IsHitTestVisible="false" Margin="{TemplateBinding Padding}"
+                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
+                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
         </Grid>
         </Grid>
         <ControlTemplate.Triggers>
         <ControlTemplate.Triggers>
             <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
             <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
-                <Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/>
-                <Setter Property="Color" TargetName="shadow" Value="#71000000"/>
+                <Setter Property="Margin" TargetName="shadow" Value="0,0,5,5" />
+                <Setter Property="Color" TargetName="shadow" Value="#71000000" />
             </Trigger>
             </Trigger>
             <Trigger Property="HasItems" Value="false">
             <Trigger Property="HasItems" Value="false">
-                <Setter Property="Height" TargetName="dropDownBorder" Value="95"/>
+                <Setter Property="Height" TargetName="dropDownBorder" Value="95" />
             </Trigger>
             </Trigger>
             <MultiTrigger>
             <MultiTrigger>
                 <MultiTrigger.Conditions>
                 <MultiTrigger.Conditions>
-                    <Condition Property="IsGrouping" Value="true"/>
-                    <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
+                    <Condition Property="IsGrouping" Value="true" />
+                    <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
                 </MultiTrigger.Conditions>
                 </MultiTrigger.Conditions>
-                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
+                <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
             </MultiTrigger>
             </MultiTrigger>
             <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
             <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
-                <Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
-                <Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
+                <Setter Property="Canvas.Top" TargetName="opaqueRect"
+                        Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
+                <Setter Property="Canvas.Left" TargetName="opaqueRect"
+                        Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
             </Trigger>
             </Trigger>
         </ControlTemplate.Triggers>
         </ControlTemplate.Triggers>
     </ControlTemplate>
     </ControlTemplate>
 
 
     <Style TargetType="ComboBox">
     <Style TargetType="ComboBox">
-        <Setter Property="Foreground" Value="White"/>
-        <Setter Property="Template" Value="{DynamicResource DarkComboBox}"/>
+        <Setter Property="Foreground" Value="White" />
+        <Setter Property="Template" Value="{DynamicResource DarkComboBox}" />
     </Style>
     </Style>
 
 
     <Style TargetType="ComboBoxItem">
     <Style TargetType="ComboBoxItem">
-        <Setter Property="Background" Value="#111111"/>
-        <Setter Property="Foreground" Value="White"/>
-        <Setter Property="BorderThickness" Value="0"/>
-        <Setter Property="OverridesDefaultStyle" Value="True"/>
+        <Setter Property="Background" Value="#111111" />
+        <Setter Property="Foreground" Value="White" />
+        <Setter Property="BorderThickness" Value="0" />
+        <Setter Property="OverridesDefaultStyle" Value="True" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="ComboBoxItem">
                 <ControlTemplate TargetType="ComboBoxItem">
                     <Border Name="Bd" Background="{TemplateBinding Background}" BorderThickness="0">
                     <Border Name="Bd" Background="{TemplateBinding Background}" BorderThickness="0">
-                        <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                        <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center"
+                                          VerticalAlignment="Center" />
                     </Border>
                     </Border>
                     <ControlTemplate.Triggers>
                     <ControlTemplate.Triggers>
-                        <Trigger Property="IsHighlighted"  Value="True">
-                            <Setter Property="Background" TargetName="Bd" Value="Gray"/>
+                        <Trigger Property="IsHighlighted" Value="True">
+                            <Setter Property="Background" TargetName="Bd" Value="Gray" />
                         </Trigger>
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="False">
                         <Trigger Property="IsEnabled" Value="False">
-                            <Setter Property="Foreground" Value="Gray"/>
+                            <Setter Property="Foreground" Value="Gray" />
                         </Trigger>
                         </Trigger>
                     </ControlTemplate.Triggers>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
                 </ControlTemplate>

+ 5 - 5
PixiEditor/Styles/DockingManagerStyle.xaml

@@ -1,13 +1,13 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
                     xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-    xmlns:avalonDock="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
-    xmlns:avalonDockControls="clr-namespace:Xceed.Wpf.AvalonDock.Controls;assembly=Xceed.Wpf.AvalonDock"
-    xmlns:avalonDockConverters="clr-namespace:Xceed.Wpf.AvalonDock.Converters;assembly=Xceed.Wpf.AvalonDock">
+                    xmlns:avalonDock="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
+                    xmlns:avalonDockControls="clr-namespace:Xceed.Wpf.AvalonDock.Controls;assembly=Xceed.Wpf.AvalonDock"
+                    xmlns:avalonDockConverters="clr-namespace:Xceed.Wpf.AvalonDock.Converters;assembly=Xceed.Wpf.AvalonDock">
 
 
     <Style TargetType="xcad:DockingManager">
     <Style TargetType="xcad:DockingManager">
-        <Setter Property="Foreground" Value="Snow"/>
-        <Setter Property="Background" Value="{StaticResource AccentColor}"/>
+        <Setter Property="Foreground" Value="Snow" />
+        <Setter Property="Background" Value="{StaticResource AccentColor}" />
     </Style>
     </Style>
 
 
 </ResourceDictionary>
 </ResourceDictionary>

+ 63 - 50
PixiEditor/Styles/MenuButtonStyle.xaml

@@ -2,11 +2,11 @@
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
 
     <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
     <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
-       TargetType="{x:Type Separator}">
+           TargetType="{x:Type Separator}">
         <Setter Property="Height"
         <Setter Property="Height"
-          Value="1" />
+                Value="1" />
         <Setter Property="Margin"
         <Setter Property="Margin"
-          Value="0,4,0,4" />
+                Value="0,4,0,4" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type Separator}">
                 <ControlTemplate TargetType="{x:Type Separator}">
@@ -21,56 +21,69 @@
     </Style>
     </Style>
 
 
     <Style x:Key="menuItemStyle" TargetType="{x:Type MenuItem}">
     <Style x:Key="menuItemStyle" TargetType="{x:Type MenuItem}">
-        <Setter Property="Foreground" Value="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Menu}}}"/>
-        <Setter Property="FontSize" Value="12"/>
+        <Setter Property="Foreground"
+                Value="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Menu}}}" />
+        <Setter Property="FontSize" Value="12" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type MenuItem}">
                 <ControlTemplate TargetType="{x:Type MenuItem}">
                     <Border x:Name="Border" Padding="2.5"
                     <Border x:Name="Border" Padding="2.5"
-                        Background="Transparent"
-                        BorderBrush="{TemplateBinding BorderBrush}"
-                        BorderThickness="0">
+                            Background="Transparent"
+                            BorderBrush="{TemplateBinding BorderBrush}"
+                            BorderThickness="0">
                         <Grid>
                         <Grid>
                             <Grid.ColumnDefinitions>
                             <Grid.ColumnDefinitions>
-                                <ColumnDefinition x:Name="Col0" MinWidth="17" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup"/>
-                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuTextColumnGroup"/>
-                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup"/>
-                                <ColumnDefinition x:Name="Col3" Width="14"/>
+                                <ColumnDefinition x:Name="Col0" MinWidth="17" Width="Auto"
+                                                  SharedSizeGroup="MenuItemIconColumnGroup" />
+                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuTextColumnGroup" />
+                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
+                                <ColumnDefinition x:Name="Col3" Width="14" />
                             </Grid.ColumnDefinitions>
                             </Grid.ColumnDefinitions>
 
 
                             <!-- ContentPresenter to show an Icon if needed -->
                             <!-- ContentPresenter to show an Icon if needed -->
-                            <ContentPresenter Grid.Column="0" Margin="4,0,6,0" x:Name="Icon" VerticalAlignment="Center" ContentSource="Icon"/>
+                            <ContentPresenter Grid.Column="0" Margin="4,0,6,0" x:Name="Icon" VerticalAlignment="Center"
+                                              ContentSource="Icon" />
 
 
                             <!-- Glyph is a checkmark if needed for a checkable menu -->
                             <!-- Glyph is a checkmark if needed for a checkable menu -->
-                            <Grid Grid.Column="0" Visibility="Hidden" Margin="4,0,6,0" x:Name="GlyphPanel" VerticalAlignment="Center">
-                                <Path x:Name="GlyphPanelpath" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z" FlowDirection="LeftToRight"/>
+                            <Grid Grid.Column="0" Visibility="Hidden" Margin="4,0,6,0" x:Name="GlyphPanel"
+                                  VerticalAlignment="Center">
+                                <Path x:Name="GlyphPanelpath" VerticalAlignment="Center"
+                                      Fill="{TemplateBinding Foreground}"
+                                      Data="M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z"
+                                      FlowDirection="LeftToRight" />
                             </Grid>
                             </Grid>
 
 
                             <!-- Content for the menu text etc -->
                             <!-- Content for the menu text etc -->
                             <ContentPresenter Grid.Column="1"
                             <ContentPresenter Grid.Column="1"
-                                          Margin="{TemplateBinding Padding}"                                          
-                                          x:Name="HeaderHost"
-                                          RecognizesAccessKey="True"                                              
-                                          ContentSource="Header"/>
+                                              Margin="{TemplateBinding Padding}"
+                                              x:Name="HeaderHost"
+                                              RecognizesAccessKey="True"
+                                              ContentSource="Header" />
 
 
                             <!-- Content for the menu IGT -->
                             <!-- Content for the menu IGT -->
                             <ContentPresenter Grid.Column="2"
                             <ContentPresenter Grid.Column="2"
-                                          Margin="8,1,8,1"
-                                          x:Name="IGTHost"
-                                          ContentSource="InputGestureText"
-                                          VerticalAlignment="Center"/>
+                                              Margin="8,1,8,1"
+                                              x:Name="IGTHost"
+                                              ContentSource="InputGestureText"
+                                              VerticalAlignment="Center" />
 
 
                             <!-- Arrow drawn path which points to the next level of the menu -->
                             <!-- Arrow drawn path which points to the next level of the menu -->
                             <Grid Grid.Column="3" Margin="4,0,6,0" x:Name="ArrowPanel" VerticalAlignment="Center">
                             <Grid Grid.Column="3" Margin="4,0,6,0" x:Name="ArrowPanel" VerticalAlignment="Center">
-                                <Path x:Name="ArrowPanelPath" HorizontalAlignment="Right" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="M0,0 L0,8 L4,4 z"/>
+                                <Path x:Name="ArrowPanelPath" HorizontalAlignment="Right" VerticalAlignment="Center"
+                                      Fill="{TemplateBinding Foreground}" Data="M0,0 L0,8 L4,4 z" />
                             </Grid>
                             </Grid>
 
 
                             <!-- The Popup is the body of the menu which expands down or across depending on the level of the item -->
                             <!-- The Popup is the body of the menu which expands down or across depending on the level of the item -->
-                            <Popup IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" x:Name="SubMenuPopup" Focusable="false" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
-                                <Border x:Name="SubMenuBorder" Background="#202020" BorderBrush="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Menu}}}" BorderThickness="1" Padding="2,2,2,2">
+                            <Popup
+                                IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
+                                Placement="Right" x:Name="SubMenuPopup" Focusable="false"
+                                PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
+                                <Border x:Name="SubMenuBorder" Background="#202020"
+                                        BorderBrush="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Menu}}}"
+                                        BorderThickness="1" Padding="2,2,2,2">
                                     <Grid x:Name="SubMenu" Grid.IsSharedSizeScope="True">
                                     <Grid x:Name="SubMenu" Grid.IsSharedSizeScope="True">
                                         <!-- StackPanel holds children of the menu. This is set by IsItemsHost=True -->
                                         <!-- StackPanel holds children of the menu. This is set by IsItemsHost=True -->
-                                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
+                                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                                     </Grid>
                                     </Grid>
                                 </Border>
                                 </Border>
                             </Popup>
                             </Popup>
@@ -81,59 +94,59 @@
                     <ControlTemplate.Triggers>
                     <ControlTemplate.Triggers>
                         <!-- Role = TopLevelHeader : this is the root menu item in a menu; the Popup expands down -->
                         <!-- Role = TopLevelHeader : this is the root menu item in a menu; the Popup expands down -->
                         <Trigger Property="Role" Value="TopLevelHeader">
                         <Trigger Property="Role" Value="TopLevelHeader">
-                            <Setter Property="Padding" Value="6,1,6,1"/>
-                            <Setter Property="Placement" Value="Bottom" TargetName="SubMenuPopup"/>
-                            <Setter Property="MinWidth" Value="0" TargetName="Col0"/>
-                            <Setter Property="Width" Value="Auto" TargetName="Col3"/>
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="GlyphPanel"/>
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="IGTHost"/>
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
+                            <Setter Property="Padding" Value="6,1,6,1" />
+                            <Setter Property="Placement" Value="Bottom" TargetName="SubMenuPopup" />
+                            <Setter Property="MinWidth" Value="0" TargetName="Col0" />
+                            <Setter Property="Width" Value="Auto" TargetName="Col3" />
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="Icon" />
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="GlyphPanel" />
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="IGTHost" />
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel" />
                         </Trigger>
                         </Trigger>
 
 
                         <!-- Role = TopLevelItem :  this is a child menu item from the top level without any child items-->
                         <!-- Role = TopLevelItem :  this is a child menu item from the top level without any child items-->
                         <Trigger Property="Role" Value="TopLevelItem">
                         <Trigger Property="Role" Value="TopLevelItem">
-                            <Setter Property="Padding" Value="6,1,6,1"/>
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
+                            <Setter Property="Padding" Value="6,1,6,1" />
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel" />
                         </Trigger>
                         </Trigger>
 
 
                         <!-- Role = SubMenuHeader : this is a child menu item which does not have children -->
                         <!-- Role = SubMenuHeader : this is a child menu item which does not have children -->
                         <Trigger Property="Role" Value="SubmenuHeader">
                         <Trigger Property="Role" Value="SubmenuHeader">
-                            <Setter Property="DockPanel.Dock" Value="Top"/>
-                            <Setter Property="Padding" Value="0,2,0,2"/>
+                            <Setter Property="DockPanel.Dock" Value="Top" />
+                            <Setter Property="Padding" Value="0,2,0,2" />
                         </Trigger>
                         </Trigger>
 
 
                         <!-- Role = SubMenuItem : this is a child menu item which has children-->
                         <!-- Role = SubMenuItem : this is a child menu item which has children-->
                         <Trigger Property="Role" Value="SubmenuItem">
                         <Trigger Property="Role" Value="SubmenuItem">
-                            <Setter Property="DockPanel.Dock" Value="Top"/>
-                            <Setter Property="Padding" Value="0,2,0,2"/>
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
+                            <Setter Property="DockPanel.Dock" Value="Top" />
+                            <Setter Property="Padding" Value="0,2,0,2" />
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel" />
                         </Trigger>
                         </Trigger>
                         <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                         <Trigger Property="IsSuspendingPopupAnimation" Value="true">
-                            <Setter Property="PopupAnimation" Value="None" TargetName="SubMenuPopup"/>
+                            <Setter Property="PopupAnimation" Value="None" TargetName="SubMenuPopup" />
                         </Trigger>
                         </Trigger>
 
 
                         <!-- If no Icon is present the we collapse the Icon Content -->
                         <!-- If no Icon is present the we collapse the Icon Content -->
                         <Trigger Property="Icon" Value="{x:Null}">
                         <Trigger Property="Icon" Value="{x:Null}">
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="Icon" />
                         </Trigger>
                         </Trigger>
 
 
                         <!-- The GlyphPanel contains the CheckMark -->
                         <!-- The GlyphPanel contains the CheckMark -->
                         <Trigger Property="IsChecked" Value="true">
                         <Trigger Property="IsChecked" Value="true">
-                            <Setter Property="Visibility" Value="Visible" TargetName="GlyphPanel"/>
-                            <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
+                            <Setter Property="Visibility" Value="Visible" TargetName="GlyphPanel" />
+                            <Setter Property="Visibility" Value="Collapsed" TargetName="Icon" />
                         </Trigger>
                         </Trigger>
 
 
                         <!-- Using the system colors for the Menu Highlight and IsEnabled-->
                         <!-- Using the system colors for the Menu Highlight and IsEnabled-->
                         <Trigger Property="IsHighlighted" Value="true">
                         <Trigger Property="IsHighlighted" Value="true">
-                            <Setter Property="Background" Value="#666666" TargetName="Border"/>
-                            <Setter Property="Foreground" Value="Black"/>
+                            <Setter Property="Background" Value="#666666" TargetName="Border" />
+                            <Setter Property="Foreground" Value="Black" />
                         </Trigger>
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="true">
                         <Trigger Property="IsEnabled" Value="true">
-                            <Setter Property="Foreground" Value="Snow"/>
+                            <Setter Property="Foreground" Value="Snow" />
                         </Trigger>
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="false">
                         <Trigger Property="IsEnabled" Value="false">
-                            <Setter Property="Foreground" Value="LightGray"/>
+                            <Setter Property="Foreground" Value="LightGray" />
                         </Trigger>
                         </Trigger>
                     </ControlTemplate.Triggers>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
                 </ControlTemplate>

Some files were not shown because too many files changed in this diff