mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using AIStudio.Wpf.DiagramDesigner;
|
|
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
|
|
{
|
|
public class ConectorValueConverter : IMultiValueConverter
|
|
{
|
|
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
if (values == null || values.Length < 2)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
if (values[0] is double && values[2] is ConnectorValueType)
|
|
{
|
|
double connectorValue = (double)values[0];
|
|
string connectorString = values[1] as string;
|
|
ConnectorValueType valueTypePoint = (ConnectorValueType)values[2];
|
|
|
|
if (valueTypePoint == ConnectorValueType.Bool)
|
|
{
|
|
return (connectorValue == 0) ? "F" : "T";
|
|
}
|
|
else if (valueTypePoint == ConnectorValueType.Int)
|
|
{
|
|
return connectorValue.ToString("0");
|
|
}
|
|
else if (valueTypePoint == ConnectorValueType.Real)
|
|
{
|
|
return connectorValue.ToString("f3");
|
|
}
|
|
else
|
|
{
|
|
return connectorString;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|