Files
ShrlAlgoToolkit/AntdWpf/Converters/ArithmeticConverter.cs
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

41 lines
1.1 KiB
C#

namespace AntdWpf.Converters
{
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
public abstract class ArithmeticConverter : MarkupExtension, IValueConverter
{
public abstract double Convert(double value, Type targetType, double parameter, CultureInfo culture);
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
var val = (double)value;
if (double.IsNaN(val))
{
return value;
}
return Convert(val, targetType, double.Parse(parameter as string), culture);
} catch { }
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}