2023-01-08 09:22:37 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometry;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class PointHelper
|
|
|
|
|
|
{
|
2023-01-08 09:22:37 +08:00
|
|
|
|
public static PointBase GetPointForConnector(FullyCreatedConnectorInfo connector)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-08 09:22:37 +08:00
|
|
|
|
PointBase point = new PointBase();
|
|
|
|
|
|
if (connector == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return point;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
if (connector.IsInnerPoint)
|
|
|
|
|
|
{
|
2023-01-08 09:22:37 +08:00
|
|
|
|
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth * connector.XRatio,
|
2021-08-01 22:30:12 +08:00
|
|
|
|
connector.DataItem.Top + connector.DataItem.ItemHeight * connector.YRatio);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
switch (connector.Orientation)
|
|
|
|
|
|
{
|
|
|
|
|
|
case ConnectorOrientation.Top:
|
2023-01-08 09:22:37 +08:00
|
|
|
|
point = new PointBase(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2), connector.DataItem.Top);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case ConnectorOrientation.Bottom:
|
2023-01-08 09:22:37 +08:00
|
|
|
|
point = new PointBase(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2), (connector.DataItem.Top + connector.DataItem.ItemHeight));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case ConnectorOrientation.Right:
|
2023-01-08 09:22:37 +08:00
|
|
|
|
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case ConnectorOrientation.Left:
|
2023-01-08 09:22:37 +08:00
|
|
|
|
point = new PointBase(connector.DataItem.Left, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return point;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|