Browse Source

Hopefully fix everything that was broken during the merge

Equbuxu 3 years ago
parent
commit
c4cd807194
37 changed files with 473 additions and 553 deletions
  1. 5 8
      PixiEditor/Helpers/Behaviours/MouseBehavior.cs
  2. 2 4
      PixiEditor/Helpers/Behaviours/TextBoxFocusBehavior.cs
  3. 2 7
      PixiEditor/Helpers/BindingProxy.cs
  4. 0 1
      PixiEditor/Helpers/Extensions/ServiceCollectionHelpers.cs
  5. 11 9
      PixiEditor/Helpers/PaletteHelpers.cs
  6. 2 7
      PixiEditor/Helpers/UI/TreeViewItemHelper.cs
  7. 7 7
      PixiEditor/Models/Commands/CommandController.cs
  8. 81 36
      PixiEditor/ViewModels/SubViewModels/Main/ColorsViewModel.cs
  9. 8 9
      PixiEditor/ViewModels/SubViewModels/Main/DebugViewModel.cs
  10. 4 25
      PixiEditor/ViewModels/ViewModelMain.cs
  11. 5 7
      PixiEditor/Views/Dialogs/ConfirmationPopup.xaml.cs
  12. 3 7
      PixiEditor/Views/Dialogs/ExportFilePopup.xaml.cs
  13. 4 5
      PixiEditor/Views/Dialogs/PalettesBrowser.xaml.cs
  14. 3 3
      PixiEditor/Views/Dialogs/ResizeCanvasPopup.xaml.cs
  15. 0 2
      PixiEditor/Views/Dialogs/ResizeablePopup.cs
  16. 179 182
      PixiEditor/Views/MainWindow.xaml
  17. 3 4
      PixiEditor/Views/UserControls/AlignableWrapPanel.cs
  18. 1 1
      PixiEditor/Views/UserControls/AnchorPointPicker.xaml.cs
  19. 11 15
      PixiEditor/Views/UserControls/EditableTextBlock.xaml.cs
  20. 5 10
      PixiEditor/Views/UserControls/InputBox.cs
  21. 7 9
      PixiEditor/Views/UserControls/Layers/LayerGroupControl.xaml.cs
  22. 10 10
      PixiEditor/Views/UserControls/Layers/LayerStructureItemContainer.xaml.cs
  23. 6 9
      PixiEditor/Views/UserControls/Layers/RawLayersViewer.xaml.cs
  24. 2 5
      PixiEditor/Views/UserControls/Layers/ReferenceLayer.xaml.cs
  25. 3 10
      PixiEditor/Views/UserControls/ListSwitchButton.cs
  26. 4 13
      PixiEditor/Views/UserControls/NumberInput.xaml.cs
  27. 9 10
      PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml.cs
  28. 3 4
      PixiEditor/Views/UserControls/Palettes/CompactPaletteViewer.xaml.cs
  29. 7 9
      PixiEditor/Views/UserControls/Palettes/PaletteColor.xaml.cs
  30. 11 13
      PixiEditor/Views/UserControls/Palettes/PaletteColorAdder.xaml.cs
  31. 34 30
      PixiEditor/Views/UserControls/Palettes/PaletteItem.xaml
  32. 6 13
      PixiEditor/Views/UserControls/Palettes/PaletteItem.xaml.cs
  33. 26 47
      PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml.cs
  34. 3 14
      PixiEditor/Views/UserControls/PrependTextBlock.xaml.cs
  35. 2 3
      PixiEditor/Views/UserControls/SizeInput.xaml.cs
  36. 4 2
      PixiEditor/Views/UserControls/SwatchesView.xaml
  37. 0 3
      PixiEditor/Views/UserControls/SwatchesView.xaml.cs

+ 5 - 8
PixiEditor/Helpers/Behaviours/MouseBehavior.cs

@@ -6,16 +6,13 @@ namespace PixiEditor.Helpers.Behaviours
 {
     public class MouseBehavior : Behavior<FrameworkElement>
     {
-        public static readonly DependencyProperty MouseYProperty = DependencyProperty.Register(
-            "MouseY", typeof(double), typeof(MouseBehavior), new PropertyMetadata(default(double)));
+        public static readonly DependencyProperty MouseYProperty = DependencyProperty.Register(nameof(MouseY), typeof(double), typeof(MouseBehavior), new PropertyMetadata(default(double)));
+
+        public static readonly DependencyProperty MouseXProperty = DependencyProperty.Register(nameof(MouseX), typeof(double), typeof(MouseBehavior), new PropertyMetadata(default(double)));
 
-        public static readonly DependencyProperty MouseXProperty = DependencyProperty.Register(
-            "MouseX", typeof(double), typeof(MouseBehavior), 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",
+            DependencyProperty.Register(nameof(RelativeTo),
                 typeof(FrameworkElement),
                 typeof(MouseBehavior),
                 new PropertyMetadata(default(FrameworkElement)));
@@ -64,4 +61,4 @@ namespace PixiEditor.Helpers.Behaviours
 
 #if PUBLISH
 #error Hi
-#endif
+#endif

+ 2 - 4
PixiEditor/Helpers/Behaviours/TextBoxFocusBehavior.cs

@@ -1,5 +1,4 @@
-using System.Linq;
-using System.Windows;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Interactivity;
@@ -46,8 +45,7 @@ namespace PixiEditor.Helpers.Behaviours
             set => SetValue(DeselectOnFocusLossProperty, value);
         }
 
-        public static readonly DependencyProperty FocusNextProperty = DependencyProperty.Register(
-            "FocusNext", typeof(bool), typeof(TextBoxFocusBehavior), new PropertyMetadata(false));
+        public static readonly DependencyProperty FocusNextProperty = DependencyProperty.Register(nameof(FocusNext), typeof(bool), typeof(TextBoxFocusBehavior), new PropertyMetadata(false));
 
         public bool FocusNext
         {

+ 2 - 7
PixiEditor/Helpers/BindingProxy.cs

@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
+using System.Windows;
 
 namespace PixiEditor.Helpers
 {
@@ -21,6 +16,6 @@ namespace PixiEditor.Helpers
         }
 
         public static readonly DependencyProperty DataProperty =
-            DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
+            DependencyProperty.Register(nameof(Data), typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
     }
 }

+ 0 - 1
PixiEditor/Helpers/Extensions/ServiceCollectionHelpers.cs

@@ -1,7 +1,6 @@
 using Microsoft.Extensions.DependencyInjection;
 using PixiEditor.Models.Commands;
 using PixiEditor.Models.Controllers;
-using PixiEditor.Models.Controllers.Shortcuts;
 using PixiEditor.Models.DataProviders;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.IO.ClsFile;

+ 11 - 9
PixiEditor/Helpers/PaletteHelpers.cs

@@ -1,22 +1,24 @@
-using System.Collections.Generic;
-using PixiEditor.Models.IO;
+using PixiEditor.Models.IO;
 
 namespace PixiEditor.Helpers
 {
     public static class PaletteHelpers
     {
-        public static string GetFilter(IList<PaletteFileParser> parsers)
+        public static string GetFilter(IList<PaletteFileParser> parsers, bool includeCommon)
         {
             string filter = "";
 
-            List<string> allSupportedFormats = new();
-            foreach (var parser in parsers)
+            if (includeCommon)
             {
-                allSupportedFormats.AddRange(parser.SupportedFileExtensions);
+                List<string> allSupportedFormats = new();
+                foreach (var parser in parsers)
+                {
+                    allSupportedFormats.AddRange(parser.SupportedFileExtensions);
+                }
+                string allSupportedFormatsString = string.Join(';', allSupportedFormats).Replace(".", "*.");
+                filter += $"Palette Files ({allSupportedFormatsString})|{allSupportedFormatsString}|";
             }
-            string allSupportedFormatsString = string.Join(';', allSupportedFormats).Replace(".", "*.");
-            filter += $"Palette Files ({allSupportedFormatsString})|{allSupportedFormatsString}|";
-            
+
             foreach (var parser in parsers)
             {
                 string supportedFormats = string.Join(';', parser.SupportedFileExtensions).Replace(".", "*.");

+ 2 - 7
PixiEditor/Helpers/UI/TreeViewItemHelper.cs

@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
+using System.Windows;
 
 namespace PixiEditor.Helpers.UI
 {
@@ -19,7 +14,7 @@ namespace PixiEditor.Helpers.UI
             obj.SetValue(IndentProperty, value);
         }
 
-        // Using a DependencyProperty as the backing store for Indent.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty IndentProperty =
             DependencyProperty.RegisterAttached("Indent", typeof(GridLength), typeof(TreeViewItemHelper), new PropertyMetadata(new GridLength(0)));
     }

+ 7 - 7
PixiEditor/Models/Commands/CommandController.cs

@@ -15,7 +15,7 @@ namespace PixiEditor.Models.Commands
         private readonly ShortcutFile shortcutFile;
 
         public static CommandController Current { get; private set; }
-        
+
         public static string ShortcutsPath { get; private set; }
 
         public CommandCollection Commands { get; }
@@ -34,7 +34,7 @@ namespace PixiEditor.Models.Commands
                 Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                 "PixiEditor",
                 "shortcuts.json");
-            
+
             shortcutFile = new(ShortcutsPath, this);
 
             Commands = new();
@@ -52,13 +52,13 @@ namespace PixiEditor.Models.Commands
                     ReplaceShortcut(Commands[command], shortcut.Key);
                 }
             }
-            
+
             if (save)
             {
                 shortcutFile.SaveShortcuts();
             }
         }
-        
+
         private static List<(string internalName, string displayName)> FindCommandGroups(Type[] typesToSearchForAttributes)
         {
             List<(string internalName, string displayName)> result = new();
@@ -201,7 +201,7 @@ namespace PixiEditor.Models.Commands
                 CommandGroups.Add(new(groupDisplayName, storedCommands));
             }
 
-            KeyCombination GetShortcut(string internalName, KeyCombination defaultShortcut) 
+            KeyCombination GetShortcut(string internalName, KeyCombination defaultShortcut)
                 => shortcuts.FirstOrDefault(x => x.Value.Contains(internalName), new(defaultShortcut, null)).Key;
 
             void AddCommandToCommandsCollection(Command command)
@@ -255,7 +255,7 @@ namespace PixiEditor.Models.Commands
 
             object CastParameter(object input, Type target)
             {
-                if (target == typeof(object) || target == input.GetType())
+                if (target == typeof(object) || target == input?.GetType())
                     return input;
                 return Convert.ChangeType(input, target);
             }
@@ -342,7 +342,7 @@ namespace PixiEditor.Models.Commands
         public void ResetShortcuts()
         {
             File.Copy(ShortcutsPath, Path.ChangeExtension(ShortcutsPath, ".json.bak"), true);
-            
+
             Commands.ClearShortcuts();
 
             foreach (var command in Commands)

+ 81 - 36
PixiEditor/ViewModels/SubViewModels/Main/ColorsViewModel.cs

@@ -1,40 +1,28 @@
-using PixiEditor.Models.Commands.Attributes;
-using SkiaSharp;
-using System.Windows.Input;
 using Microsoft.Extensions.DependencyInjection;
 using PixiEditor.Helpers;
+using PixiEditor.Models.Commands.Attributes;
+using PixiEditor.Models.Commands.Search;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.DataHolders.Palettes;
 using PixiEditor.Models.DataProviders;
 using PixiEditor.Models.Dialogs;
 using PixiEditor.Models.Enums;
-using PixiEditor.Models.IO;
-using SkiaSharp;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using PixiEditor.Models.Controllers;
-using PixiEditor.Models.DataHolders.Palettes;
 using PixiEditor.Models.ExternalServices;
+using PixiEditor.Models.IO;
 using PixiEditor.Models.Undo;
 using PixiEditor.Views.Dialogs;
+using SkiaSharp;
+using System.Windows.Input;
+using System.Windows.Media;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main
 {
+    [Command.Group("PixiEditor.Colors", "Palette Colors")]
     public class ColorsViewModel : SubViewModel<ViewModelMain>
     {
-        public RelayCommand<(SKColor, SKColor)> ReplaceColorsCommand { get; set; }
-
-        public RelayCommand SwapColorsCommand { get; set; }
-
-        public RelayCommand SelectColorCommand { get; set; }
-
-        public RelayCommand RemoveSwatchCommand { get; set; }
-
         public RelayCommand<List<string>> ImportPaletteCommand { get; set; }
 
-        public RelayCommand<int> SelectPaletteColorCommand { get; set; }
-
         public WpfObservableRangeCollection<PaletteFileParser> PaletteParsers { get; private set; }
         public WpfObservableRangeCollection<PaletteListDataSource> PaletteDataSources { get; private set; }
 
@@ -53,7 +41,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
                 {
                     primaryColor = value;
                     Owner.BitmapManager.PrimaryColor = value;
-                    RaisePropertyChanged("PrimaryColor");
+                    RaisePropertyChanged(nameof(PrimaryColor));
                 }
             }
         }
@@ -68,7 +56,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
                 if (secondaryColor != value)
                 {
                     secondaryColor = value;
-                    RaisePropertyChanged("SecondaryColor");
+                    RaisePropertyChanged(nameof(SecondaryColor));
                 }
             }
         }
