mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-13 04:36:37 +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 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);
|
||||
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 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);
|
||||
return angleInRadians * 180 / Math.PI;
|
||||
}
|
||||
|
||||
@@ -43,37 +43,47 @@
|
||||
</Path.Data>
|
||||
</Path>
|
||||
|
||||
<Path x:Name="rightarrow"
|
||||
Data="{Binding ShapeViewModel.SinkMarker.Path}"
|
||||
Width="{Binding ShapeViewModel.SinkMarker.Width}"
|
||||
Stretch="UniformToFill"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Visibility="{Binding Path=IsFullConnection, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
|
||||
Style="{StaticResource ArrowStyle}">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform x:Name="rightrot" Angle="{Binding EndAngle}"/>
|
||||
<TranslateTransform X="{Binding EndPoint.X}" Y="{Binding EndPoint.Y}"/>
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Grid Canvas.Left="{Binding EndRectangle.Left}"
|
||||
Canvas.Top="{Binding EndRectangle.Top}"
|
||||
Width="{Binding EndRectangle.Width}"
|
||||
Height="{Binding EndRectangle.Height}">
|
||||
<Path x:Name="rightarrow"
|
||||
Data="{Binding ShapeViewModel.SinkMarker.Path}"
|
||||
Width="{Binding ShapeViewModel.SinkMarker.Width}"
|
||||
Height="{Binding ShapeViewModel.SinkMarker.Height}"
|
||||
Stretch="Fill"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Style="{StaticResource ArrowStyle}">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="{Binding EndAngle}"/>
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</Grid>
|
||||
|
||||
<Path x:Name="leftarrow"
|
||||
Data="{Binding ShapeViewModel.SourceMarker.Path}"
|
||||
Width="{Binding ShapeViewModel.SourceMarker.Width}"
|
||||
Canvas.Left="{Binding StartPoint.X}"
|
||||
Canvas.Top="{Binding StartPoint.Y}"
|
||||
Stretch="UniformToFill"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Visibility="{Binding Path=IsFullConnection, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
|
||||
Style="{StaticResource ArrowStyle}">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform x:Name="leftrot" Angle="{Binding StartAngle}"/>
|
||||
<TranslateTransform X="{Binding StartPoint.X}" Y="{Binding StartPoint.Y}"/>
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Grid Canvas.Left="{Binding StartRectangle.Left}"
|
||||
Canvas.Top="{Binding StartRectangle.Top}"
|
||||
Width="{Binding StartRectangle.Width}"
|
||||
Height="{Binding StartRectangle.Height}">
|
||||
<Path x:Name="leftarrow"
|
||||
Data="{Binding ShapeViewModel.SourceMarker.Path}"
|
||||
Width="{Binding ShapeViewModel.SourceMarker.Width}"
|
||||
Height="{Binding ShapeViewModel.SourceMarker.Height}"
|
||||
Stretch="Fill"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Style="{StaticResource ArrowStyle}">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="{Binding StartAngle}"/>
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</Grid>
|
||||
|
||||
<Ellipse x:Name="ball" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
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;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user