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)

View File

@@ -143,6 +143,11 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
}
public bool IsPortless
{
get; set;
}
public ValueTypePoint _valueTypePoint;
public ValueTypePoint ValueTypePoint
{

View File

@@ -64,10 +64,10 @@ namespace AIStudio.Wpf.DiagramDesigner
protected virtual void InitConnector()
{
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top));
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom));
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left));
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Top));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Bottom));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Left));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Right));
}
#region
@@ -135,6 +135,18 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
private FullyCreatedConnectorInfo _portlessConnector;
public FullyCreatedConnectorInfo PortlessConnector
{
get
{
if (_portlessConnector == null)
_portlessConnector = new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.None) { IsPortless = true };
return _portlessConnector;
}
}
public Style ConnectorStyle
{
get; set;

View File

@@ -191,6 +191,8 @@ namespace AIStudio.Wpf.DiagramDesigner
if (IsReadOnly == true) return;
ShowText = true;
RaisePropertyChanged("EditText");
}
}
}