MFCErrorConverters.cs 911 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Windows.Data;
  3. using Venus_Core;
  4. namespace Venus_MainPages.Converters
  5. {
  6. public class MFCErrorConverters : IMultiValueConverter
  7. {
  8. public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  9. {
  10. if (values == null) return string.Empty;
  11. float setPoint = (float)(values[0]);
  12. float calculate = (float)(values[1]);
  13. if (calculate == 0)
  14. {
  15. return "0";
  16. }
  17. float deviation = (Math.Abs(calculate) - Math.Abs(setPoint)) / Math.Abs(setPoint) * 100;
  18. return deviation.ToString();
  19. }
  20. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
  21. {
  22. throw new NotImplementedException();
  23. }
  24. }
  25. }