mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-13 21:16:37 +08:00
调整了一下各种命令的位置,便于其他应用调用
This commit is contained in:
@@ -25,6 +25,42 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Init(sourceConnectorInfo, sinkConnectorInfo);
|
||||
}
|
||||
|
||||
public ConnectorViewModel( FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode vectorLineDrawMode):this(null, sourceConnectorInfo, sinkConnectorInfo, vectorLineDrawMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableDesignerItemBase ToXmlObject()
|
||||
{
|
||||
if (SinkConnectorInfo is FullyCreatedConnectorInfo sinkConnector)
|
||||
{
|
||||
ConnectionItem connection = new ConnectionItem(
|
||||
SourceConnectorInfo.DataItem.Id,
|
||||
SourceConnectorInfo.Orientation,
|
||||
SourceConnectorInfo.DataItem.GetType(),
|
||||
GetXRatioFromConnector(SourceConnectorInfo),
|
||||
GetYRatioFromConnector(SourceConnectorInfo),
|
||||
SourceConnectorInfo.IsInnerPoint,
|
||||
sinkConnector.DataItem.Id,
|
||||
sinkConnector.Orientation,
|
||||
sinkConnector.DataItem.GetType(),
|
||||
GetXRatioFromConnector(sinkConnector),
|
||||
GetYRatioFromConnector(sinkConnector),
|
||||
sinkConnector.IsInnerPoint,
|
||||
this);
|
||||
|
||||
return connection;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override Type ToXmlType()
|
||||
{
|
||||
return typeof(ConnectionItem);
|
||||
}
|
||||
|
||||
public IPathFinder PathFinder
|
||||
{
|
||||
@@ -207,6 +243,52 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public double GetXRatioFromConnector(FullyCreatedConnectorInfo info)
|
||||
{
|
||||
if (info.IsInnerPoint)
|
||||
{
|
||||
return info.XRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (info.Orientation)
|
||||
{
|
||||
case ConnectorOrientation.Top:
|
||||
return 0.5;
|
||||
case ConnectorOrientation.Left:
|
||||
return 0;
|
||||
case ConnectorOrientation.Bottom:
|
||||
return 0.5;
|
||||
case ConnectorOrientation.Right:
|
||||
return 1;
|
||||
default: return info.XRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double GetYRatioFromConnector(FullyCreatedConnectorInfo info)
|
||||
{
|
||||
if (info.IsInnerPoint)
|
||||
{
|
||||
return info.YRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (info.Orientation)
|
||||
{
|
||||
case ConnectorOrientation.Top:
|
||||
return 0;
|
||||
case ConnectorOrientation.Left:
|
||||
return 0.5;
|
||||
case ConnectorOrientation.Bottom:
|
||||
return 1;
|
||||
case ConnectorOrientation.Right:
|
||||
return 0.5;
|
||||
default: return info.YRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateArea()
|
||||
{
|
||||
Area = new Rect(SourceA, SourceB);
|
||||
|
||||
Reference in New Issue
Block a user