Browse Source

Added palettes .pixi support

Krzysztof Krysiński 3 years ago
parent
commit
fa659982d7

+ 11 - 2
PixiEditor/Helpers/Extensions/ParserHelpers.cs

@@ -16,7 +16,8 @@ namespace PixiEditor.Helpers.Extensions
             Document document = new Document(serializableDocument.Width, serializableDocument.Height)
             {
                 Layers = serializableDocument.ToLayers(),
-                Swatches = new WpfObservableRangeCollection<SKColor>(serializableDocument.Swatches.ToSKColors())
+                Swatches = new WpfObservableRangeCollection<SKColor>(serializableDocument.Swatches.ToSKColors()),
+                Palette = new WpfObservableRangeCollection<SKColor>(serializableDocument.Palette.ToSKColors())
             };
 
             document.LayerStructure.Groups = serializableDocument.ToGroups(document);
@@ -88,7 +89,9 @@ namespace PixiEditor.Helpers.Extensions
         {
             return new SerializableDocument(document.Width, document.Height,
                                             document.LayerStructure.Groups.ToSerializable(document),
-                                            document.Layers.ToSerializable()).AddSwatches(document.Swatches);
+                                            document.Layers.ToSerializable())
+                .AddSwatches(document.Swatches)
+                .AddPalette(document.Palette);
         }
 
         public static IEnumerable<SerializableLayer> ToSerializable(this IEnumerable<Layer> layers)
@@ -154,5 +157,11 @@ namespace PixiEditor.Helpers.Extensions
             document.Swatches.AddRange(colors);
             return document;
         }
+
+        private static SerializableDocument AddPalette(this SerializableDocument document, IEnumerable<SKColor> palette)
+        {
+            document.Palette.AddRange(palette);
+            return document;
+        }
     }
 }

+ 1 - 1
PixiEditor/PixiEditor.csproj

@@ -204,7 +204,7 @@
 		</PackageReference>
 		<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
 		<PackageReference Include="PixiEditor.ColorPicker" Version="3.3.1" />
-		<PackageReference Include="PixiEditor.Parser" Version="2.0.0.1" />
+		<PackageReference Include="PixiEditor.Parser" Version="2.1.0" />
 		<PackageReference Include="PixiEditor.Parser.Skia" Version="2.0.0.1" />
 		<PackageReference Include="SkiaSharp" Version="2.80.3" />
 		<PackageReference Include="System.Drawing.Common" Version="6.0.0" />

+ 1 - 1
PixiEditorTests/ModelsTests/UndoTests/StorageBasedChangeTests.cs

@@ -30,7 +30,7 @@ namespace PixiEditorTests.ModelsTests.UndoTests
             testBitmap.SetSRGBPixel(0, 0, SKColors.Black);
             testBitmap2.SetSRGBPixel(4, 4, SKColors.Blue);
             Random random = new Random();
-            testDocument.Layers = new PixiEditor.Models.DataHolders.ObservableCollection<Layer>()
+            testDocument.Layers = new PixiEditor.Models.DataHolders.WpfObservableRangeCollection<Layer>()
             {
                 new Layer("Test layer" + random.Next(int.MinValue, int.MaxValue), testBitmap, testDocument.Width, testDocument.Height),
                 new Layer("Test layer 2" + random.Next(int.MinValue, int.MaxValue), testBitmap2, testDocument.Width, testDocument.Height) { Offset = new System.Windows.Thickness(2, 3, 0, 0) }