|
@@ -6,6 +6,7 @@ using System.Windows.Media;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Models.ImageManipulation;
|
|
using PixiEditor.Models.ImageManipulation;
|
|
using PixiEditor.Models.Layers;
|
|
using PixiEditor.Models.Layers;
|
|
|
|
+using PixiEditor.Parser;
|
|
|
|
|
|
namespace PixiEditor.Helpers.Extensions
|
|
namespace PixiEditor.Helpers.Extensions
|
|
{
|
|
{
|
|
@@ -20,6 +21,8 @@ namespace PixiEditor.Helpers.Extensions
|
|
Color.FromArgb(x.Item1, x.Item2, x.Item3, x.Item4)))
|
|
Color.FromArgb(x.Item1, x.Item2, x.Item3, x.Item4)))
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ //document.LayerStructure = new LayerStructure(ToGroups(serializableDocument), document);
|
|
|
|
+
|
|
return document;
|
|
return document;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -29,25 +32,52 @@ namespace PixiEditor.Helpers.Extensions
|
|
for (int i = 0; i < serializableDocument.Layers.Length; i++)
|
|
for (int i = 0; i < serializableDocument.Layers.Length; i++)
|
|
{
|
|
{
|
|
Parser.SerializableLayer serLayer = serializableDocument.Layers[i];
|
|
Parser.SerializableLayer serLayer = serializableDocument.Layers[i];
|
|
- Layer layer =
|
|
|
|
- new Layer(serLayer.Name, BitmapUtils.BytesToWriteableBitmap(serLayer.Width, serLayer.Height, serLayer.BitmapBytes))
|
|
|
|
- {
|
|
|
|
- IsVisible = serLayer.IsVisible,
|
|
|
|
- Offset = new Thickness(serLayer.OffsetX, serLayer.OffsetY, 0, 0),
|
|
|
|
- Opacity = serLayer.Opacity
|
|
|
|
- };
|
|
|
|
|
|
+ Layer layer = new(serLayer.Name, BitmapUtils.BytesToWriteableBitmap(serLayer.Width, serLayer.Height, serLayer.BitmapBytes))
|
|
|
|
+ {
|
|
|
|
+ IsVisible = serLayer.IsVisible,
|
|
|
|
+ Offset = new Thickness(serLayer.OffsetX, serLayer.OffsetY, 0, 0),
|
|
|
|
+ Opacity = serLayer.Opacity
|
|
|
|
+ };
|
|
layers.Add(layer);
|
|
layers.Add(layer);
|
|
}
|
|
}
|
|
|
|
|
|
return layers;
|
|
return layers;
|
|
}
|
|
}
|
|
|
|
|
|
- public static Parser.SerializableDocument ToSerializable(this Document document)
|
|
|
|
|
|
+ /*public static ObservableCollection<GuidStructureItem> ToGroups(this Parser.SerializableDocument serializableDocument)
|
|
|
|
+ {
|
|
|
|
+ return ToGroups(serializableDocument.Groups);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static ObservableCollection<GuidStructureItem> ToGroups(SerializableGuidStructureItem[] items)
|
|
|
|
+ {
|
|
|
|
+ ObservableCollection<GuidStructureItem> groups = new();
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < items.Length; i++)
|
|
|
|
+ {
|
|
|
|
+ SerializableGuidStructureItem item = items[i];
|
|
|
|
+ groups.Add(ToGroup(item));
|
|
|
|
+ }
|
|
|
|
+ return groups;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static GuidStructureItem ToGroup(SerializableGuidStructureItem item)
|
|
|
|
+ {
|
|
|
|
+ return new GuidStructureItem(
|
|
|
|
+ item.Name,
|
|
|
|
+ item.StartLayerGuid,
|
|
|
|
+ item.EndLayerGuid,
|
|
|
|
+ ToGroups(item.Subgroups),
|
|
|
|
+ ToGroup(item.Parent));
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ public static SerializableDocument ToSerializable(this Document document)
|
|
{
|
|
{
|
|
Parser.SerializableDocument serializable = new Parser.SerializableDocument
|
|
Parser.SerializableDocument serializable = new Parser.SerializableDocument
|
|
{
|
|
{
|
|
Width = document.Width,
|
|
Width = document.Width,
|
|
Height = document.Height,
|
|
Height = document.Height,
|
|
|
|
+ //Groups = document.LayerStructure.Groups.Select(x => x.ToSerializable()).ToArray(),
|
|
Layers = document.Layers.Select(x => x.ToSerializable()).ToArray(),
|
|
Layers = document.Layers.Select(x => x.ToSerializable()).ToArray(),
|
|
Swatches = document.Swatches.Select(x => new Tuple<byte, byte, byte, byte>(x.A, x.R, x.G, x.B)).ToArray()
|
|
Swatches = document.Swatches.Select(x => new Tuple<byte, byte, byte, byte>(x.A, x.R, x.G, x.B)).ToArray()
|
|
};
|
|
};
|
|
@@ -55,6 +85,17 @@ namespace PixiEditor.Helpers.Extensions
|
|
return serializable;
|
|
return serializable;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*public static SerializableGuidStructureItem ToSerializable(this GuidStructureItem group)
|
|
|
|
+ {
|
|
|
|
+ return new(
|
|
|
|
+ group.GroupGuid,
|
|
|
|
+ group.Name,
|
|
|
|
+ group.StartLayerGuid,
|
|
|
|
+ group.EndLayerGuid,
|
|
|
|
+ group.Subgroups.Select(x => x.ToSerializable()).ToArray(),
|
|
|
|
+ group.Parent?.ToSerializable());
|
|
|
|
+ }*/
|
|
|
|
+
|
|
public static Parser.SerializableLayer ToSerializable(this Layer layer)
|
|
public static Parser.SerializableLayer ToSerializable(this Layer layer)
|
|
{
|
|
{
|
|
Parser.SerializableLayer serializable = new Parser.SerializableLayer
|
|
Parser.SerializableLayer serializable = new Parser.SerializableLayer
|