ValveStatusConverter.cs 994 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Data;
  7. namespace FurnaceUI.Converter
  8. {
  9. public class ValveStatusConverter : IValueConverter
  10. {
  11. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  12. {
  13. if (value == null)
  14. return string.Empty;
  15. string result = string.Empty;
  16. bool iValue;
  17. if (bool.TryParse(value.ToString(), out iValue))
  18. {
  19. if (iValue)
  20. result = "Open";
  21. else
  22. result = "Close";
  23. }
  24. return result;
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. }
  31. }