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

159 lines
3.6 KiB
C#
Raw Normal View History

2022-10-28 22:45:39 +08:00
using AIStudio.Wpf.DiagramDesigner;
2023-02-11 23:51:48 +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-03-01 19:28:06 +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
{
[Serializable]
[XmlInclude(typeof(DesignerItemBase))]
2023-01-24 16:20:39 +08:00
public class DesignerItemBase : SelectableItemBase
2021-07-23 09:42:22 +08:00
{
public DesignerItemBase()
{
}
public DesignerItemBase(DesignerItemViewModelBase viewmodel, string reserve = null) : base(viewmodel)
{
2023-02-11 22:20:24 +08:00
this.PhysicalLeft = viewmodel.PhysicalLeft;
this.PhysicalTop = viewmodel.PhysicalTop;
2021-07-23 09:42:22 +08:00
this.Angle = viewmodel.Angle;
this.ScaleX = viewmodel.ScaleX;
this.ScaleY = viewmodel.ScaleY;
2023-02-11 22:20:24 +08:00
this.PhysicalItemWidth = viewmodel.PhysicalItemWidth;
this.PhysicalItemHeight = viewmodel.PhysicalItemHeight;
2021-07-23 09:42:22 +08:00
this.Icon = viewmodel.Icon;
this.ItemTypeName = viewmodel.GetType().FullName;
this.Margin = viewmodel.Margin;
this.Reserve = reserve;
2023-03-01 19:28:06 +08:00
this.CornerRadius = viewmodel.CornerRadius;
this.BorderThickness = viewmodel.BorderThickness;
2023-03-25 11:59:31 +08:00
Connectors = new List<FullyCreatedConnectorInfoItem>(viewmodel.Connectors.Select(p => new FullyCreatedConnectorInfoItem(p)));
2021-07-23 09:42:22 +08:00
}
2023-02-11 23:51:48 +08:00
[XmlAttribute("Left")]
2023-02-11 22:20:24 +08:00
public double PhysicalLeft
{
get; set;
}
2021-07-23 09:42:22 +08:00
2023-02-11 23:51:48 +08:00
[XmlAttribute("Top")]
2023-02-11 22:20:24 +08:00
public double PhysicalTop
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
2023-02-11 22:20:24 +08:00
public double Angle
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
2023-02-11 22:20:24 +08:00
public double ScaleX
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
2023-02-11 22:20:24 +08:00
public double ScaleY
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
2023-02-11 22:20:24 +08:00
public double Margin
{
get; set;
}
2021-07-23 09:42:22 +08:00
2023-02-11 23:51:48 +08:00
[JsonProperty(PropertyName = "ItemWidth")]
[XmlAttribute("ItemWidth")]
2023-02-11 22:20:24 +08:00
public double PhysicalItemWidth
{
get; set;
}
2021-07-23 09:42:22 +08:00
2023-02-11 23:51:48 +08:00
[JsonProperty(PropertyName = "ItemHeight")]
[XmlAttribute("ItemHeight")]
2023-02-11 22:20:24 +08:00
public double PhysicalItemHeight
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
2023-02-11 22:20:24 +08:00
public string Icon
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
2023-02-11 22:20:24 +08:00
public string Reserve
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlAttribute]
2023-02-11 22:20:24 +08:00
public string ItemTypeName
{
get; set;
}
2021-07-23 09:42:22 +08:00
[XmlIgnore]
2023-03-01 19:28:06 +08:00
public CornerRadius CornerRadius
{
get; set;
}
[JsonIgnore]
[XmlElement("CornerRadius")]
public string XmlCornerRadius
{
get
{
return SerializeHelper.SerializeCornerRadius(CornerRadius);
}
set
{
CornerRadius = SerializeHelper.DeserializeCornerRadius(value);
}
}
[XmlIgnore]
2023-03-01 19:28:06 +08:00
public Thickness BorderThickness
{
get; set;
}
[JsonIgnore]
[XmlElement("BorderThickness")]
public string XmlBorderThickness
{
get
{
return SerializeHelper.SerializeThickness(BorderThickness);
}
set
{
BorderThickness = SerializeHelper.DeserializeThickness(value);
}
}
2023-03-25 11:59:31 +08:00
[XmlArray]
public List<FullyCreatedConnectorInfoItem> Connectors
{
get; set;
}
2021-07-23 09:42:22 +08:00
}
}