功能更新
This commit is contained in:
38
Melskin/Converters/Internal/DoubleToCornerRadiusConverter.cs
Normal file
38
Melskin/Converters/Internal/DoubleToCornerRadiusConverter.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user