Files
ShrlAlgoToolkit/Melskin/Converters/Internal/DoubleToCornerRadiusConverter.cs

39 lines
1.0 KiB
C#
Raw Normal View History

2025-12-23 21:35:54 +08:00
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
2026-01-02 17:30:41 +08:00
namespace Melskin.Converters.Internal
2025-12-23 21:35:54 +08:00
{
/// <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();
}
}
}