mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
可以把连线从节点上拖下来,并且依附上去。
This commit is contained in:
@@ -410,8 +410,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
if (EnableSnapping)
|
||||
{
|
||||
var nearPort = FindNearPortToAttachTo();
|
||||
if (nearPort != null || partialConnection.SinkConnectorInfoFully != null)
|
||||
var nearPort = _viewModel.FindNearPortToAttachTo(partialConnection);
|
||||
if (nearPort != null)
|
||||
{
|
||||
partialConnection.SinkConnectorInfo = nearPort;
|
||||
}
|
||||
@@ -632,20 +632,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
e.Handled = true;
|
||||
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
#region 自动依附节点
|
||||
private FullyCreatedConnectorInfo FindNearPortToAttachTo()
|
||||
{
|
||||
foreach (var port in _viewModel.Items.OfType<DesignerItemViewModelBase>().ToList().SelectMany(n => n.Connectors))
|
||||
{
|
||||
if (partialConnection.OnGoingPosition.DistanceTo(port.Position) < SnappingRadius &&
|
||||
partialConnection.SourceConnectorInfoFully?.CanAttachTo(port) == true)
|
||||
return port;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user