mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
连线优化1:开始和结束节点。
This commit is contained in:
@@ -72,6 +72,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
this.SourceConnectorInfo = sourceConnectorInfo;
|
||||
this.SinkConnectorInfo = sinkConnectorInfo;
|
||||
|
||||
|
||||
DeleteConnectionCommand = new SimpleCommand(Command_Enable, DeleteConnection);
|
||||
AddVertexCommand = new SimpleCommand(Command_Enable, AddVertex);
|
||||
@@ -612,8 +613,37 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
StartAngle = PathGeneratorResult.SourceMarkerAngle;
|
||||
EndAngle = PathGeneratorResult.TargetMarkerAngle;
|
||||
StartPoint = new PointBase(source.Value.X - Area.Left - SourceConnectorInfo.ConnectorWidth / 2, source.Value.Y - Area.Top - SourceConnectorInfo.ConnectorHeight / 2) ;
|
||||
EndPoint = new PointBase(target.Value.X - Area.Left - SinkConnectorInfo.ConnectorWidth / 2 , target.Value.Y - Area.Top - SinkConnectorInfo.ConnectorHeight / 2 );
|
||||
//StartPoint = new PointBase(source.Value.X - Area.Left - SourceConnectorInfo.ConnectorWidth / 2, source.Value.Y - Area.Top - SourceConnectorInfo.ConnectorHeight / 2) ;
|
||||
//EndPoint = new PointBase(target.Value.X - Area.Left - SinkConnectorInfo.ConnectorWidth / 2 , target.Value.Y - Area.Top - SinkConnectorInfo.ConnectorHeight / 2 );
|
||||
|
||||
StartPoint = new PointBase(source.Value.X - Area.Left , source.Value.Y - Area.Top );
|
||||
EndPoint = new PointBase(target.Value.X - Area.Left , target.Value.Y - Area.Top);
|
||||
|
||||
var startVertice = Vertices.FirstOrDefault(p => p.ConnectorVertexType == ConnectorVertexType.Start);
|
||||
if (startVertice == null)
|
||||
{
|
||||
startVertice = new ConnectorVertexModel(this, StartPoint) { ConnectorVertexType = ConnectorVertexType.Start };
|
||||
startVertice.ColorViewModel.FillColor.Color = Colors.DarkRed;
|
||||
startVertice.ColorViewModel.LineColor.Color = Colors.DarkRed;
|
||||
Vertices.Add(startVertice);
|
||||
}
|
||||
else
|
||||
{
|
||||
startVertice.SetPosition(StartPoint);
|
||||
}
|
||||
|
||||
var endVertice = Vertices.FirstOrDefault(p => p.ConnectorVertexType == ConnectorVertexType.End);
|
||||
if (endVertice == null)
|
||||
{
|
||||
endVertice = new ConnectorVertexModel(this, EndPoint) { ConnectorVertexType = ConnectorVertexType.End };
|
||||
endVertice.ColorViewModel.FillColor.Color = Colors.DarkRed;
|
||||
endVertice.ColorViewModel.LineColor.Color = Colors.DarkRed;
|
||||
Vertices.Add(endVertice);
|
||||
}
|
||||
else
|
||||
{
|
||||
endVertice.SetPosition(EndPoint);
|
||||
}
|
||||
|
||||
var paths = Labels.Count > 0 ? PathGeneratorResult.Paths.Select(p => new SvgPath(p)).ToArray() : Array.Empty<SvgPath>();
|
||||
foreach (var label in Labels)
|
||||
@@ -821,6 +851,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
pointBase = new PointBase(pointBase.X - Area.Left, pointBase.Y - Area.Top);
|
||||
}
|
||||
var vertice = new ConnectorVertexModel(this, pointBase);
|
||||
vertice.ColorViewModel.LineColor.Color = Colors.Blue;
|
||||
vertice.PropertyChanged += new WeakINPCEventHandler(Item_PropertyChanged).Handler;
|
||||
Vertices.Add(vertice);
|
||||
UpdatePathGeneratorResult();
|
||||
|
||||
Reference in New Issue
Block a user