首次上传
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace MECF.Framework.UI.Client.Ctrlib.Converter
|
||||
{
|
||||
public class Bit2Bool : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (!(value is int))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int tempValue = (int)value;
|
||||
return tempValue == 1;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (!(value is bool))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tempValue = (bool)value;
|
||||
return tempValue == true ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public class Null2Bool : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return value == null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class String2Double : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return 0.0;
|
||||
|
||||
double tempValue = 0.0;
|
||||
double.TryParse(value.ToString(), out tempValue);
|
||||
|
||||
return tempValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class Float2String : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return string.Empty;
|
||||
|
||||
if (double.IsNaN((double)value))
|
||||
return string.Empty;
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user