mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-23 02:06:35 +08:00
添加block快,不需要连接线,直接吸附。
This commit is contained in:
@@ -13,10 +13,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return point;
|
||||
}
|
||||
|
||||
var connectorWidth = double.IsNaN(connector.ConnectorWidth) ? 0 : connector.ConnectorWidth;
|
||||
var connectorHeight = double.IsNaN(connector.ConnectorHeight) ? 0 : connector.ConnectorHeight;
|
||||
var left = connector.DataItem.Left;
|
||||
var top = connector.DataItem.Top;
|
||||
var itemWidth = connector.DataItem.ItemWidth;
|
||||
var itemHeight = connector.DataItem.ItemHeight;
|
||||
|
||||
if (connector.IsInnerPoint)
|
||||
{
|
||||
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth * connector.XRatio - connector.ConnectorWidth / 2,
|
||||
connector.DataItem.Top + connector.DataItem.ItemHeight * connector.YRatio - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left + itemWidth * connector.XRatio - connectorWidth / 2,
|
||||
top + itemHeight * connector.YRatio - connectorHeight / 2);
|
||||
}
|
||||
else if (connector.IsPortless)
|
||||
{
|
||||
@@ -27,39 +34,39 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
switch (connector.Orientation)
|
||||
{
|
||||
case ConnectorOrientation.Left:
|
||||
point = new PointBase(connector.DataItem.Left - connector.ConnectorWidth / 2, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2) - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left - connectorWidth / 2, top + (itemHeight / 2) - connectorHeight / 2);
|
||||
break;
|
||||
case ConnectorOrientation.TopLeft:
|
||||
point = new PointBase(connector.DataItem.Left - connector.ConnectorWidth / 2, connector.DataItem.Top - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left - connectorWidth / 2, top - connectorHeight / 2);
|
||||
break;
|
||||
case ConnectorOrientation.Top:
|
||||
point = new PointBase(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2) - connector.ConnectorWidth / 2, connector.DataItem.Top - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left + (itemWidth / 2) - connectorWidth / 2, top - connectorHeight / 2);
|
||||
break;
|
||||
case ConnectorOrientation.TopRight:
|
||||
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth - connector.ConnectorWidth / 2, connector.DataItem.Top - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left + itemWidth - connectorWidth / 2, top - connectorHeight / 2);
|
||||
break;
|
||||
case ConnectorOrientation.Right:
|
||||
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth - connector.ConnectorWidth / 2, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2) - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left + itemWidth - connectorWidth / 2, top + (itemHeight / 2) - connectorHeight / 2);
|
||||
break;
|
||||
case ConnectorOrientation.BottomRight:
|
||||
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth - connector.ConnectorWidth / 2, connector.DataItem.Top + connector.DataItem.ItemHeight - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left + itemWidth - connectorWidth / 2, top + itemHeight - connectorHeight / 2);
|
||||
break;
|
||||
case ConnectorOrientation.Bottom:
|
||||
point = new PointBase(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2) - connector.ConnectorWidth / 2, connector.DataItem.Top + connector.DataItem.ItemHeight - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left + (itemWidth / 2) - connectorWidth / 2, top + itemHeight - connectorHeight / 2);
|
||||
break;
|
||||
case ConnectorOrientation.BottomLeft:
|
||||
point = new PointBase(connector.DataItem.Left - connector.ConnectorWidth / 2, connector.DataItem.Top + connector.DataItem.ItemHeight - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left - connectorWidth / 2, top + itemHeight - connectorHeight / 2);
|
||||
break;
|
||||
default:
|
||||
point = new PointBase(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2) - connector.ConnectorWidth / 2, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2) - connector.ConnectorHeight / 2);
|
||||
point = new PointBase(left + (itemWidth / 2) - connectorWidth / 2, top + (itemHeight / 2) - connectorHeight / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (middle)
|
||||
{
|
||||
point.X = point.X + connector.ConnectorWidth / 2;
|
||||
point.Y = point.Y + connector.ConnectorHeight / 2;
|
||||
point.X = point.X + connectorWidth / 2;
|
||||
point.Y = point.Y + connectorHeight / 2;
|
||||
}
|
||||
//旋转后的坐标
|
||||
var newX = (point.X - connector.DataItem.MiddlePosition.X) * Math.Cos(connector.DataItem.Angle * Math.PI / 180) - (point.Y - connector.DataItem.MiddlePosition.Y) * Math.Sin(connector.DataItem.Angle * Math.PI / 180) + connector.DataItem.MiddlePosition.X;
|
||||
|
||||
Reference in New Issue
Block a user