mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
131 lines
3.4 KiB
C#
131 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
{
|
|
public abstract class ConnectorInfoBase : SelectableViewModelBase
|
|
{
|
|
public ConnectorInfoBase(ConnectorOrientation orientation) : this(null, orientation)
|
|
{
|
|
|
|
}
|
|
|
|
public ConnectorInfoBase(IDiagramViewModel root, ConnectorOrientation orientation) : base(root)
|
|
{
|
|
this.Orientation = orientation;
|
|
}
|
|
|
|
public ConnectorInfoBase(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
|
{
|
|
|
|
}
|
|
|
|
public ConnectorInfoBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
|
{
|
|
|
|
}
|
|
|
|
public override SelectableItemBase GetSerializableObject()
|
|
{
|
|
return new ConnectorInfoItemBase(this);
|
|
}
|
|
|
|
protected override void Init(IDiagramViewModel root)
|
|
{
|
|
base.Init(root);
|
|
|
|
ColorViewModel = new ColorViewModel()
|
|
{
|
|
LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) },
|
|
FillColor = new ColorObject() { Color = Colors.Lavender },
|
|
};
|
|
}
|
|
|
|
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
|
{
|
|
base.LoadDesignerItemViewModel(designerbase);
|
|
|
|
if (designerbase is ConnectorInfoItemBase designer)
|
|
{
|
|
ConnectorWidth = designer.ConnectorWidth;
|
|
ConnectorHeight = designer.ConnectorHeight;
|
|
Orientation = designer.Orientation;
|
|
ConnectorValue = designer.ConnectorValue;
|
|
}
|
|
}
|
|
|
|
#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
|
|
}
|
|
}
|