mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-07 02:00:50 +08:00
IsPortless 画线
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -143,6 +143,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool IsPortless
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public ValueTypePoint _valueTypePoint;
|
||||
public ValueTypePoint ValueTypePoint
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -191,6 +191,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (IsReadOnly == true) return;
|
||||
|
||||
ShowText = true;
|
||||
|
||||
RaisePropertyChanged("EditText");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user