mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-30 13:13:24 +08:00
画线调整
This commit is contained in:
@@ -9,20 +9,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
public static double SourceMarkerAdjustement(PointBase[] route, double markerWidth)
|
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 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 = markerWidth * 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double TargetMarkerAdjustement(PointBase[] route, double markerWidth)
|
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 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 = markerWidth * 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
private void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
|
private void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
|
||||||
{
|
{
|
||||||
this.Parent = sourceConnectorInfo.DataItem.Parent;
|
this.Parent = sourceConnectorInfo.DataItem.Parent;
|
||||||
|
if (Parent != null && Parent.ColorViewModel != null)
|
||||||
|
{
|
||||||
|
this.ColorViewModel = CopyHelper.Mapper(Parent.ColorViewModel);
|
||||||
|
}
|
||||||
|
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
||||||
|
{
|
||||||
|
this.ColorViewModel.RightArrowPathStyle = ArrowPathStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
var routetype = GlobalType.AllTypes.Where(p => typeof(IRouter).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == RouterMode);
|
var routetype = GlobalType.AllTypes.Where(p => typeof(IRouter).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == RouterMode);
|
||||||
Router = routetype != null ? (System.Activator.CreateInstance(routetype) as IRouter) : new RouterNormal();
|
Router = routetype != null ? (System.Activator.CreateInstance(routetype) as IRouter) : new RouterNormal();
|
||||||
@@ -48,15 +56,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.SinkConnectorInfo = sinkConnectorInfo;
|
this.SinkConnectorInfo = sinkConnectorInfo;
|
||||||
DeleteConnectionCommand = new SimpleCommand(DeleteConnection);
|
DeleteConnectionCommand = new SimpleCommand(DeleteConnection);
|
||||||
AddVertexCommand = new SimpleCommand(AddVertex);
|
AddVertexCommand = new SimpleCommand(AddVertex);
|
||||||
|
|
||||||
if (Parent != null && Parent.ColorViewModel != null)
|
|
||||||
{
|
|
||||||
this.ColorViewModel = CopyHelper.Mapper(Parent.ColorViewModel);
|
|
||||||
}
|
|
||||||
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
|
||||||
{
|
|
||||||
this.ColorViewModel.RightArrowPathStyle = ArrowPathStyle.None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectableDesignerItemBase ToXmlObject()
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
@@ -356,8 +355,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
PathGeneratorResult = PathGenerator.Get(Parent, this, route, source.Value, target.Value);
|
PathGeneratorResult = PathGenerator.Get(Parent, this, route, source.Value, target.Value);
|
||||||
StartPoint = PathGeneratorResult.SourceMarkerPosition;
|
|
||||||
EndPoint = PathGeneratorResult.TargetMarkerPosition;
|
StartPoint = new PointBase(source.Value.X - Area.Left, source.Value.Y - Area.Top);
|
||||||
|
EndPoint = new PointBase(target.Value.X - Area.Left, target.Value.Y - Area.Top);
|
||||||
StartAngle = PathGeneratorResult.SourceMarkerAngle;
|
StartAngle = PathGeneratorResult.SourceMarkerAngle;
|
||||||
EndAngle = PathGeneratorResult.TargetMarkerAngle;
|
EndAngle = PathGeneratorResult.TargetMarkerAngle;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user