修改暂存一下

This commit is contained in:
艾竹
2023-01-12 23:02:53 +08:00
parent 5d7717cc2b
commit 6a4c31106a
58 changed files with 776 additions and 468 deletions

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
public interface IPathGenerator
{
PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target);
}
}

View File

@@ -1,4 +1,4 @@
using AIStudio.Wpf.DiagramDesigner.Geometry;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{

View File

@@ -1,5 +1,6 @@
using System;
using AIStudio.Wpf.DiagramDesigner.Geometry;
using System.Linq;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -19,7 +20,9 @@ namespace AIStudio.Wpf.DiagramDesigner
double? targetAngle = null;
sourceAngle = SourceMarkerAdjustement(route, (double)link.ColorViewModel.LeftArrowSizeStyle);
targetAngle = TargetMarkerAdjustement(route, (double)link.ColorViewModel.RightArrowPathStyle);
targetAngle = TargetMarkerAdjustement(route, (double)link.ColorViewModel.RightArrowPathStyle);
DoShift(route, link);
var path = FormattableString.Invariant($"M {route[0].X} {route[0].Y} C {route[1].X} {route[1].Y}, {route[2].X} {route[2].Y}, {route[3].X} {route[3].Y}");
return new PathGeneratorResult(new[] { path }, sourceAngle, route[0], targetAngle, route[route.Length - 1]);
@@ -33,7 +36,7 @@ namespace AIStudio.Wpf.DiagramDesigner
sourceAngle = SourceMarkerAdjustement(route, (double)link.ColorViewModel.LeftArrowSizeStyle);
targetAngle = TargetMarkerAdjustement(route, (double)link.ColorViewModel.RightArrowPathStyle);
Geometry.BezierSpline.GetCurveControlPoints(route, out var firstControlPoints, out var secondControlPoints);
BezierSpline.GetCurveControlPoints(route, out var firstControlPoints, out var secondControlPoints);
var paths = new string[firstControlPoints.Length];
for (var i = 0; i < firstControlPoints.Length; i++)
@@ -88,5 +91,7 @@ namespace AIStudio.Wpf.DiagramDesigner
default: return new PointBase(cX, cY);
};
}
}
}

View File

@@ -1,5 +1,5 @@
using System;
using AIStudio.Wpf.DiagramDesigner.Geometry;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -14,6 +14,8 @@ namespace AIStudio.Wpf.DiagramDesigner
sourceAngle = SourceMarkerAdjustement(route, (double)link.ColorViewModel.LeftArrowSizeStyle);
targetAngle = TargetMarkerAdjustement(route, (double)link.ColorViewModel.RightArrowPathStyle);
DoShift(route, link);
var paths = new string[route.Length - 1];
for (var i = 0; i < route.Length - 1; i++)
{
@@ -21,6 +23,6 @@ namespace AIStudio.Wpf.DiagramDesigner
}
return new PathGeneratorResult(paths, sourceAngle, route[0], targetAngle, route[route.Length - 1]);
}
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using AIStudio.Wpf.DiagramDesigner.Geometry;
using System.Linq;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -28,8 +29,20 @@ namespace AIStudio.Wpf.DiagramDesigner
var result = new PointBase[route.Length + 2];
result[0] = source;
route.CopyTo(result, 1);
result[route.Length - 1] = target;
result[result.Length - 1] = target;
return result;
}
private static void DoShift(PointBase[] points, ConnectorViewModel link)
{
double left = link.Area.Left;
double top = link.Area.Top;
for (int i = 0; i < points.Length; i++)
{
points[i].X = points[i].X - left;
points[i].Y = points[i].Y - top;
}
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
public class SmoothPathGenerator : IPathGenerator
{
public PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
{
return PathGenerators.Smooth(_, link, route, source, target);
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
public class StraightPathGenerator : IPathGenerator
{
public PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
{
return PathGenerators.Straight(_, link, route, source, target);
}
}
}