using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; namespace Cowain.Bake.Common.Converter { public class ScaleConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (parameter == null) throw new ArgumentNullException("value can not be null"); if (value == null) throw new ArgumentNullException("value can not be null"); double c = System.Convert.ToDouble(parameter); double index = System.Convert.ToDouble(value); return index / c; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (parameter == null) throw new ArgumentNullException("value can not be null"); if (value == null) throw new ArgumentNullException("value can not be null"); double c = System.Convert.ToDouble(parameter); double index = System.Convert.ToDouble(value); return System.Convert.ToInt32(index * c); } } }