HouseDoorStateConvert.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using ivf_tl_Entity.GlobalEntitys;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Globalization;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Data;
  11. using System.Windows.Media;
  12. namespace ivf_tl_Operate.Converts
  13. {
  14. public class HouseDoorStateConvert : IValueConverter
  15. {
  16. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  17. {
  18. if (value == null) return Visibility.Hidden;
  19. if (parameter == null) return Visibility.Hidden;
  20. if (!int.TryParse(parameter.ToString(), out int type))
  21. {
  22. return Visibility.Hidden;
  23. }
  24. if (int.TryParse(value.ToString(), out int result))
  25. {
  26. if(type == 1)
  27. {
  28. if(result == 1)
  29. {
  30. return Visibility.Visible;
  31. }
  32. else
  33. {
  34. return Visibility.Hidden;
  35. }
  36. }
  37. else
  38. {
  39. if (result == 1)
  40. {
  41. return Visibility.Hidden;
  42. }
  43. else
  44. {
  45. return Visibility.Visible;
  46. }
  47. }
  48. }
  49. else
  50. {
  51. return Visibility.Hidden;
  52. }
  53. }
  54. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  55. {
  56. throw new NotImplementedException();
  57. }
  58. }
  59. public class HouseInfoBackgroundConvert : IValueConverter
  60. {
  61. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  62. {
  63. if(value == null)
  64. {
  65. return "Transparent";
  66. }
  67. if(value is ExDish exDish)
  68. {
  69. if(exDish.vip == 1)
  70. {
  71. return "#fcf1f2";
  72. }
  73. else
  74. {
  75. return "Transparent";
  76. }
  77. }
  78. else
  79. {
  80. return "Transparent";
  81. }
  82. }
  83. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  84. {
  85. throw new NotImplementedException();
  86. }
  87. }
  88. public class HouseInfoBackgroundConvert1 : IMultiValueConverter
  89. {
  90. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  91. {
  92. try
  93. {
  94. int alarm = 0;
  95. SolidColorBrush rs = new SolidColorBrush((Colors.Transparent));
  96. if (values[0] != null && values[0] is ExDish dish)
  97. {
  98. if (dish.vip == 1)
  99. {
  100. rs = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#804D75AC"));
  101. }
  102. }
  103. if (values[1] != null && int.TryParse(values[1].ToString(), out alarm))
  104. {
  105. if (alarm == 1)
  106. {
  107. rs = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#e99c9c"));
  108. }
  109. }
  110. if (values[2] != null && int.TryParse(values[2].ToString(), out alarm))
  111. {
  112. if (alarm == 1)
  113. {
  114. rs = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#e99c9c"));
  115. }
  116. }
  117. return rs;
  118. }
  119. catch (Exception ex)
  120. {
  121. return new SolidColorBrush((Colors.Transparent));
  122. }
  123. }
  124. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  125. {
  126. throw new NotImplementedException();
  127. }
  128. }
  129. }