Files
aistudio-wpf-diagram/Extensions/AIStudio.Wpf.SFC/Models/SFCNodeDesignerItem.cs

83 lines
2.5 KiB
C#
Raw Normal View History

2021-08-03 18:19:47 +08:00
using AIStudio.Wpf.SFC.ViewModels;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Xml.Serialization;
2022-10-28 22:45:39 +08:00
using AIStudio.Wpf.DiagramDesigner;
2021-08-03 18:19:47 +08:00
namespace AIStudio.Wpf.SFC.Models
{
public class SFCNodeDesignerItem : DesignerItemBase
{
public SFCNodeDesignerItem()
{
}
public SFCNodeDesignerItem(SFCNode item) : base(item)
{
2023-01-24 17:53:04 +08:00
this.Connectors = new List<FullyCreatedConnectorInfoItem>();
2021-08-03 18:19:47 +08:00
foreach (var fullyCreatedConnectorInfo in item.Connectors)
{
2023-01-24 17:53:04 +08:00
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
2023-01-24 16:20:39 +08:00
2021-08-03 18:19:47 +08:00
this.Connectors.Add(connector);
}
Kind = item.Kind;
Expression = item.Expression;
if (item is SFCActionNode actionNode)
{
LinkPoints = new List<LinkPoint> { actionNode.LinkPoint };
}
else if (item is SFCConditionNode sFCConditionNode)
{
LinkPoints = new List<LinkPoint>(sFCConditionNode.LinkPoint);
}
else if (item is Simulate_SolenoidViewModel simulate_SolenoidViewModel)
{
LinkPoints = new List<LinkPoint> { simulate_SolenoidViewModel.DILinkPoint, simulate_SolenoidViewModel.DOLinkPoint };
}
else if (item is Simulate_StartViewModel simulate_StartViewModel)
{
LinkPoints = new List<LinkPoint> { simulate_StartViewModel.LinkPoint };
}
else if (item is Simulate_TankViewModel simulate_TankViewModel)
{
LinkPoints = new List<LinkPoint> { simulate_TankViewModel.LinkPoint };
}
}
[XmlArray]
2023-01-24 17:53:04 +08:00
public List<FullyCreatedConnectorInfoItem> Connectors { get; set; }
2021-08-03 18:19:47 +08:00
[XmlAttribute]
public SFCNodeKinds Kind { get; set; }
[XmlAttribute]
public string Expression { get; set; }
[XmlIgnore]
public List<LinkPoint> LinkPoints { get; set; } = new List<LinkPoint>();
[JsonIgnore]
[XmlElement("LinkPoint")]
public string XmlLinkPoints
{
get
{
return SFCService.SerializeLinkPoint(LinkPoints);
}
set
{
LinkPoints = SFCService.DeserializeLinkPoint(value);
}
}
}
}