2021-08-06 18:12:05 +08:00
|
|
|
|
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;
|
2023-01-12 23:02:53 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
2021-08-06 18:12:05 +08:00
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-08-06 18:12:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class ConnectionDataConverter : IMultiValueConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
static ConnectionDataConverter()
|
|
|
|
|
|
{
|
|
|
|
|
|
Instance = new ConnectionDataConverter();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ConnectionDataConverter Instance
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
private set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
PathGeometry pathGeometry = new PathGeometry();
|
2023-01-12 23:02:53 +08:00
|
|
|
|
if (values[0] != null)
|
|
|
|
|
|
{
|
2023-01-24 16:20:39 +08:00
|
|
|
|
List<ConnectorPointModel> points = (List<ConnectorPointModel>)values[0];
|
2023-01-12 23:02:53 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
2021-08-06 18:12:05 +08:00
|
|
|
|
return pathGeometry;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|