箭头bug修复

This commit is contained in:
艾竹
2023-02-04 12:17:03 +08:00
parent 8bec9b446f
commit bf5717cf25
3 changed files with 83 additions and 60 deletions

View File

@@ -208,6 +208,32 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
private RectangleBase _startRectangle;
public RectangleBase StartRectangle
{
get
{
return _startRectangle;
}
private set
{
SetProperty(ref _startRectangle, value);
}
}
private RectangleBase _endRectangle;
public RectangleBase EndRectangle
{
get
{
return _endRectangle;
}
private set
{
SetProperty(ref _endRectangle, value);
}
}
private RectangleBase _area;
public RectangleBase Area
{
@@ -520,35 +546,22 @@ namespace AIStudio.Wpf.DiagramDesigner
PathGeneratorResult = PathGenerator.Get(Root, this, route, source.Value, target.Value);
var offsetX = Math.Sin(EndAngle / 180 * Math.PI) * GetSinkMarkerWidth() / 2;
var offsetY = Math.Cos(EndAngle / 180 * Math.PI) * GetSinkMarkerHeight() / 2;
if (PathGeneratorResult.Last1.X - PathGeneratorResult.Last2.X < -0.000001d)
{
offsetX += GetSinkMarkerWidth();
}
if (PathGeneratorResult.Last1.Y - PathGeneratorResult.Last2.Y < -0.000001d)
{
offsetY += GetSinkMarkerHeight();
}
StartPoint = PathGeneratorResult.SourceMarkerPosition;
EndPoint = new PointBase
(
PathGeneratorResult.TargetMarkerPosition.X - Math.Abs(offsetX),
PathGeneratorResult.TargetMarkerPosition.Y - Math.Abs(offsetY)
var startMiddle = new RectangleBase
(
Math.Abs((PathGeneratorResult.SourceMarkerPosition.X + (source.Value.X - Area.Left)) / 2),
Math.Abs((PathGeneratorResult.SourceMarkerPosition.Y + (source.Value.Y - Area.Top)) / 2),
0,
0
);
//StartPoint = new PointBase
// (
// Math.Min(PathGeneratorResult.SourceMarkerPosition.X, source.Value.X),
// Math.Min(PathGeneratorResult.SourceMarkerPosition.Y, source.Value.Y)
// );
//EndPoint = new PointBase
// (
// Math.Min(PathGeneratorResult.TargetMarkerPosition.X, target.Value.X),
// Math.Min(PathGeneratorResult.TargetMarkerPosition.Y, target.Value.Y)
// );
var endMiddle = new RectangleBase
(
Math.Abs((PathGeneratorResult.TargetMarkerPosition.X + (target.Value.X - Area.Left)) / 2),
Math.Abs((PathGeneratorResult.TargetMarkerPosition.Y + (target.Value.Y - Area.Top)) / 2),
0,
0
);
StartRectangle = startMiddle.InflateRectangle(GetSourceMarkerWidth() / 2, GetSourceMarkerHeight() / 2);
EndRectangle = endMiddle.InflateRectangle(GetSinkMarkerWidth() / 2, GetSinkMarkerHeight() / 2);
StartAngle = PathGeneratorResult.SourceMarkerAngle;
EndAngle = PathGeneratorResult.TargetMarkerAngle;