mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-26 03:07:55 +08:00
修改暂存一下
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
@@ -26,53 +27,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
PathGeometry pathGeometry = new PathGeometry();
|
||||
//if (values[0] != null)
|
||||
//{
|
||||
// List<ConnectorPoint> points = (List<ConnectorPoint>)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);
|
||||
// }
|
||||
|
||||
// //贝塞尔曲线的简单连接
|
||||
// //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++)
|
||||
// {
|
||||
|
||||
// LineSegment arc = new LineSegment(points[i], true);
|
||||
// figure.Segments.Add(arc);
|
||||
// }
|
||||
// }
|
||||
|
||||
// pathGeometry.Figures.Add(figure);
|
||||
//}
|
||||
PathFigure figure = new PathFigure();
|
||||
figure.StartPoint = (PointBase)points[0];
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
{
|
||||
LineSegment arc = new LineSegment((PointBase)points[i], true);
|
||||
figure.Segments.Add(arc);
|
||||
}
|
||||
pathGeometry.Figures.Add(figure);
|
||||
}
|
||||
return pathGeometry;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
[ValueConversion(typeof(List<Point>), typeof(PathSegmentCollection))]
|
||||
public class ConnectionPathConverter : IValueConverter
|
||||
public class ConnectionPathConverter : IMultiValueConverter
|
||||
{
|
||||
static ConnectionPathConverter()
|
||||
{
|
||||
@@ -23,21 +24,22 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
private set;
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
List<ConnectorPoint> points = (List<ConnectorPoint>)value;
|
||||
PointCollection pointCollection = new PointCollection();
|
||||
if (points != null)
|
||||
GeometryGroup geometryGroup = new GeometryGroup();
|
||||
if (values[0] is PathGeneratorResult result)
|
||||
{
|
||||
foreach (var point in points)
|
||||
foreach (var path in result.Paths)
|
||||
{
|
||||
pointCollection.Add(new Point(point.X, point.Y));
|
||||
PathGeometry pathGeometry = PathGeometry.CreateFromGeometry(Geometry.Parse(path));
|
||||
geometryGroup.Children.Add(pathGeometry);
|
||||
}
|
||||
}
|
||||
return pointCollection;
|
||||
|
||||
return geometryGroup;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
[ValueConversion(typeof(List<Point>), typeof(PointCollection))]
|
||||
public class ConnectionPointConverter : IValueConverter
|
||||
{
|
||||
static ConnectionPointConverter()
|
||||
{
|
||||
Instance = new ConnectionPointConverter();
|
||||
}
|
||||
|
||||
public static ConnectionPointConverter Instance
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
List<Point> points = (List<Point>)value;
|
||||
PointCollection pointCollection = new PointCollection();
|
||||
if (points != null)
|
||||
{
|
||||
foreach (var point in points)
|
||||
{
|
||||
pointCollection.Add(new Point(point.X, point.Y));
|
||||
}
|
||||
}
|
||||
return pointCollection;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user