diff --git a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableDesignerItemBase.cs b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableDesignerItemBase.cs index 9b111e2..73476d1 100644 --- a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableDesignerItemBase.cs +++ b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableDesignerItemBase.cs @@ -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; } diff --git a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Boundary.cs b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Boundary.cs index cce913a..42718a5 100644 --- a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Boundary.cs +++ b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Boundary.cs @@ -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); diff --git a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Corner.cs b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Corner.cs index d54d325..034845b 100644 --- a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Corner.cs +++ b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Corner.cs @@ -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); diff --git a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Smooth.cs b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Smooth.cs index a87921e..815ca47 100644 --- a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Smooth.cs +++ b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Smooth.cs @@ -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]; diff --git a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Straight.cs b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Straight.cs index ae09332..e427c4e 100644 --- a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Straight.cs +++ b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Straight.cs @@ -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); diff --git a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Utils.cs b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Utils.cs index 46982d0..88e1955 100644 --- a/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Utils.cs +++ b/AIStudio.Wpf.DiagramDesigner/PathGenerators/PathGenerators.Utils.cs @@ -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; } diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/ColorViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/ColorViewModel.cs index 30a9c37..76025de 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/ColorViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/ColorViewModel.cs @@ -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; + } + } } diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/IColorViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/IColorViewModel.cs index 06f2c3f..b83645c 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/IColorViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/IColorViewModel.cs @@ -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; } } diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectorViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectorViewModel.cs index 3c93c4d..29d9fec 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectorViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectorViewModel.cs @@ -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); } }