mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using AIStudio.Wpf.DiagramDesigner.Geometry;
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
{
|
|
public static partial class Routers
|
|
{
|
|
public static PointBase GetPortPositionBasedOnAlignment(ConnectorInfoBase port)
|
|
{
|
|
var pt = port.Position;
|
|
switch (port.Orientation)
|
|
{
|
|
case ConnectorOrientation.Top:
|
|
return new PointBase(pt.X + port.ConnectorWidth / 2, pt.Y);
|
|
case ConnectorOrientation.TopRight:
|
|
return new PointBase(pt.X + port.ConnectorWidth, pt.Y);
|
|
case ConnectorOrientation.Right:
|
|
return new PointBase(pt.X + port.ConnectorWidth, pt.Y + port.ConnectorHeight / 2);
|
|
case ConnectorOrientation.BottomRight:
|
|
return new PointBase(pt.X + port.ConnectorWidth, pt.Y + port.ConnectorHeight);
|
|
case ConnectorOrientation.Bottom:
|
|
return new PointBase(pt.X + port.ConnectorWidth / 2, pt.Y + port.ConnectorHeight);
|
|
case ConnectorOrientation.BottomLeft:
|
|
return new PointBase(pt.X, pt.Y + port.ConnectorHeight);
|
|
case ConnectorOrientation.Left:
|
|
return new PointBase(pt.X, pt.Y + port.ConnectorHeight / 2);
|
|
default:
|
|
return pt;
|
|
}
|
|
}
|
|
}
|
|
}
|