Browse Source

merge fixes

flabbet 3 years ago
parent
commit
8538ef726f

+ 1 - 1
PixiEditor/Helpers/Converters/LayerStructureToGroupsConverter.cs

@@ -25,7 +25,7 @@ namespace PixiEditor.Helpers.Converters
 
 
         private System.Collections.ObjectModel.ObservableCollection<GuidStructureItem> GetSubGroups(IEnumerable<GuidStructureItem> groups)
         private System.Collections.ObjectModel.ObservableCollection<GuidStructureItem> GetSubGroups(IEnumerable<GuidStructureItem> groups)
         {
         {
-            Models.DataHolders.ObservableCollection<GuidStructureItem> finalGroups = new Models.DataHolders.ObservableCollection<GuidStructureItem>();
+            WpfObservableRangeCollection<GuidStructureItem> finalGroups = new WpfObservableRangeCollection<GuidStructureItem>();
             foreach (var group in groups)
             foreach (var group in groups)
             {
             {
                 finalGroups.AddRange(GetSubGroups(group));
                 finalGroups.AddRange(GetSubGroups(group));

+ 3 - 3
PixiEditor/Helpers/Converters/LayersToStructuredLayersConverter.cs

@@ -15,11 +15,11 @@ namespace PixiEditor.Helpers.Converters
         private static StructuredLayerTree cachedTree;
         private static StructuredLayerTree cachedTree;
         private List<Guid> lastLayerGuids = new List<Guid>();
         private List<Guid> lastLayerGuids = new List<Guid>();
         private IList<Layer> lastLayers = new List<Layer>();
         private IList<Layer> lastLayers = new List<Layer>();
-        private ObservableCollection<GuidStructureItem> lastStructure = new ObservableCollection<GuidStructureItem>();
+        private WpfObservableRangeCollection<GuidStructureItem> lastStructure = new WpfObservableRangeCollection<GuidStructureItem>();
 
 
         public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
         public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
         {
         {
-            if (values[0] is ObservableCollection<Layer> layers && values[1] is LayerStructure structure)
+            if (values[0] is WpfObservableRangeCollection<Layer> layers && values[1] is LayerStructure structure)
             {
             {
                 if (cachedTree == null)
                 if (cachedTree == null)
                 {
                 {
@@ -109,4 +109,4 @@ namespace PixiEditor.Helpers.Converters
             return rootMismatch;
             return rootMismatch;
         }
         }
     }
     }
-}
+}

+ 6 - 6
PixiEditor/Helpers/Extensions/ParserHelpers.cs

@@ -16,7 +16,7 @@ namespace PixiEditor.Helpers.Extensions
             Document document = new Document(serializableDocument.Width, serializableDocument.Height)
             Document document = new Document(serializableDocument.Width, serializableDocument.Height)
             {
             {
                 Layers = serializableDocument.ToLayers(),
                 Layers = serializableDocument.ToLayers(),
-                Swatches = new Models.DataHolders.ObservableCollection<SKColor>(serializableDocument.Swatches.ToSKColors())
+                Swatches = new WpfObservableRangeCollection<SKColor>(serializableDocument.Swatches.ToSKColors())
             };
             };
 
 
             document.LayerStructure.Groups = serializableDocument.ToGroups(document);
             document.LayerStructure.Groups = serializableDocument.ToGroups(document);
@@ -30,9 +30,9 @@ namespace PixiEditor.Helpers.Extensions
             return document;
             return document;
         }
         }
 
 
-        public static Models.DataHolders.ObservableCollection<Layer> ToLayers(this SerializableDocument document)
+        public static WpfObservableRangeCollection<Layer> ToLayers(this SerializableDocument document)
         {
         {
-            Models.DataHolders.ObservableCollection<Layer> layers = new();
+            WpfObservableRangeCollection<Layer> layers = new();
             foreach (SerializableLayer slayer in document)
             foreach (SerializableLayer slayer in document)
             {
             {
                 layers.Add(slayer.ToLayer(document.Width, document.Height));
                 layers.Add(slayer.ToLayer(document.Width, document.Height));
@@ -51,9 +51,9 @@ namespace PixiEditor.Helpers.Extensions
             };
             };
         }
         }
 
 
-        public static Models.DataHolders.ObservableCollection<GuidStructureItem> ToGroups(this SerializableDocument sdocument, Document document)
+        public static WpfObservableRangeCollection<GuidStructureItem> ToGroups(this SerializableDocument sdocument, Document document)
         {
         {
-            Models.DataHolders.ObservableCollection<GuidStructureItem> groups = new();
+            WpfObservableRangeCollection<GuidStructureItem> groups = new();
 
 
             if (sdocument.Groups == null)
             if (sdocument.Groups == null)
             {
             {
@@ -155,4 +155,4 @@ namespace PixiEditor.Helpers.Extensions
             return document;
             return document;
         }
         }
     }
     }
-}
+}

