2022-10-28 22:45:39 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Data;
|
2025-01-19 11:02:03 +08:00
|
|
|
|
using System.Windows.Markup;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2025-01-19 11:02:03 +08:00
|
|
|
|
public class ConectorOrientationConverter : MarkupExtension, IValueConverter
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2025-01-19 11:02:03 +08:00
|
|
|
|
public double Parameter { get; set; } = 5;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value is string)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = value as string;
|
|
|
|
|
|
|
2025-01-19 11:02:03 +08:00
|
|
|
|
var length = 0 - Parameter - (str.Length * 4);
|
|
|
|
|
|
return length;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (value is double)
|
|
|
|
|
|
{
|
|
|
|
|
|
return -Parameter - (double)value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
2025-01-19 11:02:03 +08:00
|
|
|
|
|
|
|
|
|
|
public override object ProvideValue(System.IServiceProvider serviceProvider)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new ConectorOrientationConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
Parameter = this.Parameter,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|