Files
aistudio-wpf-diagram/AIStudio.Wpf.DiagramDesigner/Models/Serializables/ConnectionItem.cs

132 lines
3.9 KiB
C#
Raw Normal View History

2022-10-28 22:45:39 +08:00
using AIStudio.Wpf.DiagramDesigner;
2023-01-21 23:25:42 +08:00
using Newtonsoft.Json;
2021-07-23 09:42:22 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2023-01-21 23:25:42 +08:00
using System.Windows;
2021-07-23 09:42:22 +08:00
using System.Windows.Media;
using System.Xml.Serialization;
2022-10-28 22:45:39 +08:00
namespace AIStudio.Wpf.DiagramDesigner
2021-07-23 09:42:22 +08:00
{
2023-01-24 16:20:39 +08:00
/// <summary>
/// 连接线
/// </summary>
2021-07-23 09:42:22 +08:00
[Serializable]
[XmlInclude(typeof(ConnectionItem))]
2023-01-24 16:20:39 +08:00
public class ConnectionItem : SelectableItemBase
2021-07-23 09:42:22 +08:00
{
public ConnectionItem()
{
}
2023-01-12 23:02:53 +08:00
2023-05-03 09:59:46 +08:00
public ConnectionItem(ConnectionViewModel viewmodel) : base(viewmodel)//Todo,半连接线也可序列化
2023-01-12 23:02:53 +08:00
{
2023-05-03 09:59:46 +08:00
this.SourceId = viewmodel.SourceConnectorInfoFully.DataItem.Id;
this.SourceOrientation = viewmodel.SourceConnectorInfoFully.Orientation;
this.SourceType = viewmodel.SourceConnectorInfoFully.DataItem.GetType();
this.SourceTypeName = viewmodel.SourceConnectorInfoFully.DataItem.GetType().FullName;
this.SourceXRatio = viewmodel.SourceConnectorInfoFully.GetXRatioFromConnector();
this.SourceYRatio = viewmodel.SourceConnectorInfoFully.GetYRatioFromConnector();
this.SourceInnerPoint = viewmodel.SourceConnectorInfoFully.IsInnerPoint;
this.SourceIsPortless = viewmodel.SourceConnectorInfoFully.IsPortless;
2023-01-12 23:02:53 +08:00
this.SinkId = viewmodel.SinkConnectorInfoFully.DataItem.Id;
this.SinkOrientation = viewmodel.SinkConnectorInfoFully.Orientation;
this.SinkType = viewmodel.SinkConnectorInfoFully.DataItem.GetType();
this.SinkTypeName = viewmodel.SinkConnectorInfoFully.DataItem.GetType().FullName;
this.SinkXRatio = viewmodel.SinkConnectorInfoFully.GetXRatioFromConnector();
this.SinkYRatio = viewmodel.SinkConnectorInfoFully.GetYRatioFromConnector();
this.SinkInnerPoint = viewmodel.SinkConnectorInfoFully.IsInnerPoint;
2023-05-03 09:59:46 +08:00
this.SinkIsPortless = viewmodel.SourceConnectorInfoFully.IsPortless;
2023-01-27 20:43:41 +08:00
2023-01-12 23:02:53 +08:00
this.RouterMode = viewmodel.RouterMode;
this.PathMode = viewmodel.PathMode;
2023-01-24 16:20:39 +08:00
this.Vertices = viewmodel.Vertices.Select(p => new ConnectorVertexItem(p)).ToList();
this.Labels = viewmodel.Labels.Select(p => new ConnectorLabelItem(p)).ToList();
2023-01-12 23:02:53 +08:00
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
public Guid SourceId { get; set; }
[XmlAttribute]
public ConnectorOrientation SourceOrientation { get; set; }
[XmlIgnore]
public Type SourceType { get; set; }
[XmlAttribute]
public string SourceTypeName { get; set; }
[XmlAttribute]
public double SourceXRatio { get; set; }
[XmlAttribute]
public double SourceYRatio { get; set; }
[XmlAttribute]
public bool SourceInnerPoint { get; set; }
2023-01-27 20:43:41 +08:00
[XmlAttribute]
public bool SourceIsPortless
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
public Guid SinkId { get; set; }
[XmlAttribute]
public ConnectorOrientation SinkOrientation { get; set; }
[XmlIgnore]
public Type SinkType { get; set; }
[XmlAttribute]
public string SinkTypeName { get; set; }
[XmlAttribute]
public double SinkXRatio { get; set; }
[XmlAttribute]
public double SinkYRatio { get; set; }
[XmlAttribute]
public bool SinkInnerPoint { get; set; }
2023-01-27 20:43:41 +08:00
[XmlAttribute]
public bool SinkIsPortless
{
get; set;
}
[XmlAttribute]
2023-01-12 23:02:53 +08:00
public string RouterMode
{
get; set;
}
[XmlAttribute]
public string PathMode
{
get; set;
}
2023-01-21 23:25:42 +08:00
2023-01-24 16:20:39 +08:00
[XmlArray]
public List<ConnectorVertexItem> Vertices
2023-01-21 23:25:42 +08:00
{
get; set;
}
2023-01-22 21:46:59 +08:00
[XmlArray]
2023-01-24 16:20:39 +08:00
public List<ConnectorLabelItem> Labels
2023-01-22 21:46:59 +08:00
{
get; set;
}
2021-07-23 09:42:22 +08:00
}
}