mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-02 14:01:29 +08:00
箭头bug修复
This commit is contained in:
@@ -10,7 +10,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
var angleInRadians = Math.Atan2(route[1].Y - route[0].Y, route[1].X - route[0].X) + Math.PI;
|
var angleInRadians = Math.Atan2(route[1].Y - route[0].Y, route[1].X - route[0].X) + Math.PI;
|
||||||
var xChange = markerWidth * Math.Cos(angleInRadians);
|
var xChange = markerWidth * Math.Cos(angleInRadians);
|
||||||
var yChange = markerWidth * Math.Sin(angleInRadians);
|
var yChange = markerHeight * Math.Sin(angleInRadians);
|
||||||
route[0] = new PointBase(route[0].X - xChange, route[0].Y - yChange);
|
route[0] = new PointBase(route[0].X - xChange, route[0].Y - yChange);
|
||||||
return angleInRadians * 180 / Math.PI;
|
return angleInRadians * 180 / Math.PI;
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
var angleInRadians = Math.Atan2(route[route.Length - 1].Y - route[route.Length - 2].Y, route[route.Length - 1].X - route[route.Length - 2].X);
|
var angleInRadians = Math.Atan2(route[route.Length - 1].Y - route[route.Length - 2].Y, route[route.Length - 1].X - route[route.Length - 2].X);
|
||||||
var xChange = markerWidth * Math.Cos(angleInRadians);
|
var xChange = markerWidth * Math.Cos(angleInRadians);
|
||||||
var yChange = markerWidth * Math.Sin(angleInRadians);
|
var yChange = markerHeight * Math.Sin(angleInRadians);
|
||||||
route[route.Length - 1] = new PointBase(route[route.Length - 1].X - xChange, route[route.Length - 1].Y - yChange);
|
route[route.Length - 1] = new PointBase(route[route.Length - 1].X - xChange, route[route.Length - 1].Y - yChange);
|
||||||
return angleInRadians * 180 / Math.PI;
|
return angleInRadians * 180 / Math.PI;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,37 +43,47 @@
|
|||||||
</Path.Data>
|
</Path.Data>
|
||||||
</Path>
|
</Path>
|
||||||
|
|
||||||
<Path x:Name="rightarrow"
|
<Grid Canvas.Left="{Binding EndRectangle.Left}"
|
||||||
Data="{Binding ShapeViewModel.SinkMarker.Path}"
|
Canvas.Top="{Binding EndRectangle.Top}"
|
||||||
Width="{Binding ShapeViewModel.SinkMarker.Width}"
|
Width="{Binding EndRectangle.Width}"
|
||||||
Stretch="UniformToFill"
|
Height="{Binding EndRectangle.Height}">
|
||||||
RenderTransformOrigin="0.5,0.5"
|
<Path x:Name="rightarrow"
|
||||||
Visibility="{Binding Path=IsFullConnection, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
|
Data="{Binding ShapeViewModel.SinkMarker.Path}"
|
||||||
Style="{StaticResource ArrowStyle}">
|
Width="{Binding ShapeViewModel.SinkMarker.Width}"
|
||||||
<Path.RenderTransform>
|
Height="{Binding ShapeViewModel.SinkMarker.Height}"
|
||||||
<TransformGroup>
|
Stretch="Fill"
|
||||||
<RotateTransform x:Name="rightrot" Angle="{Binding EndAngle}"/>
|
VerticalAlignment="Center"
|
||||||
<TranslateTransform X="{Binding EndPoint.X}" Y="{Binding EndPoint.Y}"/>
|
HorizontalAlignment="Center"
|
||||||
</TransformGroup>
|
RenderTransformOrigin="0.5,0.5"
|
||||||
</Path.RenderTransform>
|
Style="{StaticResource ArrowStyle}">
|
||||||
</Path>
|
<Path.RenderTransform>
|
||||||
|
<TransformGroup>
|
||||||
|
<RotateTransform Angle="{Binding EndAngle}"/>
|
||||||
|
</TransformGroup>
|
||||||
|
</Path.RenderTransform>
|
||||||
|
</Path>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<Path x:Name="leftarrow"
|
<Grid Canvas.Left="{Binding StartRectangle.Left}"
|
||||||
Data="{Binding ShapeViewModel.SourceMarker.Path}"
|
Canvas.Top="{Binding StartRectangle.Top}"
|
||||||
Width="{Binding ShapeViewModel.SourceMarker.Width}"
|
Width="{Binding StartRectangle.Width}"
|
||||||
Canvas.Left="{Binding StartPoint.X}"
|
Height="{Binding StartRectangle.Height}">
|
||||||
Canvas.Top="{Binding StartPoint.Y}"
|
<Path x:Name="leftarrow"
|
||||||
Stretch="UniformToFill"
|
Data="{Binding ShapeViewModel.SourceMarker.Path}"
|
||||||
RenderTransformOrigin="0.5,0.5"
|
Width="{Binding ShapeViewModel.SourceMarker.Width}"
|
||||||
Visibility="{Binding Path=IsFullConnection, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
|
Height="{Binding ShapeViewModel.SourceMarker.Height}"
|
||||||
Style="{StaticResource ArrowStyle}">
|
Stretch="Fill"
|
||||||
<Path.RenderTransform>
|
VerticalAlignment="Center"
|
||||||
<TransformGroup>
|
HorizontalAlignment="Center"
|
||||||
<RotateTransform x:Name="leftrot" Angle="{Binding StartAngle}"/>
|
RenderTransformOrigin="0.5,0.5"
|
||||||
<TranslateTransform X="{Binding StartPoint.X}" Y="{Binding StartPoint.Y}"/>
|
Style="{StaticResource ArrowStyle}">
|
||||||
</TransformGroup>
|
<Path.RenderTransform>
|
||||||
</Path.RenderTransform>
|
<TransformGroup>
|
||||||
</Path>
|
<RotateTransform Angle="{Binding StartAngle}"/>
|
||||||
|
</TransformGroup>
|
||||||
|
</Path.RenderTransform>
|
||||||
|
</Path>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<Ellipse x:Name="ball" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
<Ellipse x:Name="ball" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
||||||
Width="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}"
|
Width="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}"
|
||||||
|
|||||||
@@ -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;
|
private RectangleBase _area;
|
||||||
public RectangleBase Area
|
public RectangleBase Area
|
||||||
{
|
{
|
||||||
@@ -520,35 +546,22 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
PathGeneratorResult = PathGenerator.Get(Root, this, route, source.Value, target.Value);
|
PathGeneratorResult = PathGenerator.Get(Root, this, route, source.Value, target.Value);
|
||||||
|
|
||||||
|
var startMiddle = new RectangleBase
|
||||||
var offsetX = Math.Sin(EndAngle / 180 * Math.PI) * GetSinkMarkerWidth() / 2;
|
(
|
||||||
var offsetY = Math.Cos(EndAngle / 180 * Math.PI) * GetSinkMarkerHeight() / 2;
|
Math.Abs((PathGeneratorResult.SourceMarkerPosition.X + (source.Value.X - Area.Left)) / 2),
|
||||||
if (PathGeneratorResult.Last1.X - PathGeneratorResult.Last2.X < -0.000001d)
|
Math.Abs((PathGeneratorResult.SourceMarkerPosition.Y + (source.Value.Y - Area.Top)) / 2),
|
||||||
{
|
0,
|
||||||
offsetX += GetSinkMarkerWidth();
|
0
|
||||||
}
|
|
||||||
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 endMiddle = new RectangleBase
|
||||||
//StartPoint = new PointBase
|
(
|
||||||
// (
|
Math.Abs((PathGeneratorResult.TargetMarkerPosition.X + (target.Value.X - Area.Left)) / 2),
|
||||||
// Math.Min(PathGeneratorResult.SourceMarkerPosition.X, source.Value.X),
|
Math.Abs((PathGeneratorResult.TargetMarkerPosition.Y + (target.Value.Y - Area.Top)) / 2),
|
||||||
// Math.Min(PathGeneratorResult.SourceMarkerPosition.Y, source.Value.Y)
|
0,
|
||||||
// );
|
0
|
||||||
//EndPoint = new PointBase
|
);
|
||||||
// (
|
StartRectangle = startMiddle.InflateRectangle(GetSourceMarkerWidth() / 2, GetSourceMarkerHeight() / 2);
|
||||||
// Math.Min(PathGeneratorResult.TargetMarkerPosition.X, target.Value.X),
|
EndRectangle = endMiddle.InflateRectangle(GetSinkMarkerWidth() / 2, GetSinkMarkerHeight() / 2);
|
||||||
// Math.Min(PathGeneratorResult.TargetMarkerPosition.Y, target.Value.Y)
|
|
||||||
// );
|
|
||||||
|
|
||||||
StartAngle = PathGeneratorResult.SourceMarkerAngle;
|
StartAngle = PathGeneratorResult.SourceMarkerAngle;
|
||||||
EndAngle = PathGeneratorResult.TargetMarkerAngle;
|
EndAngle = PathGeneratorResult.TargetMarkerAngle;
|
||||||
|
|||||||
Reference in New Issue
Block a user