+ 5 - 5
PixiEditor/Models/DataHolders/Document/Document.Layers.cs

@@ -24,9 +24,9 @@ namespace PixiEditor.Models.DataHolders
         private Guid activeLayerGuid;
         private Guid activeLayerGuid;
         private LayerStructure layerStructure;
         private LayerStructure layerStructure;
 
 
-        private ObservableCollection<Layer> layers = new();
+        private WpfObservableRangeCollection<Layer> layers = new();
 
 
-        public ObservableCollection<Layer> Layers
+        public WpfObservableRangeCollection<Layer> Layers
         {
         {
             get => layers;
             get => layers;
             set
             set
@@ -407,7 +407,7 @@ namespace PixiEditor.Models.DataHolders
 
 
         }
         }
 
 
-        public void AddLayerStructureToUndo(ObservableCollection<GuidStructureItem> oldLayerStructureGroups)
+        public void AddLayerStructureToUndo(WpfObservableRangeCollection<GuidStructureItem> oldLayerStructureGroups)
         {
         {
             UndoManager.AddUndoChange(
             UndoManager.AddUndoChange(
                 new Change(
                 new Change(
@@ -519,7 +519,7 @@ namespace PixiEditor.Models.DataHolders
 
 
         public void BuildLayerStructureProcess(object[] parameters)
         public void BuildLayerStructureProcess(object[] parameters)
         {
         {
-            if (parameters.Length > 0 && parameters[0] is ObservableCollection<GuidStructureItem> groups)
+            if (parameters.Length > 0 && parameters[0] is WpfObservableRangeCollection<GuidStructureItem> groups)
             {
             {
                 LayerStructure.Groups.CollectionChanged -= Groups_CollectionChanged;
                 LayerStructure.Groups.CollectionChanged -= Groups_CollectionChanged;
                 LayerStructure.Groups = LayerStructure.CloneGroups(groups);
                 LayerStructure.Groups = LayerStructure.CloneGroups(groups);
@@ -871,4 +871,4 @@ namespace PixiEditor.Models.DataHolders
             }
             }
         }
         }
     }
     }
-}
+}

+ 2 - 2
PixiEditor/Models/DataHolders/Document/Document.cs

@@ -102,8 +102,8 @@ namespace PixiEditor.Models.DataHolders
 
 
         public UndoManager UndoManager { get; set; }
         public UndoManager UndoManager { get; set; }
 
 
-        public ObservableCollection<SKColor> Swatches { get; set; } = new ObservableCollection<SKColor>();
-        public ObservableCollection<SKColor> Palette { get; set; } = new ObservableCollection<SKColor>();
+        public WpfObservableRangeCollection<SKColor> Swatches { get; set; } = new WpfObservableRangeCollection<SKColor>();
+        public WpfObservableRangeCollection<SKColor> Palette { get; set; } = new WpfObservableRangeCollection<SKColor>();
 
 
         public void RaisePropertyChange(string name)
         public void RaisePropertyChange(string name)
         {
         {

+ 5 - 3
PixiEditor/Models/DataHolders/Palettes/Palette.cs

@@ -1,13 +1,15 @@
-namespace PixiEditor.Models.DataHolders.Palettes
+using System.Collections.ObjectModel;
+
+namespace PixiEditor.Models.DataHolders.Palettes
 {
 {
     public class Palette
     public class Palette
     {
     {
         public string Title { get; set; }
         public string Title { get; set; }
-        public ObservableCollection<string> Colors { get; set; }
+        public WpfObservableRangeCollection<string> Colors { get; set; }
         public string[] Tags { get; set; }
         public string[] Tags { get; set; }
 
 
         public Palette() { }
         public Palette() { }
-        public Palette(string title, ObservableCollection<string> colors, string[] tags)
+        public Palette(string title, WpfObservableRangeCollection<string> colors, string[] tags)
         {
         {
             Title = title;
             Title = title;
             Colors = colors;
             Colors = colors;

+ 1 - 1
PixiEditor/Models/DataHolders/Palettes/PaletteList.cs

@@ -3,6 +3,6 @@
     public class PaletteList
     public class PaletteList
     {
     {
         public bool FetchedCorrectly { get; set; }
         public bool FetchedCorrectly { get; set; }
-        public ObservableCollection<Palette> Palettes { get; set; }
+        public WpfObservableRangeCollection<Palette> Palettes { get; set; }
     }
     }
 }
 }

+ 2 - 2
PixiEditor/Models/DataProviders/LocalPalettesFetcher.cs

@@ -24,7 +24,7 @@ namespace PixiEditor.Models.DataProviders
             string[] files = DirectoryExtensions.GetFiles(PathToPalettesFolder, string.Join("|", AvailableParsers.SelectMany(x => x.SupportedFileExtensions)), SearchOption.TopDirectoryOnly);
             string[] files = DirectoryExtensions.GetFiles(PathToPalettesFolder, string.Join("|", AvailableParsers.SelectMany(x => x.SupportedFileExtensions)), SearchOption.TopDirectoryOnly);
 
 
             PaletteList result = new PaletteList();
             PaletteList result = new PaletteList();
-            result.Palettes = new ObservableCollection<Palette>();
+            result.Palettes = new WpfObservableRangeCollection<Palette>();
             for (int i = 0; i < files.Length; i++)
             for (int i = 0; i < files.Length; i++)
             {
             {
                 string filePath = files[i];
                 string filePath = files[i];
@@ -33,7 +33,7 @@ namespace PixiEditor.Models.DataProviders
                 if (foundParser != null)
                 if (foundParser != null)
                 {
                 {
                     PaletteFileData fileData = await foundParser.Parse(filePath);
                     PaletteFileData fileData = await foundParser.Parse(filePath);
-                    result.Palettes.Add(new Palette(fileData.Title, new ObservableCollection<string>(fileData.GetHexColors()), fileData.Tags));
+                    result.Palettes.Add(new Palette(fileData.Title, new WpfObservableRangeCollection<string>(fileData.GetHexColors()), fileData.Tags));
                 }
                 }
             }
             }
 
 

+ 1 - 1
PixiEditor/Models/ExternalServices/LospecPaletteFetcher.cs

@@ -57,7 +57,7 @@ namespace PixiEditor.Models.ExternalServices
             return null;
             return null;
         }
         }
 
 
-        private static void ReadjustColors(ObservableCollection<string> colors)
+        private static void ReadjustColors(WpfObservableRangeCollection<string> colors)
         {
         {
             for (int i = 0; i < colors.Count; i++)
             for (int i = 0; i < colors.Count; i++)
             {
             {

+ 6 - 6
PixiEditor/Models/Layers/LayerStructure.cs

@@ -18,7 +18,7 @@ namespace PixiEditor.Models.Layers
     {
     {
         public event EventHandler<LayerStructureChangedEventArgs> LayerStructureChanged;
         public event EventHandler<LayerStructureChangedEventArgs> LayerStructureChanged;
 
 
-        public DataHolders.ObservableCollection<GuidStructureItem> Groups { get; set; }
+        public WpfObservableRangeCollection<GuidStructureItem> Groups { get; set; }
 
 
         private Document Owner { get; }
         private Document Owner { get; }
 
 
@@ -38,9 +38,9 @@ namespace PixiEditor.Models.Layers
         /// </summary>
         /// </summary>
         /// <param name="groups">Groups to clone.</param>
         /// <param name="groups">Groups to clone.</param>
         /// <returns>ObservableCollection with cloned groups.</returns>
         /// <returns>ObservableCollection with cloned groups.</returns>
-        public static DataHolders.ObservableCollection<GuidStructureItem> CloneGroups(DataHolders.ObservableCollection<GuidStructureItem> groups)
+        public static WpfObservableRangeCollection<GuidStructureItem> CloneGroups(WpfObservableRangeCollection<GuidStructureItem> groups)
         {
         {
-            DataHolders.ObservableCollection<GuidStructureItem> outputGroups = new();
+            WpfObservableRangeCollection<GuidStructureItem> outputGroups = new();
             foreach (var group in groups.ToArray())
             foreach (var group in groups.ToArray())
             {
             {
                 outputGroups.Add(group.CloneGroup());
                 outputGroups.Add(group.CloneGroup());
@@ -69,7 +69,7 @@ namespace PixiEditor.Models.Layers
             return GetGroupByGuid(groupGuid, Groups);
             return GetGroupByGuid(groupGuid, Groups);
         }
         }
 
 
-        public DataHolders.ObservableCollection<GuidStructureItem> CloneGroups()
+        public WpfObservableRangeCollection<GuidStructureItem> CloneGroups()
         {
         {
             return CloneGroups(Groups);
             return CloneGroups(Groups);
         }
         }
@@ -709,7 +709,7 @@ namespace PixiEditor.Models.Layers
             return null;
             return null;
         }
         }
 
 
-        public LayerStructure(DataHolders.ObservableCollection<GuidStructureItem> items, Document owner)
+        public LayerStructure(WpfObservableRangeCollection<GuidStructureItem> items, Document owner)
         {
         {
             Groups = items;
             Groups = items;
             Owner = owner;
             Owner = owner;
@@ -717,7 +717,7 @@ namespace PixiEditor.Models.Layers
 
 
         public LayerStructure(Document owner)
         public LayerStructure(Document owner)
         {
         {
-            Groups = new DataHolders.ObservableCollection<GuidStructureItem>();
+            Groups = new WpfObservableRangeCollection<GuidStructureItem>();
             Owner = owner;
             Owner = owner;
         }
         }
     }
     }

+ 9 - 9
PixiEditor/Models/Layers/StructuredLayerTree.cs

@@ -11,14 +11,14 @@ namespace PixiEditor.Models.Layers
     {
     {
         private List<Guid> layersInStructure = new();
         private List<Guid> layersInStructure = new();
 
 
-        public DataHolders.ObservableCollection<IHasGuid> RootDirectoryItems { get; } = new DataHolders.ObservableCollection<IHasGuid>();
+        public WpfObservableRangeCollection<IHasGuid> RootDirectoryItems { get; } = new WpfObservableRangeCollection<IHasGuid>();
 
 
         private static void Swap(ref int startIndex, ref int endIndex)
         private static void Swap(ref int startIndex, ref int endIndex)
         {
         {
             (startIndex, endIndex) = (endIndex, startIndex);
             (startIndex, endIndex) = (endIndex, startIndex);
         }
         }
 
 
-        public StructuredLayerTree(DataHolders.ObservableCollection<Layer> layers, LayerStructure structure)
+        public StructuredLayerTree(WpfObservableRangeCollection<Layer> layers, LayerStructure structure)
         {
         {
             if (layers == null || structure == null)
             if (layers == null || structure == null)
             {
             {
@@ -40,7 +40,7 @@ namespace PixiEditor.Models.Layers
             layersInStructure.Clear();
             layersInStructure.Clear();
         }
         }
 
 
-        private void PlaceItems(List<LayerGroup> parsedFolders, System.Collections.ObjectModel.ObservableCollection<Layer> layers)
+        private void PlaceItems(List<LayerGroup> parsedFolders, ObservableCollection<Layer> layers)
         {
         {
             LayerGroup currentFolder = null;
             LayerGroup currentFolder = null;
             List<LayerGroup> groupsAtIndex = new();
             List<LayerGroup> groupsAtIndex = new();
@@ -75,7 +75,7 @@ namespace PixiEditor.Models.Layers
             }
             }
         }
         }
 
 
-        private void AssignGroup(List<LayerGroup> parsedFolders, System.Collections.ObjectModel.ObservableCollection<Layer> layers, ref LayerGroup currentFolder, ref List<LayerGroup> groupsAtIndex, Stack<LayerGroup> unfinishedFolders, int i)
+        private void AssignGroup(List<LayerGroup> parsedFolders, ObservableCollection<Layer> layers, ref LayerGroup currentFolder, ref List<LayerGroup> groupsAtIndex, Stack<LayerGroup> unfinishedFolders, int i)
         {
         {
             if (parsedFolders.Any(x => x.StructureData.StartLayerGuid == layers[i].GuidValue))
             if (parsedFolders.Any(x => x.StructureData.StartLayerGuid == layers[i].GuidValue))
             {
             {
@@ -100,7 +100,7 @@ namespace PixiEditor.Models.Layers
             }
             }
         }
         }
 
 
-        private int CalculateTopIndex(int displayIndex, GuidStructureItem structureData, System.Collections.ObjectModel.ObservableCollection<Layer> layers)
+        private int CalculateTopIndex(int displayIndex, GuidStructureItem structureData, ObservableCollection<Layer> layers)
         {
         {
             var endLayer = layers.FirstOrDefault(x => x.GuidValue == structureData.EndLayerGuid);
             var endLayer = layers.FirstOrDefault(x => x.GuidValue == structureData.EndLayerGuid);
             var bottomLayer = layers.FirstOrDefault(x => x.GuidValue == structureData.StartLayerGuid);
             var bottomLayer = layers.FirstOrDefault(x => x.GuidValue == structureData.StartLayerGuid);
@@ -118,7 +118,7 @@ namespace PixiEditor.Models.Layers
             return displayIndex + (originalTopIndex - originalBottomIndex);
             return displayIndex + (originalTopIndex - originalBottomIndex);
         }
         }
 
 
-        private List<LayerGroup> ParseFolders(IEnumerable<GuidStructureItem> folders, System.Collections.ObjectModel.ObservableCollection<Layer> layers)
+        private List<LayerGroup> ParseFolders(IEnumerable<GuidStructureItem> folders, ObservableCollection<Layer> layers)
         {
         {
             List<LayerGroup> parsedFolders = new();
             List<LayerGroup> parsedFolders = new();
             foreach (var structureItem in folders)
             foreach (var structureItem in folders)
@@ -129,7 +129,7 @@ namespace PixiEditor.Models.Layers
             return parsedFolders;
             return parsedFolders;
         }
         }
 
 
-        private LayerGroup ParseFolder(GuidStructureItem structureItem, System.Collections.ObjectModel.ObservableCollection<Layer> layers)
+        private LayerGroup ParseFolder(GuidStructureItem structureItem, ObservableCollection<Layer> layers)
         {
         {
             List<Layer> structureItemLayers = new();
             List<Layer> structureItemLayers = new();
 
 
@@ -168,7 +168,7 @@ namespace PixiEditor.Models.Layers
             return folder;
             return folder;
         }
         }
 
 
-        private Guid[] GetLayersInGroup(System.Collections.ObjectModel.ObservableCollection<Layer> layers, GuidStructureItem structureItem)
+        private Guid[] GetLayersInGroup(ObservableCollection<Layer> layers, GuidStructureItem structureItem)
         {
         {
             var startLayer = layers.FirstOrDefault(x => x.GuidValue == structureItem.StartLayerGuid);
             var startLayer = layers.FirstOrDefault(x => x.GuidValue == structureItem.StartLayerGuid);
             var endLayer = layers.FirstOrDefault(x => x.GuidValue == structureItem.EndLayerGuid);
             var endLayer = layers.FirstOrDefault(x => x.GuidValue == structureItem.EndLayerGuid);
@@ -198,4 +198,4 @@ namespace PixiEditor.Models.Layers
             return guids;
             return guids;
         }
         }
     }
     }
-}
+}

+ 5 - 4
PixiEditor/ViewModels/SubViewModels/Main/ColorsViewModel.cs

@@ -1,5 +1,6 @@
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.DependencyInjection;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Dialogs;
 using PixiEditor.Models.Dialogs;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.IO;
@@ -20,7 +21,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
 
         public RelayCommand RemoveSwatchCommand { get; set; }
         public RelayCommand RemoveSwatchCommand { get; set; }
 
 
-        public RelayCommand<ObservableCollection<string>> ImportPaletteCommand { get; set; }
+        public RelayCommand<WpfObservableRangeCollection<string>> ImportPaletteCommand { get; set; }
 
 
 
 
         public RelayCommand<int> SelectPaletteColorCommand { get; set; }
         public RelayCommand<int> SelectPaletteColorCommand { get; set; }
@@ -66,10 +67,10 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             RemoveSwatchCommand = new RelayCommand(RemoveSwatch);
             RemoveSwatchCommand = new RelayCommand(RemoveSwatch);
             SwapColorsCommand = new RelayCommand(SwapColors);
             SwapColorsCommand = new RelayCommand(SwapColors);
             SelectPaletteColorCommand = new RelayCommand<int>(SelectPaletteColor);
             SelectPaletteColorCommand = new RelayCommand<int>(SelectPaletteColor);
-            ImportPaletteCommand = new RelayCommand<ObservableCollection<string>>(ImportPalette);
+            ImportPaletteCommand = new RelayCommand<WpfObservableRangeCollection<string>>(ImportPalette);
         }
         }
 
 
-        public void ImportPalette(ObservableCollection<string> palette)
+        public void ImportPalette(WpfObservableRangeCollection<string> palette)
         {
         {
             var doc = Owner.BitmapManager.ActiveDocument;
             var doc = Owner.BitmapManager.ActiveDocument;
             if (doc == null) return;
             if (doc == null) return;
@@ -78,7 +79,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             {
             {
                 if (doc.Palette == null)
                 if (doc.Palette == null)
                 {
                 {
-                    doc.Palette = new Models.DataHolders.ObservableCollection<SKColor>();
+                    doc.Palette = new WpfObservableRangeCollection<SKColor>();
                 }
                 }
 
 
                 doc.Palette.ReplaceRange(palette.Select(x => SKColor.Parse(x)));
                 doc.Palette.ReplaceRange(palette.Select(x => SKColor.Parse(x)));

+ 1 - 1
PixiEditor/Views/UserControls/Palettes/PaletteColorAdder.xaml

@@ -11,7 +11,7 @@
         <colorpicker:PortableColorPicker
         <colorpicker:PortableColorPicker
             ColorChanged="PortableColorPicker_ColorChanged"
             ColorChanged="PortableColorPicker_ColorChanged"
             SelectedColor="{Binding SelectedColor, ElementName=paletteColorAdder, Mode=TwoWay}"
             SelectedColor="{Binding SelectedColor, ElementName=paletteColorAdder, Mode=TwoWay}"
-            Style="{StaticResource DefaultColorPickerStyle}" Margin="0 0 10 0"
+            Style="{StaticResource DefaultColorPickerStyle}" Width="50" Focusable="False" Margin="0 0 10 0"
             ShowAlpha="False"/>
             ShowAlpha="False"/>
         <Button Name="AddButton" Margin="0" Width="24" Height="24" 
         <Button Name="AddButton" Margin="0" Width="24" Height="24" 
                 Style="{StaticResource ToolButtonStyle}" 
                 Style="{StaticResource ToolButtonStyle}" 

+ 3 - 3
PixiEditor/Views/UserControls/Palettes/PaletteColorAdder.xaml.cs

@@ -23,9 +23,9 @@ namespace PixiEditor.Views.UserControls.Palettes
     /// </summary>
     /// </summary>
     public partial class PaletteColorAdder : UserControl
     public partial class PaletteColorAdder : UserControl
     {
     {
-        public ObservableCollection<SKColor> Colors
+        public WpfObservableRangeCollection<SKColor> Colors
         {
         {
-            get { return (ObservableCollection<SKColor>)GetValue(ColorsProperty); }
+            get { return (WpfObservableRangeCollection<SKColor>)GetValue(ColorsProperty); }
             set { SetValue(ColorsProperty, value); }
             set { SetValue(ColorsProperty, value); }
         }
         }
 
 
@@ -43,7 +43,7 @@ namespace PixiEditor.Views.UserControls.Palettes
 
 
         // Using a DependencyProperty as the backing store for Colors.  This enables animation, styling, binding, etc...
         // Using a DependencyProperty as the backing store for Colors.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty ColorsProperty =
         public static readonly DependencyProperty ColorsProperty =
-            DependencyProperty.Register("Colors", typeof(ObservableCollection<SKColor>), typeof(PaletteColorAdder), new PropertyMetadata(default(ObservableCollection<SKColor>), OnColorsChanged));
+            DependencyProperty.Register("Colors", typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteColorAdder), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>), OnColorsChanged));
 
 
         private static void OnColorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         private static void OnColorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
         {

+ 1 - 1
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml

@@ -70,7 +70,7 @@
                                             AssociatedKey="{Binding Path=(ItemsControl.AlternationIndex), 
                                             AssociatedKey="{Binding Path=(ItemsControl.AlternationIndex), 
                 RelativeSource={RelativeSource TemplatedParent}, Converter={converters:IndexToAssociatedKeyConverter}}">
                 RelativeSource={RelativeSource TemplatedParent}, Converter={converters:IndexToAssociatedKeyConverter}}">
                             <b:Interaction.Triggers>
                             <b:Interaction.Triggers>
-                                <b:EventTrigger EventName="MouseUp">
+                                <b:EventTrigger EventName="MouseLeftButtonUp">
                                     <b:InvokeCommandAction
                                     <b:InvokeCommandAction
                                     Command="{Binding SelectColorCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type palettes:PaletteViewer}}}"
                                     Command="{Binding SelectColorCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type palettes:PaletteViewer}}}"
                                     CommandParameter="{Binding}" />
                                     CommandParameter="{Binding}" />

+ 3 - 3
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml.cs

@@ -21,11 +21,11 @@ namespace PixiEditor.Views.UserControls.Palettes
         public const string PaletteColorDaoFormat = "PixiEditor.PaletteColor";
         public const string PaletteColorDaoFormat = "PixiEditor.PaletteColor";
 
 
         public static readonly DependencyProperty ColorsProperty = DependencyProperty.Register(
         public static readonly DependencyProperty ColorsProperty = DependencyProperty.Register(
-            "Colors", typeof(ObservableCollection<SKColor>), typeof(PaletteViewer));
+            "Colors", typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteViewer));
 
 
-        public ObservableCollection<SKColor> Colors
+        public WpfObservableRangeCollection<SKColor> Colors
         {
         {
-            get { return (ObservableCollection<SKColor>)GetValue(ColorsProperty); }
+            get { return (WpfObservableRangeCollection<SKColor>)GetValue(ColorsProperty); }
             set { SetValue(ColorsProperty, value); }
             set { SetValue(ColorsProperty, value); }
         }
         }
 
 

+ 1 - 1
PixiEditor/Views/UserControls/SwatchesView.xaml

@@ -36,7 +36,7 @@
                 <DataTemplate>
                 <DataTemplate>
                     <palettes:PaletteColor Color="{Binding}" Margin="0 5 5 5">
                     <palettes:PaletteColor Color="{Binding}" Margin="0 5 5 5">
                         <i:Interaction.Triggers>
                         <i:Interaction.Triggers>
-                            <i:EventTrigger EventName="MouseDown">
+                            <i:EventTrigger EventName="MouseLeftButtonUp">
                                 <i:InvokeCommandAction
                                 <i:InvokeCommandAction
                                     Command="{Binding SelectSwatchCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:SwatchesView}}}"
                                     Command="{Binding SelectSwatchCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:SwatchesView}}}"
                                     CommandParameter="{Binding}" />
                                     CommandParameter="{Binding}" />