mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-20 08:26:36 +08:00
整理序列化
This commit is contained in:
@@ -11,9 +11,12 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接线
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(ConnectionItem))]
|
||||
public class ConnectionItem : SelectableDesignerItemBase
|
||||
public class ConnectionItem : SelectableItemBase
|
||||
{
|
||||
public ConnectionItem()
|
||||
{
|
||||
@@ -39,7 +42,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.SinkInnerPoint = viewmodel.SinkConnectorInfoFully.IsInnerPoint;
|
||||
this.RouterMode = viewmodel.RouterMode;
|
||||
this.PathMode = viewmodel.PathMode;
|
||||
this.Vertices = viewmodel.Vertices.Select(p => (Point)p.MiddlePosition).ToList();
|
||||
this.Vertices = viewmodel.Vertices.Select(p => new ConnectorVertexItem(p)).ToList();
|
||||
this.Labels = viewmodel.Labels.Select(p => new ConnectorLabelItem(p)).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -97,28 +101,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public List<Point> Vertices
|
||||
[XmlArray]
|
||||
public List<ConnectorVertexItem> Vertices
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
[XmlAttribute("Vertices")]
|
||||
public string XmlVertices
|
||||
{
|
||||
get
|
||||
{
|
||||
return SerializeHelper.SerializePointList(Vertices);
|
||||
}
|
||||
set
|
||||
{
|
||||
Vertices = SerializeHelper.DeserializePointList(value);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<ConnectorLabelItem> Connectors
|
||||
public List<ConnectorLabelItem> Labels
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
@@ -4,20 +4,57 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectorItem
|
||||
/// <summary>
|
||||
/// 连接点
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(ConnectorItem))]
|
||||
public class ConnectorItem : SelectableItemBase
|
||||
{
|
||||
public Guid ParentId { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public ConnectorItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorItem(FullyCreatedConnectorInfo viewmodel) : base(viewmodel)
|
||||
{
|
||||
XRatio = viewmodel.XRatio;
|
||||
YRatio = viewmodel.YRatio;
|
||||
ConnectorWidth = viewmodel.ConnectorWidth;
|
||||
ConnectorHeight = viewmodel.ConnectorHeight;
|
||||
Orientation = viewmodel.Orientation;
|
||||
IsInnerPoint = viewmodel.IsInnerPoint;
|
||||
ValueTypePoint = viewmodel.ValueTypePoint;
|
||||
ConnectorValue = viewmodel.ConnectorValue;
|
||||
}
|
||||
|
||||
|
||||
[XmlAttribute]
|
||||
public double XRatio { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public double YRatio { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorWidth { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorHeight { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public ConnectorOrientation Orientation { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public bool IsInnerPoint { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public ValueTypePoint ValueTypePoint { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorValue { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectorLabelItem
|
||||
/// <summary>
|
||||
/// 连接点文字
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(ConnectorLabelItem))]
|
||||
public class ConnectorLabelItem : ConnectorPointItem
|
||||
{
|
||||
public ConnectorLabelItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorLabelItem(ConnectorLabelModel viewmodel) : base(viewmodel)
|
||||
{
|
||||
Distance = viewmodel.Distance;
|
||||
Offset = viewmodel.Offset;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double? Distance
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public Point Offset
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
[XmlAttribute("Offset")]
|
||||
public string XmlOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
return SerializeHelper.SerializePoint(Offset);
|
||||
}
|
||||
set
|
||||
{
|
||||
Offset = SerializeHelper.DeserializePoint(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 连接中间点
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(ConnectorPointItem))]
|
||||
public class ConnectorPointItem : SelectableItemBase
|
||||
{
|
||||
public ConnectorPointItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorPointItem(ConnectorPointModel viewmodel) : base(viewmodel)
|
||||
{
|
||||
X = viewmodel.X;
|
||||
Y = viewmodel.Y;
|
||||
ConnectorWidth = viewmodel.ConnectorWidth;
|
||||
ConnectorHeight = viewmodel.ConnectorHeight;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double X
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double Y
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorWidth
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorHeight
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
class ConnectorVertexItem
|
||||
/// <summary>
|
||||
/// 连接线。中间点
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(ConnectorVertexItem))]
|
||||
public class ConnectorVertexItem : ConnectorPointItem
|
||||
{
|
||||
public ConnectorVertexItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorVertexItem(ConnectorVertexModel viewmodel) : base(viewmodel)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(DesignerItemBase))]
|
||||
public class DesignerItemBase : SelectableDesignerItemBase
|
||||
public class DesignerItemBase : SelectableItemBase
|
||||
{
|
||||
public DesignerItemBase()
|
||||
{
|
||||
|
||||
@@ -15,14 +15,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Connectors = new List<ConnectorItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem()
|
||||
{
|
||||
XRatio = fullyCreatedConnectorInfo.XRatio,
|
||||
YRatio = fullyCreatedConnectorInfo.YRatio,
|
||||
ConnectorWidth = fullyCreatedConnectorInfo.ConnectorWidth,
|
||||
ConnectorHeight = fullyCreatedConnectorInfo.ConnectorHeight,
|
||||
Orientation = fullyCreatedConnectorInfo.Orientation
|
||||
};
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
Connectors.Add(connector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.Connectors = new List<ConnectorItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem()
|
||||
{
|
||||
XRatio = fullyCreatedConnectorInfo.XRatio,
|
||||
YRatio = fullyCreatedConnectorInfo.YRatio,
|
||||
ConnectorWidth = fullyCreatedConnectorInfo.ConnectorWidth,
|
||||
ConnectorHeight = fullyCreatedConnectorInfo.ConnectorHeight,
|
||||
Orientation = fullyCreatedConnectorInfo.Orientation,
|
||||
IsInnerPoint = fullyCreatedConnectorInfo.IsInnerPoint,
|
||||
ValueTypePoint = fullyCreatedConnectorInfo.ValueTypePoint,
|
||||
ConnectorValue = fullyCreatedConnectorInfo.ConnectorValue
|
||||
};
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
this.Connectors.Add(connector);
|
||||
}
|
||||
this.OrderNumber = item.OrderNumber;
|
||||
|
||||
@@ -15,14 +15,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Connectors = new List<ConnectorItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem()
|
||||
{
|
||||
XRatio = fullyCreatedConnectorInfo.XRatio,
|
||||
YRatio = fullyCreatedConnectorInfo.YRatio,
|
||||
ConnectorWidth = fullyCreatedConnectorInfo.ConnectorWidth,
|
||||
ConnectorHeight = fullyCreatedConnectorInfo.ConnectorHeight,
|
||||
Orientation = fullyCreatedConnectorInfo.Orientation
|
||||
};
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
Connectors.Add(connector);
|
||||
}
|
||||
}
|
||||
@@ -32,14 +25,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Connectors = new List<ConnectorItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem()
|
||||
{
|
||||
XRatio = fullyCreatedConnectorInfo.XRatio,
|
||||
YRatio = fullyCreatedConnectorInfo.YRatio,
|
||||
ConnectorWidth = fullyCreatedConnectorInfo.ConnectorWidth,
|
||||
ConnectorHeight = fullyCreatedConnectorInfo.ConnectorHeight,
|
||||
Orientation = fullyCreatedConnectorInfo.Orientation
|
||||
};
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
Connectors.Add(connector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,27 +13,15 @@ using System.Xml.Serialization;
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
|
||||
public abstract class SelectableDesignerItemBase
|
||||
public abstract class SelectableItemBase
|
||||
{
|
||||
public SelectableDesignerItemBase()
|
||||
public SelectableItemBase()
|
||||
{
|
||||
ColorItem = new ColorItem() { LineColor = new ColorObjectItem(), FillColor = new ColorObjectItem() };
|
||||
FontItem = new FontItem();
|
||||
}
|
||||
|
||||
//public SelectableDesignerItemBase(Guid id, int zIndex, bool isGroup, Guid parentId, IColorViewModel colorViewModel, IFontViewModel fontViewModel)
|
||||
//{
|
||||
// this.Id = id;
|
||||
// this.ZIndex = zIndex;
|
||||
// this.IsGroup = isGroup;
|
||||
// this.ParentId = parentId;
|
||||
|
||||
|
||||
// ColorItem = CopyHelper.Mapper<ColorItem>(colorViewModel);
|
||||
// FontItem = CopyHelper.Mapper<FontItem, IFontViewModel>(fontViewModel);
|
||||
//}
|
||||
|
||||
public SelectableDesignerItemBase(SelectableDesignerItemViewModelBase viewmodel)
|
||||
public SelectableItemBase(SelectableViewModelBase viewmodel)
|
||||
{
|
||||
this.Id = viewmodel.Id;
|
||||
this.ZIndex = viewmodel.ZIndex;
|
||||
@@ -45,6 +33,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
FontItem = CopyHelper.Mapper<FontItem, IFontViewModel>(viewmodel.FontViewModel);
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public Guid ParentId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public Guid Id
|
||||
{
|
||||
@@ -63,12 +57,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public Guid ParentId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Text
|
||||
{
|
||||
Reference in New Issue
Block a user