Files
GeekDesk/Converts/IntToCornerRadius.cs

31 lines
786 B
C#
Raw Permalink Normal View History

2021-04-12 13:46:05 +08:00
using System;
using System.Globalization;
2021-05-28 18:01:19 +08:00
using System.Windows;
2021-04-12 13:46:05 +08:00
using System.Windows.Data;
2021-05-28 18:01:19 +08:00
namespace GeekDesk.Converts
2021-04-12 13:46:05 +08:00
{
2021-05-28 18:01:19 +08:00
class IntToCornerRadius : IValueConverter
2021-04-12 13:46:05 +08:00
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
2021-05-28 18:01:19 +08:00
int val = int.Parse(value.ToString());
2022-06-07 11:16:14 +08:00
var param = 0;
if (parameter != null)
{
param = int.Parse(parameter.ToString());
}
if (val + param > 0)
{
val += param;
}
2021-05-28 18:01:19 +08:00
return new CornerRadius(val);
2021-04-12 13:46:05 +08:00
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
2022-06-07 11:16:14 +08:00
return null;
2021-04-12 13:46:05 +08:00
}
}
}