using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; namespace FLY.Thick.Base.UI.Converter { public class Multi2Converter : IMultiValueConverter { #region IMultiValueConverter 成员 public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values.Length != 2) return 0; if ((!(values[0] is int)) && (!(values[0] is double))) return 0; if ((!(values[1] is int)) && (!(values[1] is double))) return 0; double v0, v1; if (values[0] is int) { int p = (int)values[0]; if (p == 99999998) p = 0; v0 = p; } else v0 = (double)values[0]; if (values[1] is int) { int p = (int)values[1]; if (p == 99999998) p = 0; v1 = p; } else v1 = (double)values[1]; return v1 * v0; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return null; } #endregion } public class Add2Converter : IMultiValueConverter { #region IMultiValueConverter 成员 public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values.Length != 2) return 0; if ((!(values[0] is int)) && (!(values[0] is double))) return 0; if ((!(values[1] is int)) && (!(values[1] is double))) return 0; double v0, v1; if (values[0] is int) { int p = (int)values[0]; if (p == 99999998) p = 0; v0 = p; } else v0 = (double)values[0]; if (values[1] is int) { int p = (int)values[1]; if (p == 99999998) p = 0; v1 = p; } else v1 = (double)values[1]; return v1 + v0; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return null; } #endregion } }