@@ -76,21 +64,18 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
         public ColorsViewModel(ViewModelMain owner)
             : base(owner)
         {
-            SelectColorCommand = new RelayCommand(SelectColor);
-            RemoveSwatchCommand = new RelayCommand(RemoveSwatch);
-            SwapColorsCommand = new RelayCommand(SwapColors);
-            SelectPaletteColorCommand = new RelayCommand<int>(SelectPaletteColor);
             ImportPaletteCommand = new RelayCommand<List<string>>(ImportPalette, CanImportPalette);
-            ReplaceColorsCommand = new RelayCommand<(SKColor oldColor, SKColor newColor)>(ReplaceColors, Owner.DocumentIsNotNull);
             Owner.OnStartupEvent += OwnerOnStartupEvent;
         }
 
-        private bool CanImportPalette(List<string> paletteColors)
+        [Evaluator.CanExecute("PixiEditor.Colors.CanReplaceColors")]
+        public bool CanReplaceColors()
         {
-            return Owner.DocumentIsNotNull(paletteColors) && paletteColors.Count > 0;
+            return ViewModelMain.Current?.BitmapManager?.ActiveDocument is not null;
         }
 
-        private void ReplaceColors((SKColor oldColor, SKColor newColor) colors)
+        [Command.Internal("PixiEditor.Colors.ReplaceColors")]
+        public void ReplaceColors((SKColor oldColor, SKColor newColor) colors)
         {
             Document activeDocument = Owner.BitmapManager?.ActiveDocument;
             if (activeDocument != null)
@@ -170,7 +155,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
         private async Task SavePalette(Palette palette, PalettesBrowser browser)
         {
             palette.FileName = $"{palette.Name}.pal";
-            
+
             await LocalPaletteFetcher.SavePalette(
                 palette.FileName,
                 palette.Colors.Select(SKColor.Parse).ToArray());
@@ -188,14 +173,22 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             }
         }
 
+        [Evaluator.CanExecute("PixiEditor.Colors.CanImportPalette")]
+        public bool CanImportPalette(List<string> paletteColors)
+        {
+            return paletteColors is not null && Owner.DocumentIsNotNull(paletteColors) && paletteColors.Count > 0;
+        }
+
+        [Command.Internal("PixiEditor.Colors.ImportPalette", CanExecute = "PixiEditor.Colors.CanImportPalette")]
         public void ImportPalette(List<string> palette)
         {
             var doc = Owner.BitmapManager.ActiveDocument;
-            if (doc == null) return;
+            if (doc is null)
+                return;
 
             if (ConfirmationDialog.Show("Replace current palette with selected one?", "Replace current palette") == ConfirmationType.Yes)
             {
-                if (doc.Palette == null)
+                if (doc.Palette is null)
                 {
                     doc.Palette = new WpfObservableRangeCollection<SKColor>();
                 }
@@ -204,10 +197,62 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             }
         }
 
