Files
ShrlAlgoToolkit/Melskin/Converters/Internal/DoubleToCornerRadiusConverter.cs
2026-02-17 22:17:13 +08:00

39 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Melskin.Converters.Internal
{
/// <summary>
/// 数字转换为圆角转换器
/// </summary>
public class DoubleToCornerRadiusConverter : IValueConverter
{
/// <summary>
/// 单例
/// </summary>
public static readonly DoubleToCornerRadiusConverter Instance = new();
/// <inheritdoc />
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (double.TryParse(value?.ToString(),out double result))
{
return new CornerRadius(result);
}
return new CornerRadius();
}
/// <inheritdoc />
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}