使用PointBase代替Point

This commit is contained in:
艾竹
2023-01-08 09:22:37 +08:00
parent 8fc69bc96d
commit 5d7717cc2b
65 changed files with 4317 additions and 403 deletions

View File

@@ -26,45 +26,53 @@ namespace AIStudio.Wpf.DiagramDesigner
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
PathGeometry pathGeometry = new PathGeometry();
if (values[0] != null)
{
List<PointInfoBase> points = (List<PointInfoBase>)values[0];
//if (values[0] != null)
//{
// List<ConnectorPoint> points = (List<ConnectorPoint>)values[0];
PathFigure figure = new PathFigure();
figure.StartPoint = points[0];
if (values[1]?.ToString() == DrawMode.RadiusConnectingLine.ToString())
{
for (var i = 0; i < points.Count - 1; i++)
{
int current = i, last = i - 1, next = i + 1, next2 = i + 2;
if (last == -1)
{
last = 0;
}
if (next == points.Count)
{
next = points.Count - 1;
}
if (next2 == points.Count)
{
next2 = points.Count - 1;
}
var bzs = SegmentHelper.GetBezierSegment(points[current], points[last], points[next], points[next2]);
figure.Segments.Add(bzs);
}
}
else
{
for (int i = 0; i < points.Count; i++)
{
// PathFigure figure = new PathFigure();
// figure.StartPoint = points[0];
// if (values[1]?.ToString() == DrawMode.RadiusConnectingLine.ToString())
// {
// for (var i = 0; i < points.Count - 1; i++)
// {
// int current = i, last = i - 1, next = i + 1, next2 = i + 2;
// if (last == -1)
// {
// last = 0;
// }
// if (next == points.Count)
// {
// next = points.Count - 1;
// }
// if (next2 == points.Count)
// {
// next2 = points.Count - 1;
// }
// var bzs = SegmentHelper.GetBezierSegment(points[current], points[last], points[next], points[next2]);
// figure.Segments.Add(bzs);
// }
LineSegment arc = new LineSegment(points[i], true);
figure.Segments.Add(arc);
}
}
// //贝塞尔曲线的简单连接
// //var start = points[0];
// //var end = points.Last();
// //var width = end.X - start.X;
// //var height = end.Y - start.Y;
// //var ctrlPos = 0.382 * width + 0.309 * height;
// //figure.Segments.Add(new BezierSegment(new Point(ctrlPos - 1, 1), new Point(width - ctrlPos + 1, height - 1), new Point(width - 1, height - 1), true));
// }
// else
// {
// for (int i = 0; i < points.Count; i++)
// {
pathGeometry.Figures.Add(figure);
}
// LineSegment arc = new LineSegment(points[i], true);
// figure.Segments.Add(arc);
// }
// }
// pathGeometry.Figures.Add(figure);
//}
return pathGeometry;
}