终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

121 lines
3.4 KiB

  1. using BPASmartClient.CustomResource.UserControls.Enum;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Data;
  9. using System.Windows.Media;
  10. namespace BPASmartClient.Academy.Converter
  11. {
  12. public class DeviceCtrlConvert : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. if (parameter.ToString() == "1")//流向正向
  17. {
  18. if (value is bool)
  19. {
  20. bool value_get = (bool)value;
  21. if (value_get)
  22. {
  23. return 1;
  24. }
  25. else
  26. {
  27. return 0;
  28. }
  29. }
  30. else
  31. {
  32. return 0;
  33. }
  34. }
  35. else if (parameter.ToString() == "2")//管道颜色
  36. {
  37. if (value is bool)
  38. {
  39. bool value_get = (bool)value;
  40. if (value_get)
  41. {
  42. return Color.FromRgb(227,26,26);
  43. }
  44. else
  45. {
  46. return Color.FromRgb(255,255,255);
  47. }
  48. }
  49. else
  50. {
  51. return Color.FromRgb(255, 255, 255);
  52. }
  53. }
  54. else if(parameter.ToString() == "3")//电机颜色
  55. {
  56. if (value is bool)
  57. {
  58. bool value_get = (bool)value;
  59. if (value_get)
  60. {
  61. return MotorColor.Green;
  62. }
  63. else
  64. {
  65. return MotorColor.Gray;
  66. }
  67. }
  68. else
  69. {
  70. return MotorColor.Gray;
  71. }
  72. }
  73. else if(parameter.ToString()=="4")//字体颜色
  74. {
  75. if (value is bool)
  76. {
  77. bool value_get = (bool)value;
  78. if (value_get)
  79. {
  80. return new SolidColorBrush(Color.FromRgb(227, 26, 26));
  81. }
  82. else
  83. {
  84. return new SolidColorBrush(Color.FromRgb(255, 255, 255));
  85. }
  86. }
  87. else
  88. {
  89. return new SolidColorBrush(Color.FromRgb(255, 255, 255));
  90. }
  91. }
  92. else//流向反向
  93. {
  94. if (value is bool)
  95. {
  96. bool value_get = (bool)value;
  97. if (value_get)
  98. {
  99. return 2;
  100. }
  101. else
  102. {
  103. return 0;
  104. }
  105. }
  106. else
  107. {
  108. return 0;
  109. }
  110. }
  111. }
  112. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  113. {
  114. throw new NotImplementedException();
  115. }
  116. }
  117. }