namespace OINA.Extender.WPF.Testharness
{
using System;
using System.Globalization;
using System.Windows.Data;
///
/// DataConvert class
///
public class DataConverter : IValueConverter
{
///
/// add unit to deadtime
///
/// source value
/// target type
/// parameter
/// culture info
/// converted value
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
switch (parameter as string)
{
case "outputRateUnit":
int outputRate = (int)value;
return outputRate.ToString(CultureInfo.InvariantCulture) + @"cps";
case "deadTimeUnit":
double deadTime = (double)value;
return deadTime.ToString(CultureInfo.InvariantCulture) + @"%";
default:
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, @"Invalid argument {0}", parameter));
}
}
///
/// remove unit from OutputRate
///
/// source value
/// target type
/// parameter
/// culture info
/// converted value
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}