26 lines
779 B
C#
26 lines
779 B
C#
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace NeumUI.Converters.Internal;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[ValueConversion(typeof(double), typeof(Thickness))]
|
|
internal class IntensityToSlotMarginConverter : IValueConverter
|
|
{
|
|
public static readonly IntensityToSlotMarginConverter Instance = new();
|
|
|
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
var intensity = (double)(value ?? 0);
|
|
//边距越小,留下的边框越窄
|
|
var uniformValue = 4 * intensity + 4;
|
|
return new Thickness(uniformValue);
|
|
}
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
return Binding.DoNothing;
|
|
}
|
|
} |