mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-25 10:56:35 +08:00
Mind 出发
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class DoubleToCornerRadius : IValueConverter
|
||||
{
|
||||
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
if (parameter != null)
|
||||
{
|
||||
switch (parameter.ToString())
|
||||
{
|
||||
case "TopLeft":
|
||||
return new CornerRadius(System.Convert.ToDouble(value), 0, 0, 0);
|
||||
|
||||
case "TopRight":
|
||||
return new CornerRadius(0, System.Convert.ToDouble(value), 0, 0);
|
||||
|
||||
case "BottomRight":
|
||||
return new CornerRadius(0, 0, System.Convert.ToDouble(value), 0);
|
||||
|
||||
case "ButtomLeft":
|
||||
return new CornerRadius(0, 0, 0, System.Convert.ToDouble(value));
|
||||
|
||||
default:
|
||||
return new CornerRadius(System.Convert.ToDouble(value));
|
||||
}
|
||||
}
|
||||
return new CornerRadius(System.Convert.ToDouble(value));
|
||||
}
|
||||
return new CornerRadius(0);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
if (parameter != null)
|
||||
{
|
||||
switch (parameter.ToString())
|
||||
{
|
||||
case "TopLeft":
|
||||
return ((CornerRadius)value).TopLeft;
|
||||
|
||||
case "TopRight":
|
||||
return ((CornerRadius)value).TopRight;
|
||||
|
||||
case "BottomRight":
|
||||
return ((CornerRadius)value).BottomRight;
|
||||
|
||||
case "BottomLeft":
|
||||
return ((CornerRadius)value).BottomLeft;
|
||||
|
||||
default:
|
||||
return ((CornerRadius)value).TopLeft;
|
||||
}
|
||||
}
|
||||
return ((CornerRadius)value).TopLeft;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user