2021-07-23 09:42:22 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2023-01-12 23:02:53 +08:00
|
|
|
|
using System.Globalization;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
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-07-23 09:42:22 +08:00
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-12 23:02:53 +08:00
|
|
|
|
public class ConnectionPathConverter : IMultiValueConverter
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
static ConnectionPathConverter()
|
|
|
|
|
|
{
|
|
|
|
|
|
Instance = new ConnectionPathConverter();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ConnectionPathConverter Instance
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
private set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-12 23:02:53 +08:00
|
|
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-12 23:02:53 +08:00
|
|
|
|
GeometryGroup geometryGroup = new GeometryGroup();
|
|
|
|
|
|
if (values[0] is PathGeneratorResult result)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-12 23:02:53 +08:00
|
|
|
|
foreach (var path in result.Paths)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-12 23:02:53 +08:00
|
|
|
|
PathGeometry pathGeometry = PathGeometry.CreateFromGeometry(Geometry.Parse(path));
|
|
|
|
|
|
geometryGroup.Children.Add(pathGeometry);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-12 23:02:53 +08:00
|
|
|
|
|
|
|
|
|
|
return geometryGroup;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-12 23:02:53 +08:00
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|