mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-04 00:35:46 +08:00
分离逻辑与常规连接点
This commit is contained in:
@@ -51,8 +51,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
protected virtual void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
|
||||
{
|
||||
this.Root = sourceConnectorInfo.DataItem.Root;
|
||||
|
||||
this.ColorViewModel.FillColor.Color = Colors.Red;
|
||||
|
||||
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
||||
{
|
||||
this.ShapeViewModel.SinkMarker = LinkMarker.None;
|
||||
@@ -417,14 +416,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
break;
|
||||
case nameof(SourceConnectorInfo):
|
||||
SourceA = PointHelper.GetPointForConnector(SourceConnectorInfo);
|
||||
(SourceConnectorInfo.DataItem as INotifyPropertyChanged).PropertyChanged += new WeakINPCEventHandler(ConnectorViewModel_PropertyChanged).Handler;
|
||||
(SourceConnectorInfo.DataItem as INotifyPropertyChanged).PropertyChanged += new WeakINPCEventHandler(ConnectorViewModel_PropertyChanged).Handler;
|
||||
break;
|
||||
case nameof(SinkConnectorInfo):
|
||||
SourceB = SinkConnectorInfo.Position;
|
||||
if (SinkConnectorInfo is FullyCreatedConnectorInfo)
|
||||
{
|
||||
(((FullyCreatedConnectorInfo)SinkConnectorInfo).DataItem as INotifyPropertyChanged).PropertyChanged += new WeakINPCEventHandler(ConnectorViewModel_PropertyChanged).Handler;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case nameof(IsSelected):
|
||||
if (IsSelected == false)
|
||||
@@ -521,67 +520,74 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
PathGeneratorResult = PathGenerator.Get(Root, this, route, source.Value, target.Value);
|
||||
|
||||
//修正旋转
|
||||
switch (SourceConnectorInfo.Orientation)
|
||||
if (IsFullConnection)
|
||||
{
|
||||
case ConnectorOrientation.Left:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X, PathGeneratorResult.SourceMarkerPosition.Y - GetSourceMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Top:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X - GetSourceMarkerWidth() / 2, PathGeneratorResult.SourceMarkerPosition.Y);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Right:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X - GetSourceMarkerWidth(), PathGeneratorResult.SourceMarkerPosition.Y - GetSourceMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Bottom:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X - GetSourceMarkerWidth() / 2, PathGeneratorResult.SourceMarkerPosition.Y - GetSourceMarkerWidth());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
StartPoint = PathGeneratorResult.SourceMarkerPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//修正旋转
|
||||
switch (SourceConnectorInfo.Orientation)
|
||||
{
|
||||
case ConnectorOrientation.Left:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X, PathGeneratorResult.SourceMarkerPosition.Y - GetSourceMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Top:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X - GetSourceMarkerWidth() / 2, PathGeneratorResult.SourceMarkerPosition.Y);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Right:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X - GetSourceMarkerWidth(), PathGeneratorResult.SourceMarkerPosition.Y - GetSourceMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Bottom:
|
||||
{
|
||||
StartPoint = new PointBase(PathGeneratorResult.SourceMarkerPosition.X - GetSourceMarkerWidth() / 2, PathGeneratorResult.SourceMarkerPosition.Y - GetSourceMarkerWidth());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
StartPoint = PathGeneratorResult.SourceMarkerPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//修正旋转
|
||||
switch (SinkConnectorInfo.Orientation)
|
||||
//修正旋转
|
||||
switch (SinkConnectorInfo.Orientation)
|
||||
{
|
||||
case ConnectorOrientation.Left:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X, PathGeneratorResult.TargetMarkerPosition.Y - GetSinkMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
|
||||
case ConnectorOrientation.Top:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X - GetSinkMarkerWidth() / 2, PathGeneratorResult.TargetMarkerPosition.Y);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Right:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X - GetSinkMarkerWidth(), PathGeneratorResult.TargetMarkerPosition.Y - GetSinkMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Bottom:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X - GetSinkMarkerWidth() / 2, PathGeneratorResult.TargetMarkerPosition.Y - GetSinkMarkerWidth());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
EndPoint = PathGeneratorResult.TargetMarkerPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
case ConnectorOrientation.Left:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X, PathGeneratorResult.TargetMarkerPosition.Y - GetSinkMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
|
||||
case ConnectorOrientation.Top:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X - GetSinkMarkerWidth() / 2, PathGeneratorResult.TargetMarkerPosition.Y);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Right:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X - GetSinkMarkerWidth(), PathGeneratorResult.TargetMarkerPosition.Y - GetSinkMarkerWidth() / 2);
|
||||
break;
|
||||
}
|
||||
case ConnectorOrientation.Bottom:
|
||||
{
|
||||
EndPoint = new PointBase(PathGeneratorResult.TargetMarkerPosition.X - GetSinkMarkerWidth() / 2, PathGeneratorResult.TargetMarkerPosition.Y - GetSinkMarkerWidth());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
EndPoint = PathGeneratorResult.TargetMarkerPosition;
|
||||
break;
|
||||
}
|
||||
StartPoint = PathGeneratorResult.SourceMarkerPosition;
|
||||
EndPoint = PathGeneratorResult.TargetMarkerPosition;
|
||||
}
|
||||
|
||||
StartAngle = PathGeneratorResult.SourceMarkerAngle;
|
||||
EndAngle = PathGeneratorResult.TargetMarkerAngle;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user