ModuleTypeToVisibilityConverter.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using SWRIS.Enums;
  2. using System;
  3. using System.Globalization;
  4. using System.Windows;
  5. using System.Windows.Data;
  6. namespace SWRIS.Converters
  7. {
  8. public class ModuleTypeToVisibilityConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  11. {
  12. if (value != null && (ModuleType)value is ModuleType moduleType)
  13. {
  14. parameter = parameter ?? "Tcp";
  15. if (moduleType == ModuleType.ModbusRtu)
  16. {
  17. return parameter.ToString() == "Serial" ? Visibility.Visible : Visibility.Collapsed;
  18. }
  19. else
  20. {
  21. return parameter.ToString() == "Tcp" ? Visibility.Visible : Visibility.Collapsed;
  22. }
  23. }
  24. return Visibility.Collapsed;
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. }
  31. }