mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-19 07:56:37 +08:00
部分连接线完成,另外待连接点红色区域显示。
This commit is contained in:
@@ -448,12 +448,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RaiseFullConnection()
|
||||
{
|
||||
RaisePropertyChanged(nameof(IsFullConnection));
|
||||
}
|
||||
|
||||
public double SmoothMargin { get; set; } = 125;
|
||||
public double SmoothAutoSlope { get; set; } = 1;
|
||||
public double OrthogonalShapeMargin { get; set; } = 10;
|
||||
@@ -585,13 +579,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
else if(connectorVertexModel.ConnectorVertexType == ConnectorVertexType.Start)
|
||||
{
|
||||
var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.Start);
|
||||
SetSourcePort(new PartCreatedConnectorInfo(connectorVertexModel.Position.X, connectorVertexModel.Position.Y));
|
||||
this.ZIndex = -1;
|
||||
}
|
||||
else if (connectorVertexModel.ConnectorVertexType == ConnectorVertexType.End)
|
||||
{
|
||||
var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.End);
|
||||
SetSinkPort(new PartCreatedConnectorInfo(connectorVertexModel.Position.X, connectorVertexModel.Position.Y));
|
||||
this.ZIndex = -1;
|
||||
}
|
||||
break;
|
||||
case nameof(ConnectorPointModel.DragStart):
|
||||
@@ -599,7 +593,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (connectorVertexModel.ConnectorVertexType == ConnectorVertexType.Start)
|
||||
{
|
||||
var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.Start);
|
||||
var nearPort = Root?.FindNearPortToAttachTo(this, ConnectorVertexType.Start);
|
||||
if (nearPort != null)
|
||||
{
|
||||
SetSourcePort(nearPort);
|
||||
@@ -607,12 +601,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
else if (connectorVertexModel.ConnectorVertexType == ConnectorVertexType.End)
|
||||
{
|
||||
var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.End);
|
||||
var nearPort = Root?.FindNearPortToAttachTo(this, ConnectorVertexType.End);
|
||||
if (nearPort != null)
|
||||
{
|
||||
SetSinkPort(nearPort);
|
||||
}
|
||||
}
|
||||
Root?.ClearNearPort();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -895,7 +890,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public double GetSourceMarkerWidth()
|
||||
{
|
||||
if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path))
|
||||
if (string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -904,7 +899,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public double GetSourceMarkerHeight()
|
||||
{
|
||||
if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path))
|
||||
if (string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -913,7 +908,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public double GetSinkMarkerWidth()
|
||||
{
|
||||
if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path))
|
||||
if (string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -922,7 +917,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public double GetSinkMarkerHeight()
|
||||
{
|
||||
if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path))
|
||||
if (string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -145,6 +145,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
private bool _beAttachTo;
|
||||
public bool BeAttachTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _beAttachTo;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _beAttachTo, value);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanAttachTo(ConnectorInfoBase port)
|
||||
=> port != this && !port.IsReadOnly;
|
||||
#endregion
|
||||
|
||||
@@ -170,11 +170,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPosition(PointBase position)
|
||||
{
|
||||
X = position.X;
|
||||
Y = position.Y;
|
||||
}
|
||||
|
||||
private bool _dragStart;
|
||||
public bool DragStart
|
||||
@@ -189,6 +184,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPosition(PointBase position)
|
||||
{
|
||||
X = position.X;
|
||||
Y = position.Y;
|
||||
}
|
||||
|
||||
|
||||
public static ConnectorPointModel operator -(ConnectorPointModel a, ConnectorPointModel b)
|
||||
{
|
||||
return new ConnectorPointModel(a.X - b.X, a.Y - b.Y);
|
||||
|
||||
@@ -39,10 +39,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; set;
|
||||
} = 50;
|
||||
public double HittingRadius
|
||||
{
|
||||
get; set;
|
||||
} = 20;
|
||||
}
|
||||
|
||||
public class ShortcutOption
|
||||
|
||||
@@ -3357,19 +3357,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (partialConnection == null)
|
||||
return null;
|
||||
|
||||
ClearNearPort();
|
||||
foreach (var port in Items.OfType<DesignerItemViewModelBase>().ToList().SelectMany(n => n.Connectors))
|
||||
{
|
||||
if (connectorVertexType == ConnectorVertexType.Start)
|
||||
{
|
||||
if (partialConnection.SourceConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.HittingRadius &&
|
||||
if (partialConnection.SourceConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.SnappingRadius &&
|
||||
partialConnection.SinkConnectorInfo?.CanAttachTo(port) == true)
|
||||
{
|
||||
port.DataItem.ShowConnectors = true;
|
||||
port.BeAttachTo = true;
|
||||
return port;
|
||||
}
|
||||
}
|
||||
else if (connectorVertexType == ConnectorVertexType.End)
|
||||
{
|
||||
if (partialConnection.SinkConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.HittingRadius &&
|
||||
if (partialConnection.SinkConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.SnappingRadius &&
|
||||
partialConnection.SourceConnectorInfo?.CanAttachTo(port) == true)
|
||||
{
|
||||
port.DataItem.ShowConnectors = true;
|
||||
port.BeAttachTo = true;
|
||||
return port;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3381,15 +3390,25 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (partialConnection == null)
|
||||
return null;
|
||||
|
||||
ClearNearPort();
|
||||
foreach (var port in Items.OfType<DesignerItemViewModelBase>().ToList().SelectMany(n => n.Connectors))
|
||||
{
|
||||
if (partialConnection.OnGoingPosition.DistanceTo(port.Position) < DiagramOption.SnappingOption.SnappingRadius &&
|
||||
partialConnection.SourceConnectorInfoFully?.CanAttachTo(port) == true)
|
||||
{
|
||||
port.DataItem.ShowConnectors = true;
|
||||
port.BeAttachTo = true;
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ClearNearPort()
|
||||
{
|
||||
Items.OfType<DesignerItemViewModelBase>().ToList().SelectMany(n => n.Connectors).Where(p => p.BeAttachTo == true).ToList().ForEach(p => p.BeAttachTo = false);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user