-        private void SelectPaletteColor(int index)
+        [Evaluator.CanExecute("PixiEditor.Colors.CanSelectPaletteColor")]
+        public bool CanSelectPaletteColor(int index)
+        {
+            var document = Owner.BitmapManager.ActiveDocument;
+            return document.Palette is not null && document.Palette.Count > index;
+        }
+
+        [Evaluator.Icon("PixiEditor.Colors.FirstPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon1() => GetPaletteColorIcon(0);
+        [Evaluator.Icon("PixiEditor.Colors.SecondPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon2() => GetPaletteColorIcon(1);
+        [Evaluator.Icon("PixiEditor.Colors.ThirdPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon3() => GetPaletteColorIcon(2);
+        [Evaluator.Icon("PixiEditor.Colors.FourthPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon4() => GetPaletteColorIcon(3);
+        [Evaluator.Icon("PixiEditor.Colors.FifthPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon5() => GetPaletteColorIcon(4);
+        [Evaluator.Icon("PixiEditor.Colors.SixthPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon6() => GetPaletteColorIcon(5);
+        [Evaluator.Icon("PixiEditor.Colors.SeventhPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon7() => GetPaletteColorIcon(6);
+        [Evaluator.Icon("PixiEditor.Colors.EighthPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon8() => GetPaletteColorIcon(7);
+        [Evaluator.Icon("PixiEditor.Colors.NinthPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon9() => GetPaletteColorIcon(8);
+        [Evaluator.Icon("PixiEditor.Colors.TenthPaletteColorIcon")]
+        public ImageSource GetPaletteColorIcon10() => GetPaletteColorIcon(9);
+
+
+        private ImageSource GetPaletteColorIcon(int index)
+        {
+            var document = Owner.BitmapManager.ActiveDocument;
+
+            SKColor color;
+            if (document.Palette is null || document.Palette.Count <= index)
+                color = SKColors.Gray;
+            else
+                color = document.Palette[index];
+
+            return ColorSearchResult.GetIcon(color);
+        }
+
+        [Command.Basic("PixiEditor.Colors.SelectFirstPaletteColor", "Select color 1", "Select the first color in the palette", Key = Key.D1, Parameter = 0, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.FirstPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectSecondPaletteColor", "Select color 2", "Select the second color in the palette", Key = Key.D2, Parameter = 1, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.SecondPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectThirdPaletteColor", "Select color 3", "Select the third color in the palette", Key = Key.D3, Parameter = 2, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.ThirdPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectFourthPaletteColor", "Select color 4", "Select the fourth color in the palette", Key = Key.D4, Parameter = 3, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.FourthPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectFifthPaletteColor", "Select color 5", "Select the fifth color in the palette", Key = Key.D5, Parameter = 4, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.FifthPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectSixthPaletteColor", "Select color 6", "Select the sixth color in the palette", Key = Key.D6, Parameter = 5, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.SixthPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectSeventhPaletteColor", "Select color 7", "Select the seventh color in the palette", Key = Key.D7, Parameter = 6, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.SeventhPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectEighthPaletteColor", "Select color 8", "Select the eighth color in the palette", Key = Key.D8, Parameter = 7, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.EighthPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectNinthPaletteColor", "Select color 9", "Select the ninth color in the palette", Key = Key.D9, Parameter = 8, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.NinthPaletteColorIcon")]
+        [Command.Basic("PixiEditor.Colors.SelectTenthPaletteColor", "Select color 10", "Select the tenth color in the palette", Key = Key.D0, Parameter = 9, CanExecute = "PixiEditor.Colors.CanSelectPaletteColor", IconEvaluator = "PixiEditor.Colors.TenthPaletteColorIcon")]
+        public void SelectPaletteColor(int index)
         {
             var document = Owner.BitmapManager.ActiveDocument;
-            if(document.Palette != null && document.Palette.Count > index)
+            if (document.Palette != null && document.Palette.Count > index)
             {
                 PrimaryColor = document.Palette[index];
             }

+ 8 - 9
PixiEditor/ViewModels/SubViewModels/Main/DebugViewModel.cs

@@ -5,8 +5,6 @@ using PixiEditor.Models.UserPreferences;
 using System.Diagnostics;
 using System.IO;
 using System.Reflection;
-using System.Windows.Media;
-using SkiaSharp;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main
 {
@@ -32,18 +30,19 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             UpdateDebugMode(preferences.GetPreference<bool>("IsDebugModeEnabled"));
         }
 
-        [Command.Debug("PixiEditor.Debug.OpenTempDirectory", "%Temp%/PixiEditor", "Open Temp Directory", "Open Temp Directory")]
-        [Command.Debug("PixiEditor.Debug.OpenLocalAppDataDirectory", "%LocalAppData%/PixiEditor", "Open Local AppData Directory", "Open Local AppData Directory")]
-        [Command.Debug("PixiEditor.Debug.OpenRoamingAppDataDirectory", "%AppData%/PixiEditor", "Open Roaming AppData Directory", "Open Roaming AppData Directory")]
-        [Command.Debug("PixiEditor.Debug.OpenCrashReportsDirectory", "%LocalAppData%/PixiEditor/crash_logs", "Open Crash Reports Directory", "Open Crash Reports Directory")]
+        [Command.Debug("PixiEditor.Debug.OpenTempDirectory", @"%Temp%\PixiEditor", "Open Temp Directory", "Open Temp Directory")]
+        [Command.Debug("PixiEditor.Debug.OpenLocalAppDataDirectory", @"%LocalAppData%\PixiEditor", "Open Local AppData Directory", "Open Local AppData Directory")]
+        [Command.Debug("PixiEditor.Debug.OpenRoamingAppDataDirectory", @"%AppData%\PixiEditor", "Open Roaming AppData Directory", "Open Roaming AppData Directory")]
+        [Command.Debug("PixiEditor.Debug.OpenCrashReportsDirectory", @"%LocalAppData%\PixiEditor\crash_logs", "Open Crash Reports Directory", "Open Crash Reports Directory")]
         public static void OpenFolder(string path)
         {
-            if (!Directory.Exists(path))
+            string expandedPath = Environment.ExpandEnvironmentVariables(path);
+            if (!Directory.Exists(expandedPath))
             {
-                NoticeDialog.Show($"{path} does not exist.", "Location does not exist");
+                NoticeDialog.Show($"{expandedPath} does not exist.", "Location does not exist");
                 return;
             }
-        
+
             ProcessHelpers.ShellExecuteEV(path);
         }
 

+ 4 - 25
PixiEditor/ViewModels/ViewModelMain.cs

@@ -1,12 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Windows;
-using System.Windows.Input;
-using System.Windows.Threading;
-using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection;
 using PixiEditor.Helpers;
 using PixiEditor.Models.Commands;
 using PixiEditor.Models.Controllers;
@@ -16,11 +8,11 @@ using PixiEditor.Models.Enums;
 using PixiEditor.Models.Events;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
-using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.UserPreferences;
 using PixiEditor.ViewModels.SubViewModels.Main;
-using PixiEditor.Views.Dialogs;
 using SkiaSharp;
+using System.ComponentModel;
+using System.Windows;
 
 namespace PixiEditor.ViewModels
 {
@@ -80,7 +72,7 @@ namespace PixiEditor.ViewModels
         public WindowViewModel WindowSubViewModel { get; set; }
 
         public SearchViewModel SearchSubViewModel { get; set; }
-        
+
         public RegistryViewModel RegistrySubViewModel { get; set; }
 
         public IPreferences Preferences { get; set; }
@@ -158,20 +150,7 @@ namespace PixiEditor.ViewModels
             WindowSubViewModel = services.GetService<WindowViewModel>();
             StylusSubViewModel = services.GetService<StylusViewModel>();
             RegistrySubViewModel = services.GetService<RegistryViewModel>();
-            AddDebugOnlyViewModels();
-            AddReleaseOnlyViewModels();
-            
-            Shortcut[] colorShortcuts = new Shortcut[10];
-            colorShortcuts[9] = new Shortcut(
-                Key.D0, ColorsSubViewModel.SelectPaletteColorCommand, 9);
-            for (int i = 0; i < colorShortcuts.Length - 1; i++)
-            {
-                //35 is a D1 key integer value
-                colorShortcuts[i] = new Shortcut((Key)35 + i, ColorsSubViewModel.SelectPaletteColorCommand, i);
-            }
 
-            ShortcutController.ShortcutGroups.Add(new ShortcutGroup("Palette Colors", colorShortcuts));
-            
             MiscSubViewModel = services.GetService<MiscViewModel>();
 
             BitmapManager.PrimaryColor = ColorsSubViewModel.PrimaryColor;

+ 5 - 7
PixiEditor/Views/Dialogs/ConfirmationPopup.xaml.cs

@@ -8,14 +8,12 @@ namespace PixiEditor.Views
     /// </summary>
     public partial class ConfirmationPopup : Window
     {
-        // Using a DependencyProperty as the backing store for SaveChanges.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty SaveChangesProperty =
-            DependencyProperty.Register("SaveChanges", typeof(bool), typeof(ConfirmationPopup),
+        public static readonly DependencyProperty ResultProperty =
+            DependencyProperty.Register(nameof(Result), typeof(bool), typeof(ConfirmationPopup),
                 new PropertyMetadata(true));
 
-        // Using a DependencyProperty as the backing store for Body.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty BodyProperty =
-            DependencyProperty.Register("Body", typeof(string), typeof(ConfirmationPopup), new PropertyMetadata(""));
+            DependencyProperty.Register(nameof(Body), typeof(string), typeof(ConfirmationPopup), new PropertyMetadata(""));
 
         public ConfirmationPopup()
         {
@@ -31,8 +29,8 @@ namespace PixiEditor.Views
 
         public bool Result
         {
-            get => (bool)GetValue(SaveChangesProperty);
-            set => SetValue(SaveChangesProperty, value);
+            get => (bool)GetValue(ResultProperty);
+            set => SetValue(ResultProperty, value);
         }
 
 

+ 3 - 7
PixiEditor/Views/Dialogs/ExportFilePopup.xaml.cs

@@ -1,25 +1,21 @@
 using PixiEditor.Models.Enums;
 using PixiEditor.ViewModels;
-using System;
-using System.ComponentModel;
 using System.Windows;
 using System.Windows.Input;
 
 namespace PixiEditor.Views
 {
-    public partial class ExportFilePopup : Window, INotifyPropertyChanged
+    public partial class ExportFilePopup : Window
     {
         public static readonly DependencyProperty SaveHeightProperty =
-            DependencyProperty.Register("SaveHeight", typeof(int), typeof(ExportFilePopup), new PropertyMetadata(32));
+            DependencyProperty.Register(nameof(SaveHeight), typeof(int), typeof(ExportFilePopup), new PropertyMetadata(32));
 
 
         public static readonly DependencyProperty SaveWidthProperty =
-            DependencyProperty.Register("SaveWidth", typeof(int), typeof(ExportFilePopup), new PropertyMetadata(32));
+            DependencyProperty.Register(nameof(SaveWidth), typeof(int), typeof(ExportFilePopup), new PropertyMetadata(32));
 
         private readonly SaveFilePopupViewModel dataContext = new SaveFilePopupViewModel();
 
-        public event PropertyChangedEventHandler PropertyChanged;
-
         private int imageWidth;
         private int imageHeight;
         public string SizeHint => $"If you want to share the image, try {GetBestPercentage()}% for the best clarity";

+ 4 - 5
PixiEditor/Views/Dialogs/PalettesBrowser.xaml.cs

@@ -10,12 +10,8 @@ using PixiEditor.Models.UserPreferences;
 using PixiEditor.ViewModels;
 using PixiEditor.Views.UserControls.Palettes;
 using SkiaSharp;
-using System;
-using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
@@ -223,6 +219,7 @@ namespace PixiEditor.Views.Dialogs
             }
 
             UpdateRenamedFavourite(Path.GetFileNameWithoutExtension(oldFileName), itemAffected.Name);
+            Sort();
         }
 
         private void HandleCacheItemDeleted(string deletedItemFileName)
@@ -231,6 +228,7 @@ namespace PixiEditor.Views.Dialogs
             if (item != null)
             {
                 SortedResults.Remove(item);
+                PaletteList.Palettes.Remove(item);
             }
         }
 
@@ -250,6 +248,7 @@ namespace PixiEditor.Views.Dialogs
         private void HandleCachePaletteCreated(Palette updatedItem)
         {
             SortedResults.Add(updatedItem);
+            PaletteList.Palettes.Add(updatedItem);
             Sort();
         }
 
@@ -537,7 +536,7 @@ namespace PixiEditor.Views.Dialogs
             var parsers = ViewModelMain.Current.ColorsSubViewModel.PaletteParsers;
             OpenFileDialog openFileDialog = new OpenFileDialog
             {
-                Filter = PaletteHelpers.GetFilter(parsers)
+                Filter = PaletteHelpers.GetFilter(parsers, true)
             };
 
             if (openFileDialog.ShowDialog() == true)

+ 3 - 3
PixiEditor/Views/Dialogs/ResizeCanvasPopup.xaml.cs

@@ -9,12 +9,12 @@ namespace PixiEditor.Views
     /// </summary>
     public partial class ResizeCanvasPopup : ResizeablePopup
     {
-        // Using a DependencyProperty as the backing store for SelectedAnchorPoint.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty SelectedAnchorPointProperty =
-            DependencyProperty.Register("SelectedAnchorPoint", typeof(AnchorPoint), typeof(ResizeCanvasPopup),
+            DependencyProperty.Register(nameof(SelectedAnchorPoint), typeof(AnchorPoint), typeof(ResizeCanvasPopup),
                 new PropertyMetadata(AnchorPoint.Top | AnchorPoint.Left));
 
-        
+
         public ResizeCanvasPopup()
         {
             InitializeComponent();

+ 0 - 2
PixiEditor/Views/Dialogs/ResizeablePopup.cs

@@ -11,11 +11,9 @@ namespace PixiEditor.Views
         public static readonly DependencyProperty NewSelectedUnitProperty =
             DependencyProperty.Register(nameof(NewSelectedUnit), typeof(SizeUnit), typeof(SizePicker), new PropertyMetadata(SizeUnit.Pixel));
 
-        // Using a DependencyProperty as the backing store for NewAbsoluteHeight.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty NewAbsoluteHeightProperty =
             DependencyProperty.Register(nameof(NewAbsoluteHeight), typeof(int), typeof(ResizeablePopup), new PropertyMetadata(0));
 
-        // Using a DependencyProperty as the backing store for NewAbsoluteWidth.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty NewAbsoluteWidthProperty =
             DependencyProperty.Register(nameof(NewAbsoluteWidth), typeof(int), typeof(ResizeablePopup), new PropertyMetadata(0));
 

+ 179 - 182
PixiEditor/Views/MainWindow.xaml

@@ -12,6 +12,7 @@
     xmlns:dataHolders="clr-namespace:PixiEditor.Models.DataHolders"
     xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
+    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
     xmlns:ui="clr-namespace:PixiEditor.Helpers.UI"
     xmlns:cmd="http://www.galasoft.ch/mvvmlight"
     xmlns:avalondock="https://github.com/Dirkster99/AvalonDock"
@@ -22,6 +23,7 @@
     xmlns:layerUserControls="clr-namespace:PixiEditor.Views.UserControls.Layers"
     xmlns:cmds="clr-namespace:PixiEditor.Models.Commands.XAML"
     xmlns:commandSearch="clr-namespace:PixiEditor.Views.UserControls.CommandSearch"
+    xmlns:palettes="clr-namespace:PixiEditor.Views.UserControls.Palettes"
     d:DataContext="{d:DesignInstance Type=vm:ViewModelMain}"
     mc:Ignorable="d"
     WindowStyle="None"
@@ -342,7 +344,7 @@
                 <Border Width="200" Height="25" 
                         Background="{StaticResource DarkerAccentColor}"
                         CornerRadius="5" BorderThickness="1"
-                        Margin="10,0,0,0"
+                        Margin="10,-6,0,0"
                         WindowChrome.IsHitTestVisibleInChrome="True"
                         Cursor="IBeam">
                     <Border.Style>
@@ -413,92 +415,93 @@
                 <Button
                     Margin="1,0,0,0"
                     Command="{cmds:Command PixiEditor.Undo.Undo}"
-                    ToolTip="Undo"Style="{StaticResource ToolSettingsGlyphButton}" 
+                    ToolTip="Undo"
+                    Style="{StaticResource ToolSettingsGlyphButton}" 
 					Content="&#xE7A7;"/>
-            <Button 
+                <Button 
 				Command="{cmds:Command PixiEditor.Undo.Redo}" 
 				ToolTip="Redo"
                 Style="{StaticResource ToolSettingsGlyphButton}" 
 				Content="&#xE7A6;"/>
-            <ToggleButton 
+                <ToggleButton 
 				Width="30" 
 				BorderThickness="0"
 				ToolTip="Pen Mode" 
 				Focusable="False"
                 IsChecked="{Binding StylusSubViewModel.IsPenModeEnabled}">
-                <ToggleButton.Style>
-                    <Style TargetType="ToggleButton">
-                        <Setter Property="Template">
-                            <Setter.Value>
-                                <ControlTemplate TargetType="ToggleButton">
-                                    <Border BorderBrush="{TemplateBinding BorderBrush}" 
+                    <ToggleButton.Style>
+                        <Style TargetType="ToggleButton">
+                            <Setter Property="Template">
+                                <Setter.Value>
+                                    <ControlTemplate TargetType="ToggleButton">
+                                        <Border BorderBrush="{TemplateBinding BorderBrush}" 
                                             Background="{TemplateBinding Background}" Focusable="False">
-                                        <ContentPresenter HorizontalAlignment="Center"
+                                            <ContentPresenter HorizontalAlignment="Center"
                                               VerticalAlignment="Center" Focusable="False"/>
-                                    </Border>
-                                </ControlTemplate>
-                            </Setter.Value>
-                        </Setter>
-                        <Style.Triggers>
-                            <Trigger Property="IsChecked" Value="False">
-                                <Setter Property="Background" Value="Transparent"/>
-                            </Trigger>
-                            <Trigger Property="IsMouseOver" Value="True">
-                                <Setter Property="Background" Value="#404040"/>
-                            </Trigger>
-                            <Trigger Property="IsChecked" Value="True">
-                                <Setter Property="Background" Value="#707070"/>
-                            </Trigger>
-                        </Style.Triggers>
-                    </Style>
-                </ToggleButton.Style>
-                <Image Height="20" Source="../Images/penMode.png"/>
-            </ToggleButton>
-            <Grid Margin="5,5,10,5" Background="{StaticResource BrighterAccentColor}" Width="5"/>
-            <Label Style="{StaticResource BaseLabel}" FontSize="12"
+                                        </Border>
+                                    </ControlTemplate>
+                                </Setter.Value>
+                            </Setter>
+                            <Style.Triggers>
+                                <Trigger Property="IsChecked" Value="False">
+                                    <Setter Property="Background" Value="Transparent"/>
+                                </Trigger>
+                                <Trigger Property="IsMouseOver" Value="True">
+                                    <Setter Property="Background" Value="#404040"/>
+                                </Trigger>
+                                <Trigger Property="IsChecked" Value="True">
+                                    <Setter Property="Background" Value="#707070"/>
+                                </Trigger>
+                            </Style.Triggers>
+                        </Style>
+                    </ToggleButton.Style>
+                    <Image Height="20" Source="../Images/penMode.png"/>
+                </ToggleButton>
+                <Grid Margin="5,5,10,5" Background="{StaticResource BrighterAccentColor}" Width="5"/>
+                <Label Style="{StaticResource BaseLabel}" FontSize="12"
                    VerticalAlignment="Center" Content="{Binding ToolsSubViewModel.ActiveTool.DisplayName}"
                    ToolTip="{Binding ToolsSubViewModel.ActiveTool.ActionDisplay}"/>
-            <ItemsControl ItemsSource="{Binding ToolsSubViewModel.ActiveTool.Toolbar.Settings}">
-                <ItemsControl.ItemsPanel>
-                    <ItemsPanelTemplate>
-                        <StackPanel Orientation="Horizontal" Margin="10, 0, 0, 0" />
-                    </ItemsPanelTemplate>
-                </ItemsControl.ItemsPanel>
-                <ItemsControl.ItemTemplate>
-                    <DataTemplate>
-                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,10,0">
-                            <Label
+                <ItemsControl ItemsSource="{Binding ToolsSubViewModel.ActiveTool.Toolbar.Settings}">
+                    <ItemsControl.ItemsPanel>
+                        <ItemsPanelTemplate>
+                            <StackPanel Orientation="Horizontal" Margin="10, 0, 0, 0" />
+                        </ItemsPanelTemplate>
+                    </ItemsControl.ItemsPanel>
+                    <ItemsControl.ItemTemplate>
+                        <DataTemplate>
+                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,10,0">
+                                <Label
                                 Visibility="{Binding HasLabel, Converter={StaticResource BoolToVisibilityConverter}}"
                                 Foreground="White" Content="{Binding Label}" />
-                            <ContentControl Content="{Binding SettingControl}" />
-                        </StackPanel>
-                    </DataTemplate>
-                </ItemsControl.ItemTemplate>
-            </ItemsControl>
-        </StackPanel>
-        <Grid Grid.Column="1" Grid.Row="2" Background="#303030" >
-            <Grid AllowDrop="True" Drop="MainWindow_Drop">
-                <DockingManager ActiveContent="{Binding BitmapManager.ActiveWindow, Mode=TwoWay}"
+                                <ContentControl Content="{Binding SettingControl}" />
+                            </StackPanel>
+                        </DataTemplate>
+                    </ItemsControl.ItemTemplate>
+                </ItemsControl>
+            </StackPanel>
+            <Grid Grid.Column="1" Grid.Row="2" Background="#303030" >
+                <Grid AllowDrop="True" Drop="MainWindow_Drop">
+                    <DockingManager ActiveContent="{Binding BitmapManager.ActiveWindow, Mode=TwoWay}"
                                            DocumentsSource="{Binding BitmapManager.Documents}">
-                    <DockingManager.Theme>
-                        <avalonDockTheme:PixiEditorDockTheme />
-                    </DockingManager.Theme>
+                        <DockingManager.Theme>
+                            <avalonDockTheme:PixiEditorDockTheme />
+                        </DockingManager.Theme>
 
-                    <avalondock:DockingManager.LayoutItemContainerStyleSelector>
-                        <ui:PanelsStyleSelector>
-                            <ui:PanelsStyleSelector.DocumentTabStyle>
-                                <Style TargetType="{x:Type avalondock:LayoutItem}">
-                                    <Setter Property="Title" Value="{Binding Model.Name}" />
-                                    <Setter Property="CloseCommand" Value="{Binding Model.RequestCloseDocumentCommand}" />
-                                </Style>
-                            </ui:PanelsStyleSelector.DocumentTabStyle>
-                        </ui:PanelsStyleSelector>
-                    </avalondock:DockingManager.LayoutItemContainerStyleSelector>
-                    <DockingManager.LayoutItemTemplateSelector>
-                        <ui:DocumentsTemplateSelector>
-                            <ui:DocumentsTemplateSelector.DocumentsViewTemplate>
-                                <DataTemplate DataType="{x:Type dataHolders:Document}">
-                                    <usercontrols:DrawingViewPort
+                        <avalondock:DockingManager.LayoutItemContainerStyleSelector>
+                            <ui:PanelsStyleSelector>
+                                <ui:PanelsStyleSelector.DocumentTabStyle>
+                                    <Style TargetType="{x:Type avalondock:LayoutItem}">
+                                        <Setter Property="Title" Value="{Binding Model.Name}" />
+                                        <Setter Property="CloseCommand" Value="{Binding Model.RequestCloseDocumentCommand}" />
+                                    </Style>
+                                </ui:PanelsStyleSelector.DocumentTabStyle>
+                            </ui:PanelsStyleSelector>
+                        </avalondock:DockingManager.LayoutItemContainerStyleSelector>
+                        <DockingManager.LayoutItemTemplateSelector>
+                            <ui:DocumentsTemplateSelector>
+                                <ui:DocumentsTemplateSelector.DocumentsViewTemplate>
+                                    <DataTemplate DataType="{x:Type dataHolders:Document}">
+                                        <usercontrols:DrawingViewPort
                                         CenterViewportTrigger="{Binding CenterViewportTrigger}"
                                         ZoomViewportTrigger="{Binding ZoomViewportTrigger}"
                                         GridLinesVisible="{Binding XamlAccesibleViewModel.ViewportSubViewModel.GridLinesEnabled}"
@@ -517,128 +520,123 @@
                                         IsUsingZoomTool="{Binding XamlAccesibleViewModel.ToolsSubViewModel.ActiveTool, Converter={converters:IsSpecifiedTypeConverter SpecifiedType={x:Type tools:ZoomTool}}}"
                                         IsUsingMoveViewportTool="{Binding XamlAccesibleViewModel.ToolsSubViewModel.ActiveTool, Converter={converters:IsSpecifiedTypeConverter SpecifiedType={x:Type tools:MoveViewportTool}}}"
                                         Stylus.IsTapFeedbackEnabled="False" Stylus.IsTouchFeedbackEnabled="False">
-                                        <i:Interaction.Triggers>
-                                            <i:EventTrigger EventName="PreviewMouseDown">
-                                                <i:InvokeCommandAction Command="{Binding SetAsActiveOnClickCommand}"/>
-                                            </i:EventTrigger>
-                                        </i:Interaction.Triggers>
-                                        <usercontrols:DrawingViewPort.ContextMenu>
-                                            <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
-                                                <ContextMenu.Template>
-                                                    <ControlTemplate>
-                                                        <Border Height="120" Background="{StaticResource AccentColor}" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
-                                                            <Grid>
-                                                                <Grid.ColumnDefinitions>
-                                                                    <ColumnDefinition Width="100"/>
-                                                                    <ColumnDefinition Width="{Binding XamlAccesibleViewModel.BitmapManager.ActiveDocument.Palette, Converter={converters:PaletteItemsToWidthConverter}}"/>
-                                                                </Grid.ColumnDefinitions>
-                                                                <Border BorderThickness="0 0 1 0" BorderBrush="Black">
-                                                                    <StackPanel Orientation="Vertical" Grid.Column="0">
-                                                                    <MenuItem
+                                            <i:Interaction.Triggers>
+                                                <i:EventTrigger EventName="PreviewMouseDown">
+                                                    <i:InvokeCommandAction Command="{Binding SetAsActiveOnClickCommand}"/>
+                                                </i:EventTrigger>
+                                            </i:Interaction.Triggers>
+                                            <usercontrols:DrawingViewPort.ContextMenu>
+                                                <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
+                                                    <ContextMenu.Template>
+                                                        <ControlTemplate>
+                                                            <Border Height="120" Background="{StaticResource AccentColor}" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
+                                                                <Grid>
+                                                                    <Grid.ColumnDefinitions>
+                                                                        <ColumnDefinition Width="100"/>
+                                                                        <ColumnDefinition Width="{Binding XamlAccesibleViewModel.BitmapManager.ActiveDocument.Palette, Converter={converters:PaletteItemsToWidthConverter}}"/>
+                                                                    </Grid.ColumnDefinitions>
+                                                                    <Border BorderThickness="0 0 1 0" BorderBrush="Black">
+                                                                        <StackPanel Orientation="Vertical" Grid.Column="0">
+                                                                            <MenuItem
 																		Header="_Select All"
 																		cmds:ContextMenu.Command="PixiEditor.Selection.SelectAll" />
-																	<MenuItem
+                                                                            <MenuItem
 																		Header="_Deselect"
 																		cmds:ContextMenu.Command="PixiEditor.Selection.Clear" />
-																	<Separator />
-																	<MenuItem
+                                                                            <Separator />
+                                                                            <MenuItem
 																		Header="_Cut"
 																		cmds:ContextMenu.Command="PixiEditor.Clipboard.Cut" />
-																	<MenuItem
+                                                                            <MenuItem
 																		Header="_Copy"
 																		cmds:ContextMenu.Command="PixiEditor.Clipboard.Copy" />
-																	<MenuItem
+                                                                            <MenuItem
 																		Header="_Paste"
 																		cmds:ContextMenu.Command="PixiEditor.Clipboard.Paste" />
-                                                                    </StackPanel>
-                                                                </Border>
-                                                                <ScrollViewer Margin="5" Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
-                                                                    <ItemsControl ItemsSource="{Binding XamlAccesibleViewModel.BitmapManager.ActiveDocument.Palette}" AlternationCount="9999">
-                                                                        <ItemsControl.ItemsPanel>
-                                                                            <ItemsPanelTemplate>
-                                                                                <WrapPanel Orientation="Horizontal"
+                                                                        </StackPanel>
+                                                                    </Border>
+                                                                    <ScrollViewer Margin="5" Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
+                                                                        <ItemsControl ItemsSource="{Binding XamlAccesibleViewModel.BitmapManager.ActiveDocument.Palette}" AlternationCount="9999">
+                                                                            <ItemsControl.ItemsPanel>
+                                                                                <ItemsPanelTemplate>
+                                                                                    <WrapPanel Orientation="Horizontal"
                                   HorizontalAlignment="Left" VerticalAlignment="Top"/>
-                                                                            </ItemsPanelTemplate>
-                                                                        </ItemsControl.ItemsPanel>
-                                                                        <ItemsControl.ItemTemplate>
-                                                                            <DataTemplate>
-                                                                                <palettes:PaletteColor Cursor="Hand" CornerRadius="0" ToolTip="Click to select as main color." Width="22" Height="22" Color="{Binding}">
-                                                                                    <b:Interaction.Triggers>
-                                                                                        <b:EventTrigger EventName="MouseLeftButtonUp">
-                                                                                            <b:InvokeCommandAction
+                                                                                </ItemsPanelTemplate>
+                                                                            </ItemsControl.ItemsPanel>
+                                                                            <ItemsControl.ItemTemplate>
+                                                                                <DataTemplate>
+                                                                                    <palettes:PaletteColor Cursor="Hand" CornerRadius="0" ToolTip="Click to select as main color." Width="22" Height="22" Color="{Binding}">
+                                                                                        <b:Interaction.Triggers>
+                                                                                            <b:EventTrigger EventName="MouseLeftButtonUp">
+                                                                                                <b:InvokeCommandAction
                                      Command="{Binding DataContext.XamlAccesibleViewModel.ColorsSubViewModel.SelectColorCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"
                                     CommandParameter="{Binding}" />
-                                                                                        </b:EventTrigger>
-                                                                                    </b:Interaction.Triggers>
-                                                                                </palettes:PaletteColor>
-                                                                            </DataTemplate>
-                                                                        </ItemsControl.ItemTemplate>
-                                                                    </ItemsControl>
-                                                                </ScrollViewer>
-                                                            </Grid>
-                                                        </Border>
-                                                    </ControlTemplate>
-                                                </ContextMenu.Template>
-                                            </ContextMenu>
-                                        </usercontrols:DrawingViewPort.ContextMenu>
-                                    </usercontrols:DrawingViewPort>
-                                </DataTemplate>
-                            </ui:DocumentsTemplateSelector.DocumentsViewTemplate>
-                        </ui:DocumentsTemplateSelector>
-                    </DockingManager.LayoutItemTemplateSelector>
-                    <avalondock:LayoutRoot x:Name="LayoutRoot">
-                        <LayoutPanel Orientation="Horizontal">
-                            <LayoutDocumentPane/>
-                            <LayoutAnchorablePaneGroup Orientation="Vertical" DockWidth="290">
+                                                                                            </b:EventTrigger>
+                                                                                        </b:Interaction.Triggers>
+                                                                                    </palettes:PaletteColor>
+                                                                                </DataTemplate>
+                                                                            </ItemsControl.ItemTemplate>
+                                                                        </ItemsControl>
+                                                                    </ScrollViewer>
+                                                                </Grid>
+                                                            </Border>
+                                                        </ControlTemplate>
+                                                    </ContextMenu.Template>
+                                                </ContextMenu>
+                                            </usercontrols:DrawingViewPort.ContextMenu>
+                                        </usercontrols:DrawingViewPort>
+                                    </DataTemplate>
+                                </ui:DocumentsTemplateSelector.DocumentsViewTemplate>
+                            </ui:DocumentsTemplateSelector>
+                        </DockingManager.LayoutItemTemplateSelector>
+                        <avalondock:LayoutRoot x:Name="LayoutRoot">
+                            <LayoutPanel Orientation="Horizontal">
+                                <LayoutDocumentPane/>
+                                <LayoutAnchorablePaneGroup Orientation="Vertical" DockWidth="290">
 
-                                <LayoutAnchorablePane x:Name="colorPane">
-                                    <LayoutAnchorable ContentId="colorPicker" Title="Color Picker" CanHide="False"
+                                    <LayoutAnchorablePane x:Name="colorPane">
+                                        <LayoutAnchorable ContentId="colorPicker" Title="Color Picker" CanHide="False"
                                                       CanClose="False" CanAutoHide="False" x:Name="colorPickerPanel"
                                                       CanDockAsTabbedDocument="False" CanFloat="True">
-                                        <usercontrols:SmallColorPicker SelectedColor="{Binding ColorsSubViewModel.PrimaryColor, Mode=TwoWay, Converter={StaticResource SKColorToMediaColorConverter}}"
+                                            <usercontrols:SmallColorPicker SelectedColor="{Binding ColorsSubViewModel.PrimaryColor, Mode=TwoWay, Converter={StaticResource SKColorToMediaColorConverter}}"
                                                                          SecondaryColor="{Binding ColorsSubViewModel.SecondaryColor, Mode=TwoWay, Converter={StaticResource SKColorToMediaColorConverter}}" 
                                                                          Style="{StaticResource DefaultColorPickerStyle}" x:Name="mainColorPicker">
-                                            <i:Interaction.Behaviors>
-                                                <behaviours:GlobalShortcutFocusBehavior/>
-                                            </i:Interaction.Behaviors>
-                                        </usercontrols:SmallColorPicker>
-                                    </LayoutAnchorable>
-                                    <LayoutAnchorable ContentId="colorSliders" Title="Color Sliders" CanHide="False"
+                                                <i:Interaction.Behaviors>
+                                                    <behaviours:GlobalShortcutFocusBehavior/>
+                                                </i:Interaction.Behaviors>
+                                            </usercontrols:SmallColorPicker>
+                                        </LayoutAnchorable>
+                                        <LayoutAnchorable ContentId="colorSliders" Title="Color Sliders" CanHide="False"
                                                       CanClose="False" CanAutoHide="False" x:Name="colorSlidersPanel"
                                                       CanDockAsTabbedDocument="False" CanFloat="True">
-                                        <colorpicker:ColorSliders Style="{StaticResource DefaultColorPickerStyle}" 
+                                            <colorpicker:ColorSliders Style="{StaticResource DefaultColorPickerStyle}" 
                                                                   ColorState="{Binding ElementName=mainColorPicker, Path=ColorState, Delay=10, Mode=TwoWay}">
-                                            <i:Interaction.Behaviors>
-                                                <behaviours:GlobalShortcutFocusBehavior/>
-                                            </i:Interaction.Behaviors>
-                                        </colorpicker:ColorSliders>
-                                    </LayoutAnchorable>
-                                    <avalondock:LayoutAnchorable ContentId="palette" Title="Palette" CanHide="False"
+                                                <i:Interaction.Behaviors>
+                                                    <behaviours:GlobalShortcutFocusBehavior/>
+                                                </i:Interaction.Behaviors>
+                                            </colorpicker:ColorSliders>
+                                        </LayoutAnchorable>
+                                        <avalondock:LayoutAnchorable ContentId="palette" Title="Palette" CanHide="False"
                                                                  CanClose="False" CanAutoHide="False" x:Name="paletteAnchorable"
                                                                  CanDockAsTabbedDocument="False" CanFloat="True">
-                                        <Grid>
-                                            <palettes:CompactPaletteViewer IsEnabled="{Binding DocumentSubViewModel.Owner.BitmapManager.ActiveDocument,
-                                        Converter={converters:NotNullToBoolConverter}}"
-                                                                           SelectColorCommand="{Binding ColorsSubViewModel.SelectColorCommand}"
-                                                                           Colors="{Binding BitmapManager.ActiveDocument.Palette}" 
-                                                                           Visibility="{Binding RelativeSource={RelativeSource Mode=Self}, 
-                                                Path=ActualWidth, Converter={converters:PaletteViewerWidthToVisibilityConverter}}"/>
-                                            <palettes:PaletteViewer IsEnabled="{Binding DocumentSubViewModel.Owner.BitmapManager.ActiveDocument,
-                                        Converter={converters:NotNullToBoolConverter}}" Colors="{Binding BitmapManager.ActiveDocument.Palette}"
-                                                              Swatches="{Binding BitmapManager.ActiveDocument.Swatches}"
-                                                                    SelectColorCommand="{Binding ColorsSubViewModel.SelectColorCommand}"
-                                                              HintColor="{Binding Path=ColorsSubViewModel.PrimaryColor,
-                                                Converter={converters:SKColorToMediaColorConverter}}"
-                                                                DataSources="{Binding ColorsSubViewModel.PaletteDataSources}"
-                                                                FileParsers="{Binding ColorsSubViewModel.PaletteParsers}"
-                                                                    Visibility="{Binding RelativeSource={RelativeSource Mode=Self}, 
-                                                Path=ActualWidth, Converter={converters:PaletteViewerWidthToVisibilityConverter},
-                                                ConverterParameter=Hidden}"
-                                                                ImportPaletteCommand="{Binding ColorsSubViewModel.ImportPaletteCommand}"
-                                                                           ReplaceColorsCommand="{Binding ColorsSubViewModel.ReplaceColorsCommand}"/>
-                                        </Grid>
-                                    </avalondock:LayoutAnchorable>
-                                    <avalondock:LayoutAnchorable
+                                            <Grid>
+                                                <palettes:CompactPaletteViewer 
+                                                    IsEnabled="{Binding DocumentSubViewModel.Owner.BitmapManager.ActiveDocument, Converter={converters:NotNullToBoolConverter}}"
+                                                    SelectColorCommand="{cmds:Command PixiEditor.Colors.SelectColor, UseProvided=True}"
+                                                    Colors="{Binding BitmapManager.ActiveDocument.Palette}" 
+                                                    Visibility="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualWidth, Converter={converters:PaletteViewerWidthToVisibilityConverter}}"/>
+                                                <palettes:PaletteViewer IsEnabled="{Binding DocumentSubViewModel.Owner.BitmapManager.ActiveDocument, Converter={converters:NotNullToBoolConverter}}" Colors="{Binding BitmapManager.ActiveDocument.Palette}"
+                                                    Swatches="{Binding BitmapManager.ActiveDocument.Swatches}"
+                                                    SelectColorCommand="{cmds:Command PixiEditor.Colors.SelectColor, UseProvided=True}"
+                                                    HintColor="{Binding Path=ColorsSubViewModel.PrimaryColor,Converter={converters:SKColorToMediaColorConverter}}"
+                                                    DataSources="{Binding ColorsSubViewModel.PaletteDataSources}"
+                                                    FileParsers="{Binding ColorsSubViewModel.PaletteParsers}"
+                                                    Visibility="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualWidth, Converter={converters:PaletteViewerWidthToVisibilityConverter}, ConverterParameter=Hidden}"
+                                                    ImportPaletteCommand="{cmds:Command PixiEditor.Colors.ImportPalette, UseProvided=True}"
+                                                    ReplaceColorsCommand="{cmds:Command PixiEditor.Colors.ReplaceColors, UseProvided=True}"/>
+                                            </Grid>
+                                        </avalondock:LayoutAnchorable>
+                                        <avalondock:LayoutAnchorable
 										ContentId="swatches"
 										Title="Swatches"
 										CanHide="False"
@@ -646,13 +644,12 @@
 										CanAutoHide="False"
 										CanDockAsTabbedDocument="False"
 										CanFloat="True">
-										<usercontrols:SwatchesView
-											SelectSwatchCommand="{cmds:Command PixiEditor.Colors.SelectColor, UseProvided=True}"
-											RemoveSwatchCommand="{cmds:Command PixiEditor.Colors.RemoveSwatch, UseProvided=True}"
-											Swatches="{Binding BitmapManager.ActiveDocument.Swatches}" />
-									</avalondock:LayoutAnchorable>
-                                </LayoutAnchorablePane>
-                                <LayoutAnchorablePane>
+                                            <usercontrols:SwatchesView
+											    SelectSwatchCommand="{cmds:Command PixiEditor.Colors.SelectColor, UseProvided=True}"
+											    Swatches="{Binding BitmapManager.ActiveDocument.Swatches}" />
+                                        </avalondock:LayoutAnchorable>
+                                    </LayoutAnchorablePane>
+                                    <LayoutAnchorablePane>
                                         <LayoutAnchorable
                                             ContentId="layers"
                                             Title="Layers"
@@ -698,14 +695,14 @@
                                                 PrimaryColor="{Binding ColorsSubViewModel.PrimaryColor, Mode=TwoWay, Converter={StaticResource SKColorToMediaColorConverter}}" />
                                         </LayoutAnchorable>
                                     </LayoutAnchorablePane>
-                            </LayoutAnchorablePaneGroup>
-                        </LayoutPanel>
-                    </avalondock:LayoutRoot>
-                </DockingManager>
+                                </LayoutAnchorablePaneGroup>
+                            </LayoutPanel>
+                        </avalondock:LayoutRoot>
+                    </DockingManager>
+                </Grid>
             </Grid>
-        </Grid>
 
-        <Border
+            <Border
                 Grid.Row="2"
                 Grid.Column="0"
                 Background="{StaticResource AccentColor}"
@@ -818,4 +815,4 @@
             Height="700"
             MaxWidth="920" />
     </Grid>
-</Window>
+</Window>

+ 3 - 4
PixiEditor/Views/UserControls/AlignableWrapPanel.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Windows;
+using System.Windows;
 using System.Windows.Controls;
 
 namespace PixiEditor.Views.UserControls
@@ -13,7 +12,7 @@ namespace PixiEditor.Views.UserControls
         }
 
         public static readonly DependencyProperty HorizontalContentAlignmentProperty =
-            DependencyProperty.Register("HorizontalContentAlignment", typeof(HorizontalAlignment), typeof(AlignableWrapPanel), new FrameworkPropertyMetadata(HorizontalAlignment.Left, FrameworkPropertyMetadataOptions.AffectsArrange));
+            DependencyProperty.Register(nameof(HorizontalContentAlignment), typeof(HorizontalAlignment), typeof(AlignableWrapPanel), new FrameworkPropertyMetadata(HorizontalAlignment.Left, FrameworkPropertyMetadataOptions.AffectsArrange));
 
         protected override Size MeasureOverride(Size constraint)
         {
@@ -119,4 +118,4 @@ namespace PixiEditor.Views.UserControls
             }
         }
     }
-}
+}

+ 1 - 1
PixiEditor/Views/UserControls/AnchorPointPicker.xaml.cs

@@ -11,7 +11,7 @@ namespace PixiEditor.Views
     public partial class AnchorPointPicker : UserControl
     {
         public static readonly DependencyProperty AnchorPointProperty =
-            DependencyProperty.Register("AnchorPoint", typeof(AnchorPoint), typeof(AnchorPointPicker),
+            DependencyProperty.Register(nameof(AnchorPoint), typeof(AnchorPoint), typeof(AnchorPointPicker),
                 new PropertyMetadata());
 
 

+ 11 - 15
PixiEditor/Views/UserControls/EditableTextBlock.xaml.cs

@@ -1,9 +1,8 @@
-using System;
+using PixiEditor.Models.Controllers;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Threading;
-using PixiEditor.Models.Controllers;
 
 namespace PixiEditor.Views
 {
@@ -12,26 +11,23 @@ namespace PixiEditor.Views
     /// </summary>
     public partial class EditableTextBlock : UserControl
     {
-        // Using a DependencyProperty as the backing store for TextBlockVisibility.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty TextBlockVisibilityProperty =
-            DependencyProperty.Register(
-                "TextBlockVisibility",
+            DependencyProperty.Register(nameof(TextBlockVisibility),
                 typeof(Visibility),
                 typeof(EditableTextBlock),
                 new PropertyMetadata(Visibility.Visible));
 
-        // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty TextProperty =
-            DependencyProperty.Register(
-                "Text",
+            DependencyProperty.Register(nameof(Text),
                 typeof(string),
                 typeof(EditableTextBlock),
                 new PropertyMetadata(default(string)));
 
-        // Using a DependencyProperty as the backing store for EnableEditing.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty EnableEditingProperty =
-            DependencyProperty.Register(
-                "IsEditing",
+            DependencyProperty.Register(nameof(IsEditing),
                 typeof(bool),
                 typeof(EditableTextBlock),
                 new PropertyMetadata(OnIsEditingChanged));
@@ -42,9 +38,9 @@ namespace PixiEditor.Views
             set { SetValue(MaxCharsProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for MaxChars.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty MaxCharsProperty =
-            DependencyProperty.Register("MaxChars", typeof(int), typeof(EditableTextBlock), new PropertyMetadata(int.MaxValue));
+            DependencyProperty.Register(nameof(MaxChars), typeof(int), typeof(EditableTextBlock), new PropertyMetadata(int.MaxValue));
 
 
         public event EventHandler<TextChangedEventArgs> OnSubmit;
@@ -79,7 +75,7 @@ namespace PixiEditor.Views
             IsEditing = true;
             Dispatcher.BeginInvoke(
                 DispatcherPriority.Input,
-                new Action(delegate()
+                new Action(delegate ()
                 {
                     textBox.Focus();         // Set Logical Focus
                     Keyboard.Focus(textBox); // Set Keyboard Focus
@@ -143,4 +139,4 @@ namespace PixiEditor.Views
             }
         }
     }
-}
+}

+ 5 - 10
PixiEditor/Views/UserControls/InputBox.cs

@@ -1,9 +1,4 @@
 using PixiEditor.Models.Events;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
@@ -18,9 +13,9 @@ namespace PixiEditor.Views.UserControls
             set { SetValue(SubmitCommandProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for SubmitCommand.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty SubmitCommandProperty =
-            DependencyProperty.Register("SubmitCommand", typeof(ICommand), typeof(InputBox));
+            DependencyProperty.Register(nameof(SubmitCommand), typeof(ICommand), typeof(InputBox));
 
         public object SubmitCommandParameter
         {
@@ -28,9 +23,9 @@ namespace PixiEditor.Views.UserControls
             set { SetValue(SubmitCommandParameterProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for SubmitCommandParameter.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty SubmitCommandParameterProperty =
-            DependencyProperty.Register("SubmitCommandParameter", typeof(object), typeof(InputBox), new PropertyMetadata(null));
+            DependencyProperty.Register(nameof(SubmitCommandParameter), typeof(object), typeof(InputBox), new PropertyMetadata(null));
 
         public event EventHandler<InputBoxEventArgs> OnSubmit;
 
@@ -46,7 +41,7 @@ namespace PixiEditor.Views.UserControls
         {
             if (e.Key != Key.Enter) return;
 
-            if(SubmitCommand != null && SubmitCommand.CanExecute(SubmitCommandParameter))
+            if (SubmitCommand != null && SubmitCommand.CanExecute(SubmitCommandParameter))
             {
                 SubmitCommand.Execute(SubmitCommandParameter);
             }

+ 7 - 9
PixiEditor/Views/UserControls/Layers/LayerGroupControl.xaml.cs

@@ -2,8 +2,6 @@
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Undo;
 using PixiEditor.ViewModels.SubViewModels.Main;
-using System;
-using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
@@ -23,7 +21,7 @@ namespace PixiEditor.Views.UserControls.Layers
         }
 
         public static readonly DependencyProperty GroupGuidProperty =
-            DependencyProperty.Register("GroupGuid", typeof(Guid), typeof(LayerGroupControl), new PropertyMetadata(Guid.NewGuid()));
+            DependencyProperty.Register(nameof(GroupGuid), typeof(Guid), typeof(LayerGroupControl), new PropertyMetadata(Guid.NewGuid()));
 
         public LayersViewModel LayersViewModel
         {
@@ -32,7 +30,7 @@ namespace PixiEditor.Views.UserControls.Layers
         }
 
         public static readonly DependencyProperty LayersViewModelProperty =
-            DependencyProperty.Register("LayersViewModel", typeof(LayersViewModel), typeof(LayerGroupControl), new PropertyMetadata(default(LayersViewModel), LayersViewModelCallback));
+            DependencyProperty.Register(nameof(LayersViewModel), typeof(LayersViewModel), typeof(LayerGroupControl), new PropertyMetadata(default(LayersViewModel), LayersViewModelCallback));
 
         public bool IsVisibleUndoTriggerable
         {
@@ -41,7 +39,7 @@ namespace PixiEditor.Views.UserControls.Layers
         }
 
         public static readonly DependencyProperty IsVisibleUndoTriggerableProperty =
-            DependencyProperty.Register("IsVisibleUndoTriggerable", typeof(bool), typeof(LayerGroupControl), new PropertyMetadata(true));
+            DependencyProperty.Register(nameof(IsVisibleUndoTriggerable), typeof(bool), typeof(LayerGroupControl), new PropertyMetadata(true));
 
         public float GroupOpacity
         {
@@ -50,7 +48,7 @@ namespace PixiEditor.Views.UserControls.Layers
         }
 
         public static readonly DependencyProperty GroupOpacityProperty =
-            DependencyProperty.Register("GroupOpacity", typeof(float), typeof(LayerGroupControl), new PropertyMetadata(1f));
+            DependencyProperty.Register(nameof(GroupOpacity), typeof(float), typeof(LayerGroupControl), new PropertyMetadata(1f));
 
 
         public static string LayerGroupControlDataName = typeof(LayerGroupControl).FullName;
@@ -77,7 +75,7 @@ namespace PixiEditor.Views.UserControls.Layers
         }
 
         public static readonly DependencyProperty GroupNameProperty =
-            DependencyProperty.Register("GroupName", typeof(string), typeof(LayerGroupControl), new PropertyMetadata(default(string)));
+            DependencyProperty.Register(nameof(GroupName), typeof(string), typeof(LayerGroupControl), new PropertyMetadata(default(string)));
 
         public GuidStructureItem GroupData
         {
@@ -86,7 +84,7 @@ namespace PixiEditor.Views.UserControls.Layers
         }
 
         public static readonly DependencyProperty GroupDataProperty =
-            DependencyProperty.Register("GroupData", typeof(GuidStructureItem), typeof(LayerGroupControl), new PropertyMetadata(default(GuidStructureItem), GroupDataChangedCallback));
+            DependencyProperty.Register(nameof(GroupData), typeof(GuidStructureItem), typeof(LayerGroupControl), new PropertyMetadata(default(GuidStructureItem), GroupDataChangedCallback));
 
         public void GeneratePreviewImage()
         {
@@ -115,7 +113,7 @@ namespace PixiEditor.Views.UserControls.Layers
         }
 
         public static readonly DependencyProperty PreviewImageProperty =
-            DependencyProperty.Register("PreviewImage", typeof(WriteableBitmap), typeof(LayerGroupControl), new PropertyMetadata(default(WriteableBitmap)));
+            DependencyProperty.Register(nameof(PreviewImage), typeof(WriteableBitmap), typeof(LayerGroupControl), new PropertyMetadata(default(WriteableBitmap)));
 
         public LayerGroupControl()
         {

+ 10 - 10
PixiEditor/Views/UserControls/Layers/LayerStructureItemContainer.xaml.cs

@@ -1,7 +1,7 @@
-using System.Windows;
-using System.Windows.Controls;
-using PixiEditor.Models.Layers;
+using PixiEditor.Models.Layers;
 using PixiEditor.ViewModels.SubViewModels.Main;
+using System.Windows;
+using System.Windows.Controls;
 
 namespace PixiEditor.Views.UserControls.Layers
 {
@@ -16,9 +16,9 @@ namespace PixiEditor.Views.UserControls.Layers
             set { SetValue(LayerProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for Layer.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty LayerProperty =
-            DependencyProperty.Register("Layer", typeof(Layer), typeof(LayerStructureItemContainer), new PropertyMetadata(default(Layer)));
+            DependencyProperty.Register(nameof(Layer), typeof(Layer), typeof(LayerStructureItemContainer), new PropertyMetadata(default(Layer)));
 
         public LayersViewModel LayerCommandsViewModel
         {
@@ -26,9 +26,9 @@ namespace PixiEditor.Views.UserControls.Layers
             set { SetValue(LayerCommandsViewModelProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty LayerCommandsViewModelProperty =
-            DependencyProperty.Register("LayerCommandsViewModel", typeof(LayersViewModel), typeof(LayerStructureItemContainer), new PropertyMetadata(default(LayersViewModel)));
+            DependencyProperty.Register(nameof(LayerCommandsViewModel), typeof(LayersViewModel), typeof(LayerStructureItemContainer), new PropertyMetadata(default(LayersViewModel)));
 
         public int ContainerIndex
         {
@@ -36,13 +36,13 @@ namespace PixiEditor.Views.UserControls.Layers
             set { SetValue(ContainerIndexProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for ContainerIndex.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty ContainerIndexProperty =
-            DependencyProperty.Register("ContainerIndex", typeof(int), typeof(LayerStructureItemContainer), new PropertyMetadata(0));
+            DependencyProperty.Register(nameof(ContainerIndex), typeof(int), typeof(LayerStructureItemContainer), new PropertyMetadata(0));
 
         public LayerStructureItemContainer()
         {
             InitializeComponent();
         }
     }
-}
+}

+ 6 - 9
PixiEditor/Views/UserControls/Layers/RawLayersViewer.xaml.cs

@@ -1,9 +1,7 @@
-using System;
+using PixiEditor.Models.Layers;
 using System.Collections.ObjectModel;
-using System.Diagnostics;
 using System.Windows;
 using System.Windows.Controls;
-using PixiEditor.Models.Layers;
 
 namespace PixiEditor.Views.UserControls.Layers
 {
@@ -18,10 +16,9 @@ namespace PixiEditor.Views.UserControls.Layers
             set { SetValue(LayersProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for Layers.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty LayersProperty =
-            DependencyProperty.Register(
-                "Layers",
+            DependencyProperty.Register(nameof(Layers),
                 typeof(ObservableCollection<Layer>),
                 typeof(RawLayersViewer),
                 new PropertyMetadata(default(ObservableCollection<Layer>)));
@@ -32,13 +29,13 @@ namespace PixiEditor.Views.UserControls.Layers
             set { SetValue(StructureProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for Structure.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty StructureProperty =
-            DependencyProperty.Register("Structure", typeof(LayerStructure), typeof(RawLayersViewer), new PropertyMetadata(default(LayerStructure)));
+            DependencyProperty.Register(nameof(Structure), typeof(LayerStructure), typeof(RawLayersViewer), new PropertyMetadata(default(LayerStructure)));
 
         public RawLayersViewer()
         {
             InitializeComponent();
         }
     }
-}
+}

+ 2 - 5
PixiEditor/Views/UserControls/Layers/ReferenceLayer.xaml.cs

@@ -1,12 +1,9 @@
 using Microsoft.Win32;
-using PixiEditor.Helpers;
-using PixiEditor.Models.Enums;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.Layers;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
-using static PixiEditor.Helpers.SupportedFilesHelper;
 
 namespace PixiEditor.Views.UserControls.Layers
 {
@@ -21,9 +18,9 @@ namespace PixiEditor.Views.UserControls.Layers
             set { SetValue(ReferenceLayerProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for ReferenceLayer.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty ReferenceLayerProperty =
-            DependencyProperty.Register("Layer", typeof(Layer), typeof(ReferenceLayer), new PropertyMetadata(default(Layer)));
+            DependencyProperty.Register(nameof(Layer), typeof(Layer), typeof(ReferenceLayer), new PropertyMetadata(default(Layer)));
 
 
         public ReferenceLayer()

+ 3 - 10
PixiEditor/Views/UserControls/ListSwitchButton.cs

@@ -1,14 +1,10 @@
-using System;
-using System.Collections.ObjectModel;
+using System.Collections.ObjectModel;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
 
 namespace PixiEditor.Views.UserControls
 {
-    /// <summary>
-    /// Interaction logic for ListSwitchButton.xaml
-    /// </summary>
     public class ListSwitchButton : Button
     {
         public ObservableCollection<SwitchItem> Items
@@ -17,9 +13,8 @@ namespace PixiEditor.Views.UserControls
             set { SetValue(ItemsProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for Items.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty ItemsProperty =
-            DependencyProperty.Register("Items", typeof(ObservableCollection<SwitchItem>), typeof(ListSwitchButton), new PropertyMetadata(default(ObservableCollection<SwitchItem>), CollChanged));
+            DependencyProperty.Register(nameof(Items), typeof(ObservableCollection<SwitchItem>), typeof(ListSwitchButton), new PropertyMetadata(default(ObservableCollection<SwitchItem>), CollChanged));
 
         private static void CollChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
@@ -39,10 +34,8 @@ namespace PixiEditor.Views.UserControls
             set { SetValue(ActiveItemProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for ActiveItem.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty ActiveItemProperty =
-            DependencyProperty.Register("ActiveItem", typeof(SwitchItem), typeof(ListSwitchButton), new PropertyMetadata(new SwitchItem(Brushes.Transparent, "", null)));
-
+            DependencyProperty.Register(nameof(ActiveItem), typeof(SwitchItem), typeof(ListSwitchButton), new PropertyMetadata(new SwitchItem(Brushes.Transparent, "", null)));
 
         static ListSwitchButton()
         {

+ 4 - 13
PixiEditor/Views/UserControls/NumberInput.xaml.cs

@@ -10,7 +10,6 @@ namespace PixiEditor.Views
     /// </summary>
     public partial class NumberInput : UserControl
     {
-        // Using a DependencyProperty as the backing store for Value.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty ValueProperty =
             DependencyProperty.Register(
                 nameof(Value),
@@ -18,7 +17,6 @@ namespace PixiEditor.Views
                 typeof(NumberInput),
                 new PropertyMetadata(0f, OnValueChanged));
 
-        // Using a DependencyProperty as the backing store for Min.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty MinProperty =
             DependencyProperty.Register(
                 nameof(Min),
@@ -26,7 +24,6 @@ namespace PixiEditor.Views
                 typeof(NumberInput),
                 new PropertyMetadata(float.NegativeInfinity));
 
-        // Using a DependencyProperty as the backing store for Max.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty MaxProperty =
             DependencyProperty.Register(
                 nameof(Max),
@@ -36,17 +33,14 @@ namespace PixiEditor.Views
 
         private readonly Regex regex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$", RegexOptions.Compiled);
 
-
         public int Decimals
         {
             get { return (int)GetValue(DecimalsProperty); }
             set { SetValue(DecimalsProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for Precision.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty DecimalsProperty =
-            DependencyProperty.Register("Decimals", typeof(int), typeof(NumberInput), new PropertyMetadata(2));
-
+            DependencyProperty.Register(nameof(Decimals), typeof(int), typeof(NumberInput), new PropertyMetadata(2));
 
         public Action OnScrollAction
         {
@@ -54,10 +48,8 @@ namespace PixiEditor.Views
             set { SetValue(OnScrollActionProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for OnScrollAction.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty OnScrollActionProperty =
-            DependencyProperty.Register("OnScrollAction", typeof(Action), typeof(NumberInput), new PropertyMetadata(null));
-
+            DependencyProperty.Register(nameof(OnScrollAction), typeof(Action), typeof(NumberInput), new PropertyMetadata(null));
 
         public NumberInput()
         {
@@ -82,8 +74,7 @@ namespace PixiEditor.Views
             set => SetValue(MaxProperty, value);
         }
 
-        public static readonly DependencyProperty FocusNextProperty = DependencyProperty.Register(
-            "FocusNext", typeof(bool), typeof(NumberInput), new PropertyMetadata(false));
+        public static readonly DependencyProperty FocusNextProperty = DependencyProperty.Register(nameof(FocusNext), typeof(bool), typeof(NumberInput), new PropertyMetadata(false));
 
         public bool FocusNext
         {
@@ -123,4 +114,4 @@ namespace PixiEditor.Views
             OnScrollAction?.Invoke();
         }
     }
-}
+}

+ 9 - 10
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml.cs

@@ -14,9 +14,9 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(ColorToReplaceProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for ColorToReplace.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty ColorToReplaceProperty =
-            DependencyProperty.Register("ColorToReplace", typeof(SKColor), typeof(ColorReplacer), new PropertyMetadata(SKColors.White));
+            DependencyProperty.Register(nameof(ColorToReplace), typeof(SKColor), typeof(ColorReplacer), new PropertyMetadata(SKColors.White));
 
 
         public Color HintColor
@@ -31,8 +31,7 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(NewColorProperty, value); }
         }
 
-        public static readonly DependencyProperty ReplaceColorsCommandProperty = DependencyProperty.Register(
-            "ReplaceColorsCommand", typeof(ICommand), typeof(ColorReplacer), new PropertyMetadata(default(ICommand)));
+        public static readonly DependencyProperty ReplaceColorsCommandProperty = DependencyProperty.Register(nameof(ReplaceColorsCommand), typeof(ICommand), typeof(ColorReplacer), new PropertyMetadata(default(ICommand)));
 
         public ICommand ReplaceColorsCommand
         {
@@ -41,14 +40,14 @@ namespace PixiEditor.Views.UserControls.Palettes
         }
 
 
-        // Using a DependencyProperty as the backing store for NewColor.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty NewColorProperty =
-            DependencyProperty.Register("NewColor", typeof(Color), typeof(ColorReplacer), new PropertyMetadata(Colors.Black));
+            DependencyProperty.Register(nameof(NewColor), typeof(Color), typeof(ColorReplacer), new PropertyMetadata(Colors.Black));
+
 
 
-        // Using a DependencyProperty as the backing store for HintColor.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty HintColorProperty =
-            DependencyProperty.Register("HintColor", typeof(Color), typeof(ColorReplacer), new PropertyMetadata(Colors.Black));
+            DependencyProperty.Register(nameof(HintColor), typeof(Color), typeof(ColorReplacer), new PropertyMetadata(Colors.Black));
 
 
 
@@ -58,9 +57,9 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(IsCollapsedProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for IsCollapsed.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty IsCollapsedProperty =
-            DependencyProperty.Register("IsCollapsed", typeof(bool), typeof(ColorReplacer), new PropertyMetadata(false));
+            DependencyProperty.Register(nameof(IsCollapsed), typeof(bool), typeof(ColorReplacer), new PropertyMetadata(false));
 
 
 

+ 3 - 4
PixiEditor/Views/UserControls/Palettes/CompactPaletteViewer.xaml.cs

@@ -11,8 +11,7 @@ namespace PixiEditor.Views.UserControls.Palettes
     /// </summary>
     public partial class CompactPaletteViewer : UserControl
     {
-        public static readonly DependencyProperty ColorsProperty = DependencyProperty.Register(
-            "Colors", typeof(WpfObservableRangeCollection<SKColor>), typeof(CompactPaletteViewer));
+        public static readonly DependencyProperty ColorsProperty = DependencyProperty.Register(nameof(Colors), typeof(WpfObservableRangeCollection<SKColor>), typeof(CompactPaletteViewer));
 
         public WpfObservableRangeCollection<SKColor> Colors
         {
@@ -26,9 +25,9 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(SelectColorCommandProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for SelectColorCommand.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty SelectColorCommandProperty =
-            DependencyProperty.Register("SelectColorCommand", typeof(ICommand), typeof(CompactPaletteViewer));
+            DependencyProperty.Register(nameof(SelectColorCommand), typeof(ICommand), typeof(CompactPaletteViewer));
 
         public CompactPaletteViewer()
         {

+ 7 - 9
PixiEditor/Views/UserControls/Palettes/PaletteColor.xaml.cs

@@ -1,8 +1,7 @@
-using System;
+using SkiaSharp;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
-using SkiaSharp;
 
 namespace PixiEditor.Views.UserControls.Palettes;
 
@@ -10,8 +9,7 @@ public partial class PaletteColor : UserControl
 {
     public const string PaletteColorDaoFormat = "PixiEditor.PaletteColor";
 
-    public static readonly DependencyProperty ColorProperty = DependencyProperty.Register(
-        "Color", typeof(SKColor), typeof(PaletteColor), new PropertyMetadata(default(SKColor)));
+    public static readonly DependencyProperty ColorProperty = DependencyProperty.Register(nameof(Color), typeof(SKColor), typeof(PaletteColor), new PropertyMetadata(default(SKColor)));
 
     public SKColor Color
     {
@@ -26,9 +24,9 @@ public partial class PaletteColor : UserControl
         set { SetValue(AssociatedKeyProperty, value); }
     }
 
-    // Using a DependencyProperty as the backing store for AssociatedKey.  This enables animation, styling, binding, etc...
+
     public static readonly DependencyProperty AssociatedKeyProperty =
-        DependencyProperty.Register("AssociatedKey", typeof(int?), typeof(PaletteColor), new PropertyMetadata(null));
+        DependencyProperty.Register(nameof(AssociatedKey), typeof(int?), typeof(PaletteColor), new PropertyMetadata(null));
 
     public CornerRadius CornerRadius
     {
@@ -36,9 +34,9 @@ public partial class PaletteColor : UserControl
         set { SetValue(CornerRadiusProperty, value); }
     }
 
-    // Using a DependencyProperty as the backing store for CornerRadius.  This enables animation, styling, binding, etc...
+
     public static readonly DependencyProperty CornerRadiusProperty =
-        DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(PaletteColor), new PropertyMetadata(new CornerRadius(5f)));
+        DependencyProperty.Register(nameof(CornerRadius), typeof(CornerRadius), typeof(PaletteColor), new PropertyMetadata(new CornerRadius(5f)));
 
     private Point clickPoint;
 
@@ -70,4 +68,4 @@ public partial class PaletteColor : UserControl
             clickPoint = e.GetPosition(this);
         }
     }
-}
+}

+ 11 - 13
PixiEditor/Views/UserControls/Palettes/PaletteColorAdder.xaml.cs

@@ -1,7 +1,6 @@
 using PixiEditor.Models.DataHolders;
 using SkiaSharp;
 using System.Collections.Specialized;
-using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
@@ -25,9 +24,9 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(HintColorProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for HintColor.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty HintColorProperty =
-            DependencyProperty.Register("HintColor", typeof(Color), typeof(PaletteColorAdder), new PropertyMetadata(System.Windows.Media.Colors.Transparent, OnHintColorChanged));
+            DependencyProperty.Register(nameof(HintColor), typeof(Color), typeof(PaletteColorAdder), new PropertyMetadata(System.Windows.Media.Colors.Transparent, OnHintColorChanged));
 
         private static void OnHintColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
@@ -39,8 +38,7 @@ namespace PixiEditor.Views.UserControls.Palettes
             }
         }
 
-        public static readonly DependencyProperty SwatchesProperty = DependencyProperty.Register(
-            "Swatches", typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteColorAdder), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>), OnSwatchesChanged));
+        public static readonly DependencyProperty SwatchesProperty = DependencyProperty.Register(nameof(Swatches), typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteColorAdder), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>), OnSwatchesChanged));
 
         public WpfObservableRangeCollection<SKColor> Swatches
         {
@@ -54,15 +52,15 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(SelectedColorProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for SelectedColor.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty SelectedColorProperty =
-            DependencyProperty.Register("SelectedColor", typeof(Color), typeof(PaletteColorAdder), 
+            DependencyProperty.Register(nameof(SelectedColor), typeof(Color), typeof(PaletteColorAdder),
                 new PropertyMetadata(System.Windows.Media.Colors.Black));
 
 
-        // Using a DependencyProperty as the backing store for Colors.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty ColorsProperty =
-            DependencyProperty.Register("Colors", typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteColorAdder), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>), OnColorsChanged));
+            DependencyProperty.Register(nameof(Colors), typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteColorAdder), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>), OnColorsChanged));
 
         private static void OnColorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
@@ -73,7 +71,7 @@ namespace PixiEditor.Views.UserControls.Palettes
                 adder.UpdateAddButton();
                 adder.Colors.CollectionChanged += adder.Colors_CollectionChanged;
             }
-            else if(e.OldValue != null)
+            else if (e.OldValue != null)
             {
                 adder.Colors.CollectionChanged -= adder.Colors_CollectionChanged;
             }
@@ -130,7 +128,7 @@ namespace PixiEditor.Views.UserControls.Palettes
             }
         }
 
-        private void PortableColorPicker_ColorChanged(object sender, RoutedEventArgs e) => 
+        private void PortableColorPicker_ColorChanged(object sender, RoutedEventArgs e) =>
             AddButton.IsEnabled = !Colors.Contains(ToSKColor(SelectedColor));
 
         private static SKColor ToSKColor(Color color) => new SKColor(color.R, color.G, color.B, color.A);
@@ -141,8 +139,8 @@ namespace PixiEditor.Views.UserControls.Palettes
 
             foreach (var color in Swatches)
             {
-                if(color.Alpha < 255) continue; // No alpha support for now, palette colors shouldn't be transparent
-                
+                if (color.Alpha < 255) continue; // No alpha support for now, palette colors shouldn't be transparent
+
                 if (!Colors.Contains(color))
                 {
                     Colors.Add(color);

+ 34 - 30
PixiEditor/Views/UserControls/Palettes/PaletteItem.xaml

@@ -4,8 +4,11 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:views="clr-namespace:PixiEditor.Views"
+             xmlns:controls="clr-namespace:PixiEditor.Views.UserControls.Palettes"
              mc:Ignorable="d"
-             d:DesignHeight="200" d:DesignWidth="800" Name="paletteItem">
+             d:DesignHeight="200" 
+             d:DesignWidth="800" 
+             Name="paletteItem">
     <UserControl.Resources>
         <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
     </UserControl.Resources>
@@ -57,16 +60,16 @@
                         </Style.Triggers>
                     </Style>
                 </Border.Style>
-            <Button
+                <Button
                     ToolTip="Use in current image" Cursor="Hand" 
-                    Command="{Binding ImportPaletteCommand, ElementName=paletteItem}"
                     Style="{StaticResource ToolButtonStyle}"
                     Margin="0 3 0 0" Width="24" Height="24"
-                    CommandParameter="{Binding ElementName=paletteItem, Path=Palette.Colors}">
-                <Button.Background>
-                    <ImageBrush ImageSource="/Images/Check-square.png"/>
-                </Button.Background>
-            </Button>
+                    CommandParameter="{Binding ElementName=paletteItem, Path=Palette.Colors}"
+                    Command="{Binding ImportPaletteCommand, ElementName=paletteItem}">
+                    <Button.Background>
+                        <ImageBrush ImageSource="/Images/Check-square.png"/>
+                    </Button.Background>
+                </Button>
             </Border>
             <Border Margin="2 0 -2 0" Width="28" Height="28" HorizontalAlignment="Right" CornerRadius="2.5"
                     Padding="2">
@@ -82,31 +85,32 @@
                         </Style.Triggers>
                     </Style>
                 </Border.Style>
-            <Button
+                <Button
                     Command="{Binding ElementName=paletteItem, Path=ToggleFavouriteCommand}"
                     CommandParameter="{Binding ElementName=paletteItem, Path=Palette}"
                     ToolTip="Add to favorites">
-                <Button.Style>
-                    <Style BasedOn="{StaticResource ImageButtonStyle}" TargetType="Button">
-                        <Style.Triggers>
-                            <DataTrigger Binding="{Binding ElementName=paletteItem, Path=Palette.IsFavourite}" Value="False">
-                                <Setter Property="Background">
-                                    <Setter.Value>
-                                        <ImageBrush ImageSource="/Images/Star.png"/>
-                                    </Setter.Value>
-                                </Setter>
-                            </DataTrigger>
-                            <DataTrigger Binding="{Binding ElementName=paletteItem, Path=Palette.IsFavourite}" Value="True">
-                                <Setter Property="Background">
-                                    <Setter.Value>
-                                        <ImageBrush ImageSource="/Images/Star-filled.png"/>
-                                    </Setter.Value>
-                                </Setter>
-                            </DataTrigger>
-                        </Style.Triggers>
-                    </Style>
-                </Button.Style>
-            </Button></Border>
+                    <Button.Style>
+                        <Style BasedOn="{StaticResource ImageButtonStyle}" TargetType="Button">
+                            <Style.Triggers>
+                                <DataTrigger Binding="{Binding ElementName=paletteItem, Path=Palette.IsFavourite}" Value="False">
+                                    <Setter Property="Background">
+                                        <Setter.Value>
+                                            <ImageBrush ImageSource="/Images/Star.png"/>
+                                        </Setter.Value>
+                                    </Setter>
+                                </DataTrigger>
+                                <DataTrigger Binding="{Binding ElementName=paletteItem, Path=Palette.IsFavourite}" Value="True">
+                                    <Setter Property="Background">
+                                        <Setter.Value>
+                                            <ImageBrush ImageSource="/Images/Star-filled.png"/>
+                                        </Setter.Value>
+                                    </Setter>
+                                </DataTrigger>
+                            </Style.Triggers>
+                        </Style>
+                    </Button.Style>
+                </Button>
+            </Border>
             <Border Width="28" Height="28" CornerRadius="2.5"
                     Margin="5 0 0 0" Padding="2">
                 <Border.Style>

+ 6 - 13
PixiEditor/Views/UserControls/Palettes/PaletteItem.xaml.cs

@@ -1,14 +1,10 @@
-using System;
-using PixiEditor.Models.DataHolders.Palettes;
+using PixiEditor.Models.DataHolders.Palettes;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 
 namespace PixiEditor.Views.UserControls.Palettes
 {
-    /// <summary>
-    /// Interaction logic for LospecPaletteItem.xaml
-    /// </summary>
     public partial class PaletteItem : UserControl
     {
         public Palette Palette
@@ -17,9 +13,8 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(PaletteProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for Palette.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty PaletteProperty =
-            DependencyProperty.Register("Palette", typeof(Palette), typeof(PaletteItem));
+            DependencyProperty.Register(nameof(Palette), typeof(Palette), typeof(PaletteItem));
 
         public ICommand ImportPaletteCommand
         {
@@ -27,9 +22,8 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(ImportPaletteCommandProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for ImportPaletteCommand.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty ImportPaletteCommandProperty =
-            DependencyProperty.Register("ImportPaletteCommand", typeof(ICommand), typeof(PaletteItem));
+            DependencyProperty.Register(nameof(ImportPaletteCommand), typeof(ICommand), typeof(PaletteItem));
 
         public ICommand DeletePaletteCommand
         {
@@ -37,12 +31,11 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(DeletePaletteCommandProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for DeletePaletteCommand.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty DeletePaletteCommandProperty =
-            DependencyProperty.Register("DeletePaletteCommand", typeof(ICommand), typeof(PaletteItem));
+            DependencyProperty.Register(nameof(DeletePaletteCommand), typeof(ICommand), typeof(PaletteItem));
 
         public static readonly DependencyProperty ToggleFavouriteCommandProperty = DependencyProperty.Register(
-            "ToggleFavouriteCommand", typeof(ICommand), typeof(PaletteItem), new PropertyMetadata(default(ICommand)));
+            nameof(ToggleFavouriteCommand), typeof(ICommand), typeof(PaletteItem), new PropertyMetadata(default(ICommand)));
 
         public ICommand ToggleFavouriteCommand
         {
@@ -52,7 +45,7 @@ namespace PixiEditor.Views.UserControls.Palettes
 
         public event EventHandler<EditableTextBlock.TextChangedEventArgs> OnRename;
 
- 
+
         public PaletteItem()
         {
             InitializeComponent();

+ 26 - 47
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml.cs

@@ -1,17 +1,15 @@
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-using Microsoft.Win32;
+using Microsoft.Win32;
 using PixiEditor.Helpers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataProviders;
 using PixiEditor.Models.IO;
 using PixiEditor.Views.Dialogs;
 using SkiaSharp;
+using System.IO;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
 
 namespace PixiEditor.Views.UserControls.Palettes
 {
@@ -20,16 +18,14 @@ namespace PixiEditor.Views.UserControls.Palettes
     /// </summary>
     public partial class PaletteViewer : UserControl
     {
-        public static readonly DependencyProperty SwatchesProperty = DependencyProperty.Register(
-            "Swatches", typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteViewer), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>)));
+        public static readonly DependencyProperty SwatchesProperty = DependencyProperty.Register(nameof(Swatches), typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteViewer), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>)));
 
         public WpfObservableRangeCollection<SKColor> Swatches
         {
             get => (WpfObservableRangeCollection<SKColor>)GetValue(SwatchesProperty);
             set => SetValue(SwatchesProperty, value);
         }
-        public static readonly DependencyProperty ColorsProperty = DependencyProperty.Register(
-            "Colors", typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteViewer));
+        public static readonly DependencyProperty ColorsProperty = DependencyProperty.Register(nameof(Colors), typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteViewer));
 
         public WpfObservableRangeCollection<SKColor> Colors
         {
@@ -43,12 +39,11 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(HintColorProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for HintColor.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty HintColorProperty =
-            DependencyProperty.Register("HintColor", typeof(Color), typeof(PaletteViewer), new PropertyMetadata(System.Windows.Media.Colors.Transparent));
+            DependencyProperty.Register(nameof(HintColor), typeof(Color), typeof(PaletteViewer), new PropertyMetadata(System.Windows.Media.Colors.Transparent));
 
-        public static readonly DependencyProperty ReplaceColorsCommandProperty = DependencyProperty.Register(
-            "ReplaceColorsCommand", typeof(ICommand), typeof(PaletteViewer), new PropertyMetadata(default(ICommand)));
+        public static readonly DependencyProperty ReplaceColorsCommandProperty = DependencyProperty.Register(nameof(ReplaceColorsCommand), typeof(ICommand), typeof(PaletteViewer), new PropertyMetadata(default(ICommand)));
 
         public ICommand ReplaceColorsCommand
         {
@@ -62,9 +57,9 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(SelectColorCommandProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for SelectColorCommand.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty SelectColorCommandProperty =
-            DependencyProperty.Register("SelectColorCommand", typeof(ICommand), typeof(PaletteViewer));
+            DependencyProperty.Register(nameof(SelectColorCommand), typeof(ICommand), typeof(PaletteViewer));
 
         public ICommand ImportPaletteCommand
         {
@@ -72,9 +67,9 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(ImportPaletteCommandProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for ImportPaletteCommand.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty ImportPaletteCommandProperty =
-            DependencyProperty.Register("ImportPaletteCommand", typeof(ICommand), typeof(PaletteViewer));
+            DependencyProperty.Register(nameof(ImportPaletteCommand), typeof(ICommand), typeof(PaletteViewer));
 
         public WpfObservableRangeCollection<PaletteListDataSource> DataSources
         {
@@ -82,9 +77,9 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(DataSourcesProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for DataSources.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty DataSourcesProperty =
-            DependencyProperty.Register("DataSources", typeof(WpfObservableRangeCollection<PaletteListDataSource>), typeof(PaletteViewer), new PropertyMetadata(new WpfObservableRangeCollection<PaletteListDataSource>()));
+            DependencyProperty.Register(nameof(DataSources), typeof(WpfObservableRangeCollection<PaletteListDataSource>), typeof(PaletteViewer), new PropertyMetadata(new WpfObservableRangeCollection<PaletteListDataSource>()));
 
         public WpfObservableRangeCollection<PaletteFileParser> FileParsers
         {
@@ -92,26 +87,10 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(FileParsersProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for FileParsers.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty FileParsersProperty =
-            DependencyProperty.Register("FileParsers", typeof(WpfObservableRangeCollection<PaletteFileParser>), typeof(PaletteViewer), new PropertyMetadata(new WpfObservableRangeCollection<PaletteFileParser>()));
-
-        private string _filesFilter;
 
-        public string FilesFilter
-        {
-            get
-            {
-                if(_filesFilter == null)
-                {
-                    _filesFilter = PaletteHelpers.GetFilter(FileParsers);
-                }
+        public static readonly DependencyProperty FileParsersProperty =
+            DependencyProperty.Register(nameof(FileParsers), typeof(WpfObservableRangeCollection<PaletteFileParser>), typeof(PaletteViewer), new PropertyMetadata(new WpfObservableRangeCollection<PaletteFileParser>()));
 
-                return _filesFilter;
-            }
-            set => _filesFilter = value;
-        }
-        
         public PaletteViewer()
         {
             InitializeComponent();
@@ -131,7 +110,7 @@ namespace PixiEditor.Views.UserControls.Palettes
         {
             OpenFileDialog openFileDialog = new OpenFileDialog
             {
-                Filter = FilesFilter
+                Filter = PaletteHelpers.GetFilter(FileParsers, true),
             };
             if (openFileDialog.ShowDialog() == true)
             {
@@ -143,7 +122,7 @@ namespace PixiEditor.Views.UserControls.Palettes
         {
             var parser = FileParsers.FirstOrDefault(x => x.SupportedFileExtensions.Contains(Path.GetExtension(fileName)));
             var data = await parser.Parse(fileName);
-            if(data.IsCorrupted || data.Colors.Length == 0) return;
+            if (data.IsCorrupted || data.Colors.Length == 0) return;
             Colors.Clear();
             Colors.AddRange(data.Colors);
         }
@@ -152,7 +131,7 @@ namespace PixiEditor.Views.UserControls.Palettes
         {
             SaveFileDialog saveFileDialog = new SaveFileDialog
             {
-                Filter = FilesFilter
+                Filter = PaletteHelpers.GetFilter(FileParsers, false)
             };
 
             if (saveFileDialog.ShowDialog() == true)
@@ -165,7 +144,7 @@ namespace PixiEditor.Views.UserControls.Palettes
 
         private void Grid_PreviewDragEnter(object sender, DragEventArgs e)
         {
-            if(IsPalFilePresent(e, out _))
+            if (IsPalFilePresent(e, out _))
             {
                 dragDropGrid.Visibility = Visibility.Visible;
             }
@@ -178,7 +157,7 @@ namespace PixiEditor.Views.UserControls.Palettes
 
         private async void Grid_Drop(object sender, DragEventArgs e)
         {
-            if(IsPalFilePresent(e, out string filePath))
+            if (IsPalFilePresent(e, out string filePath))
             {
                 await ImportPalette(filePath);
                 dragDropGrid.Visibility = Visibility.Hidden;
@@ -203,11 +182,11 @@ namespace PixiEditor.Views.UserControls.Palettes
 
         private void PaletteColor_Drop(object sender, DragEventArgs e)
         {
-            if(e.Data.GetDataPresent(PaletteColor.PaletteColorDaoFormat))
+            if (e.Data.GetDataPresent(PaletteColor.PaletteColorDaoFormat))
             {
                 string data = (string)e.Data.GetData(PaletteColor.PaletteColorDaoFormat);
                 SKColor color = SKColor.Parse(data);
-                if(Colors.Contains(color))
+                if (Colors.Contains(color))
                 {
                     PaletteColor paletteColor = sender as PaletteColor;
                     int currIndex = Colors.IndexOf(color);

+ 3 - 14
PixiEditor/Views/UserControls/PrependTextBlock.xaml.cs

@@ -1,17 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
+using System.Windows;
 using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
 using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
 
 namespace PixiEditor.Views.UserControls
 {
@@ -71,9 +60,9 @@ namespace PixiEditor.Views.UserControls
             set { SetValue(HidePrependProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for HidePrepend.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty HidePrependProperty =
-            DependencyProperty.Register("HidePrepend", typeof(bool), typeof(PrependTextBlock), new PropertyMetadata(false));
+            DependencyProperty.Register(nameof(HidePrepend), typeof(bool), typeof(PrependTextBlock), new PropertyMetadata(false));
 
 
 

+ 2 - 3
PixiEditor/Views/UserControls/SizeInput.xaml.cs

@@ -1,5 +1,4 @@
 using PixiEditor.Models.Enums;
-using System;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
@@ -29,9 +28,9 @@ namespace PixiEditor.Views
             set { SetValue(OnScrollActionProperty, value); }
         }
 
-        // Using a DependencyProperty as the backing store for OnScrollAction.  This enables animation, styling, binding, etc...
+
         public static readonly DependencyProperty OnScrollActionProperty =
-            DependencyProperty.Register("OnScrollAction", typeof(Action), typeof(SizeInput), new PropertyMetadata(null));
+            DependencyProperty.Register(nameof(OnScrollAction), typeof(Action), typeof(SizeInput), new PropertyMetadata(null));
 
         public SizeInput()
         {

+ 4 - 2
PixiEditor/Views/UserControls/SwatchesView.xaml

@@ -5,7 +5,9 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PixiEditor.Views.UserControls" 
              xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
-             xmlns:conv="clr-namespace:PixiEditor.Helpers.Converters" xmlns:palettes="clr-namespace:PixiEditor.Views.UserControls.Palettes"
+             xmlns:conv="clr-namespace:PixiEditor.Helpers.Converters" 
+             xmlns:palettes="clr-namespace:PixiEditor.Views.UserControls.Palettes"
+             xmlns:cmds="clr-namespace:PixiEditor.Models.Commands.XAML"
              mc:Ignorable="d" Name="swatchesView"
              d:DesignHeight="450" d:DesignWidth="300">
     <UserControl.Resources>
@@ -45,7 +47,7 @@
                         <palettes:PaletteColor.ContextMenu>
                             <ContextMenu>
                                 <MenuItem Header="Remove" Foreground="White"
-                                          Command="{Binding Source={x:Reference Name=swatchesView}, Path=DataContext.ColorsSubViewModel.RemoveSwatchCommand}"
+                                          Command="{cmds:Command PixiEditor.Colors.RemoveSwatch, UseProvided=True}"
                                           CommandParameter="{Binding}" />
                             </ContextMenu>
                         </palettes:PaletteColor.ContextMenu>

+ 0 - 3
PixiEditor/Views/UserControls/SwatchesView.xaml.cs

@@ -6,9 +6,6 @@ using System.Windows.Input;
 
 namespace PixiEditor.Views.UserControls
 {
-    /// <summary>
-    /// Interaction logic for SwatchesView.xaml
-    /// </summary>
     public partial class SwatchesView : UserControl
     {
         public static readonly DependencyProperty SwatchesProperty =