2023-01-12 23:02:53 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
2023-01-08 09:22:37 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
|
|
|
|
{
|
|
|
|
|
|
public static partial class Routers
|
|
|
|
|
|
{
|
|
|
|
|
|
public static PointBase GetPortPositionBasedOnAlignment(ConnectorInfoBase port)
|
|
|
|
|
|
{
|
2023-01-15 20:27:39 +08:00
|
|
|
|
var pt = port.Position;
|
2023-01-08 09:22:37 +08:00
|
|
|
|
switch (port.Orientation)
|
|
|
|
|
|
{
|
2023-01-27 20:43:41 +08:00
|
|
|
|
case ConnectorOrientation.Left:
|
|
|
|
|
|
return new PointBase(pt.X, pt.Y + port.ConnectorHeight / 2);
|
|
|
|
|
|
case ConnectorOrientation.TopLeft:
|
|
|
|
|
|
return new PointBase(pt.X, pt.Y);
|
2023-01-08 09:22:37 +08:00
|
|
|
|
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:
|
2023-01-27 20:43:41 +08:00
|
|
|
|
return new PointBase(pt.X, pt.Y + port.ConnectorHeight);
|
2023-01-08 09:22:37 +08:00
|
|
|
|
default:
|
|
|
|
|
|
return pt;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|