mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-05 08:46:34 +08:00
block的序列化与反序列化
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(BlockDesignerItem))]
|
||||
public class BlockDesignerItem : DesignerItemBase
|
||||
{
|
||||
public BlockDesignerItem()
|
||||
{
|
||||
}
|
||||
|
||||
public BlockDesignerItem(BlockDesignerItemViewModel viewmodel) : base(viewmodel)
|
||||
{
|
||||
Containers = new List<BlockItemsContainerInfoItem>(viewmodel.Containers.Select(p => new BlockItemsContainerInfoItem(p)));
|
||||
}
|
||||
|
||||
|
||||
[XmlArray]
|
||||
public List<BlockItemsContainerInfoItem> Containers
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(BlockItemsContainerInfoItem))]
|
||||
public class BlockItemsContainerInfoItem : SelectableItemBase
|
||||
{
|
||||
public BlockItemsContainerInfoItem()
|
||||
{
|
||||
}
|
||||
|
||||
public BlockItemsContainerInfoItem(BlockItemsContainerInfo viewmodel) : base(viewmodel)
|
||||
{
|
||||
this.OnlyOneChild = viewmodel.OnlyOneChild;
|
||||
this.ChildFlag = viewmodel.ChildFlag;
|
||||
this.PhysicalItemWidth = viewmodel.PhysicalItemWidth;
|
||||
this.PhysicalItemHeight = viewmodel.PhysicalItemHeight;
|
||||
|
||||
Children = new List<BlockDesignerItem>(viewmodel.Children.Select(p => new BlockDesignerItem(p)));
|
||||
}
|
||||
|
||||
public bool OnlyOneChild
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public List<string> ChildFlag
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
||||
[JsonProperty(PropertyName = "ItemWidth")]
|
||||
[XmlAttribute("ItemWidth")]
|
||||
public double PhysicalItemWidth
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[JsonProperty(PropertyName = "ItemHeight")]
|
||||
[XmlAttribute("ItemHeight")]
|
||||
public double PhysicalItemHeight
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<BlockDesignerItem> Children
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.ScaleY = viewmodel.ScaleY;
|
||||
this.PhysicalItemWidth = viewmodel.PhysicalItemWidth;
|
||||
this.PhysicalItemHeight = viewmodel.PhysicalItemHeight;
|
||||
this.MinItemWidth = viewmodel.MinItemWidth;
|
||||
this.MinItemHeight = viewmodel.MinItemHeight;
|
||||
this.Icon = viewmodel.Icon;
|
||||
this.ItemTypeName = viewmodel.GetType().FullName;
|
||||
this.Margin = viewmodel.Margin;
|
||||
@@ -89,6 +91,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double MinItemWidth
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
||||
[XmlAttribute]
|
||||
public double MinItemHeight
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Icon
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user