IsPortless 画线

This commit is contained in:
艾竹
2023-01-27 20:10:17 +08:00
parent 72e3efb052
commit e8bd6faa21
15 changed files with 197 additions and 49 deletions

View File

@@ -370,7 +370,7 @@ namespace AIStudio.Wpf.DiagramDesigner
RaisePropertyChanged(nameof(IsFullConnection));
}
public bool IsPortless => SourceConnectorInfo?.DataItem?.Connectors?.Count() == 0;
public bool IsPortless => SourceConnectorInfo.IsPortless || SinkConnectorInfoFully?.IsPortless == true;
#endregion
#region
@@ -607,9 +607,9 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (SourceConnectorInfo.DataItem == null || (IsFullConnection && SinkConnectorInfoFully.DataItem == null))
return (null, null);
var sourceCenter = SourceConnectorInfo.DataItem.GetBounds().Center;
var targetCenter = SinkConnectorInfoFully?.DataItem?.GetBounds().Center ?? OnGoingPosition;
var sourceCenter = SourceConnectorInfo.IsPortless ? SourceConnectorInfo.DataItem.GetBounds().Center : SourceConnectorInfo.MiddlePosition;
var targetCenter = SinkConnectorInfoFully?.IsPortless == true ? SinkConnectorInfoFully?.DataItem?.GetBounds().Center ?? OnGoingPosition : SinkConnectorInfoFully?.MiddlePosition ?? OnGoingPosition;
var firstPt = route.Length > 0 ? route[0] : targetCenter;
var secondPt = route.Length > 0 ? route[0] : sourceCenter;
var sourceLine = new LineBase(firstPt, sourceCenter);
@@ -618,7 +618,8 @@ namespace AIStudio.Wpf.DiagramDesigner
var targetIntersections = SinkConnectorInfoFully.DataItem.GetShape()?.GetIntersectionsWithLine(targetLine) ?? new PointBase[] { OnGoingPosition };
var sourceIntersection = GetClosestPointTo(sourceIntersections, firstPt);
var targetIntersection = GetClosestPointTo(targetIntersections, secondPt);
return (sourceIntersection ?? sourceCenter, targetIntersection ?? targetCenter);
return (sourceIntersection ?? sourceCenter,targetIntersection ?? targetCenter);
}
else
{
@@ -626,6 +627,8 @@ namespace AIStudio.Wpf.DiagramDesigner
var target = SinkConnectorInfo.MiddlePosition;// GetPortPositionBasedOnAlignment(SinkConnectorInfoFully, ColorViewModel.RightArrowSizeStyle);
return (source, target);
}
}
private PointBase? GetPortPositionBasedOnAlignment(ConnectorInfoBase port, ArrowSizeStyle marker)