mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-12 20:26:35 +08:00
箭头位置,指向连接点的中心
This commit is contained in:
@@ -182,6 +182,26 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
[XmlIgnore]
|
||||
public double LeftArrowSize
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
[XmlIgnore]
|
||||
public double RightArrowSize
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
route = GetRouteWithMiddlePoints(_, link, route);
|
||||
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowPathStyle == ArrowPathStyle.None ? 0d : (double)link.ColorViewModel.LeftArrowSizeStyle);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowPathStyle == ArrowPathStyle.None ? 0d : (double)link.ColorViewModel.RightArrowPathStyle);
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowSize);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowSize);
|
||||
|
||||
DoShift(route, link);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
link.SourceConnectorInfo.MiddlePosition,
|
||||
link.SourceConnectorInfo.Orientation,
|
||||
link.SinkConnectorInfo.MiddlePosition,
|
||||
link.IsFullConnection ? link.SinkConnectorInfoFully.Orientation : (link.SinkConnectorInfo.Position.Y >= link.SourceConnectorInfo.Position.Y ? ConnectorOrientation.Top : ConnectorOrientation.Bottom),
|
||||
link.IsFullConnection ? link.SinkConnectorInfoFully.Orientation : (link.SinkConnectorInfo.MiddlePosition.Y >= link.SourceConnectorInfo.MiddlePosition.Y ? ConnectorOrientation.Top : ConnectorOrientation.Bottom),
|
||||
_.GridCellSize,
|
||||
_.GridMargin);
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
else
|
||||
route = GetRouteWithPartConnectionLine(_, link, route);
|
||||
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowPathStyle == ArrowPathStyle.None ? 0d : (double)link.ColorViewModel.LeftArrowSizeStyle);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowPathStyle == ArrowPathStyle.None ? 0d : (double)link.ColorViewModel.RightArrowPathStyle);
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowSize);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowSize);
|
||||
|
||||
DoShift(route, link);
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
route = GetRouteWithCurvePoints(link, route);
|
||||
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowPathStyle == ArrowPathStyle.None ? 0d : (double)link.ColorViewModel.LeftArrowSizeStyle);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowPathStyle == ArrowPathStyle.None ? 0d : (double)link.ColorViewModel.RightArrowPathStyle);
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowSize);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowSize);
|
||||
|
||||
DoShift(route, link);
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private static PathGeneratorResult CurveThroughPoints(PointBase[] route, ConnectorViewModel link)
|
||||
{
|
||||
double sourceAngle = SourceMarkerAdjustement(route, (double)link.ColorViewModel.LeftArrowSizeStyle);
|
||||
double targetAngle = TargetMarkerAdjustement(route, (double)link.ColorViewModel.RightArrowPathStyle);
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowSize);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowSize);
|
||||
|
||||
BezierSpline.GetCurveControlPoints(route, out var firstControlPoints, out var secondControlPoints);
|
||||
var paths = new string[firstControlPoints.Length];
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
route = ConcatRouteAndSourceAndTarget(route, source, target);
|
||||
|
||||
double sourceAngle = SourceMarkerAdjustement(route, (double)link.ColorViewModel.LeftArrowSizeStyle);
|
||||
double targetAngle = TargetMarkerAdjustement(route, (double)link.ColorViewModel.RightArrowPathStyle);
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowSize);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowSize);
|
||||
|
||||
DoShift(route, link);
|
||||
|
||||
|
||||
@@ -9,18 +9,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public static double SourceMarkerAdjustement(PointBase[] route, double markerWidth)
|
||||
{
|
||||
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);
|
||||
route[0] = new PointBase(route[0].X - xChange, route[0].Y - yChange);
|
||||
//不需要留出箭头的位置
|
||||
//var xChange = markerWidth * Math.Cos(angleInRadians);
|
||||
//var yChange = markerWidth * Math.Sin(angleInRadians);
|
||||
//route[0] = new PointBase(route[0].X - xChange, route[0].Y - yChange);
|
||||
return angleInRadians * 180 / Math.PI;
|
||||
}
|
||||
|
||||
public static double TargetMarkerAdjustement(PointBase[] route, double markerWidth)
|
||||
{
|
||||
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);
|
||||
route[route.Length - 1] = new PointBase(route[route.Length - 1].X - xChange, route[route.Length - 1].Y - yChange);
|
||||
//不需要留出箭头的位置
|
||||
//var xChange = markerWidth * Math.Cos(angleInRadians);
|
||||
//var yChange = markerWidth * 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,22 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double LeftArrowSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return LeftArrowPathStyle == ArrowPathStyle.None ? 0d : (double)LeftArrowSizeStyle;
|
||||
}
|
||||
}
|
||||
|
||||
public double RightArrowSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return RightArrowPathStyle == ArrowPathStyle.None ? 0d : (double)RightArrowSizeStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,19 +3,55 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IColorViewModel
|
||||
{
|
||||
IColorObject LineColor { get; set; }
|
||||
IColorObject FillColor { get; set; }
|
||||
Color ShadowColor { get; set; }
|
||||
double LineWidth { get; set; }
|
||||
ArrowPathStyle LeftArrowPathStyle { get; set; }
|
||||
ArrowPathStyle RightArrowPathStyle { get; set; }
|
||||
ArrowSizeStyle LeftArrowSizeStyle { get; set; }
|
||||
ArrowSizeStyle RightArrowSizeStyle { get; set; }
|
||||
IColorObject LineColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
IColorObject FillColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
Color ShadowColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
double LineWidth
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
ArrowPathStyle LeftArrowPathStyle
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
ArrowPathStyle RightArrowPathStyle
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
ArrowSizeStyle LeftArrowSizeStyle
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
ArrowSizeStyle RightArrowSizeStyle
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
double LeftArrowSize
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
double RightArrowSize
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,9 +497,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
else
|
||||
{
|
||||
var source = GetPortPositionBasedOnAlignment(SourceConnectorInfo, ColorViewModel.LeftArrowSizeStyle);
|
||||
var target = GetPortPositionBasedOnAlignment(SinkConnectorInfoFully, ColorViewModel.RightArrowSizeStyle);
|
||||
return (source, target ?? OnGoingPosition);
|
||||
var source = SourceConnectorInfo.MiddlePosition;//GetPortPositionBasedOnAlignment(SourceConnectorInfo, ColorViewModel.LeftArrowSizeStyle);
|
||||
var target = SinkConnectorInfo.MiddlePosition;// GetPortPositionBasedOnAlignment(SinkConnectorInfoFully, ColorViewModel.RightArrowSizeStyle);
|
||||
return (source, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user