mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
序列化继续整理
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public abstract class ConnectorInfoBase : SelectableViewModelBase
|
||||
{
|
||||
public ConnectorInfoBase(ConnectorOrientation orientation)
|
||||
{
|
||||
this.Orientation = orientation;
|
||||
}
|
||||
|
||||
public ConnectorInfoBase(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorInfoBase(IDiagramViewModel root, string json) : base(root, json)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
ColorViewModel = new ColorViewModel()
|
||||
{
|
||||
LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) },
|
||||
FillColor = new ColorObject() { Color = Colors.Lavender },
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is ConnectorInfoItemBase designer)
|
||||
{
|
||||
ConnectorWidth = designer.ConnectorWidth;
|
||||
ConnectorHeight = designer.ConnectorHeight;
|
||||
Orientation = designer.Orientation;
|
||||
ConnectorValue = designer.ConnectorValue;
|
||||
}
|
||||
}
|
||||
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
{
|
||||
return new ConnectorInfoItemBase(this);
|
||||
}
|
||||
|
||||
public override Type ToXmlType()
|
||||
{
|
||||
return typeof(ConnectorInfoBase);
|
||||
}
|
||||
|
||||
#region 属性
|
||||
public virtual PointBase Position
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public virtual PointBase MiddlePosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return new PointBase(Position.X + ConnectorWidth / 2, Position.Y + ConnectorHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
private ConnectorOrientation _orientation;
|
||||
public ConnectorOrientation Orientation
|
||||
{
|
||||
get
|
||||
{
|
||||
return _orientation;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _orientation, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double connectorWidth = 8;
|
||||
public double ConnectorWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return connectorWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
connectorWidth = value;
|
||||
}
|
||||
}
|
||||
|
||||
private double connectorHeight = 8;
|
||||
public double ConnectorHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return connectorHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
connectorHeight = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double _connectorValue;
|
||||
public double ConnectorValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connectorValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _connectorValue, value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user