月更
This commit is contained in:
40
AntDesignWPF/Converters/ArithmeticConverter.cs
Normal file
40
AntDesignWPF/Converters/ArithmeticConverter.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
namespace AntDesign.WPF.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user