DishInfoUserControlConvert.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. using ivf_tl_Entity.Entity.balance;
  2. using ivf_tl_Entity.Enums;
  3. using System;
  4. using System.Collections.Generic;
  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. using System.Windows.Media.Imaging;
  13. namespace ivf_tl_Manage.Converts
  14. {
  15. public class DishInfoUserOnlyVipConvert : IValueConverter
  16. {
  17. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  18. {
  19. try
  20. {
  21. var type = parameter.ToString();
  22. if (value != null && value.ToString() == "1")
  23. {
  24. switch (type)
  25. {
  26. case "border":
  27. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#804D75AC"));
  28. case "rectangle1":
  29. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E2EBF9"));
  30. case "rectangle2":
  31. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7092C4"));
  32. case "editButton":
  33. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EditVipIcon.png", UriKind.Absolute));
  34. }
  35. }
  36. switch (type)
  37. {
  38. case "border":
  39. return new SolidColorBrush(Colors.Transparent);
  40. case "rectangle1":
  41. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#C1C1C1"));
  42. case "rectangle2":
  43. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CFCFCF"));
  44. case "editButton":
  45. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EditIcon.png", UriKind.Absolute));
  46. }
  47. return null;
  48. }
  49. catch (Exception)
  50. {
  51. return null;
  52. }
  53. }
  54. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  55. {
  56. throw new NotImplementedException();
  57. }
  58. }
  59. public class DishInfoDataAndVipConvert : IValueConverter
  60. {
  61. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  62. {
  63. try
  64. {
  65. var type = parameter.ToString();
  66. if (value is Dish dish && dish.id > 0)
  67. {
  68. switch (type)
  69. {
  70. case "DishHeadshot":
  71. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishHeadshot.png", UriKind.Absolute));
  72. case "DishName":
  73. if (dish.vip == 1) return new SolidColorBrush(Colors.White);
  74. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
  75. case "EditButton":
  76. return Visibility.Visible;
  77. case "AddButton":
  78. return Visibility.Hidden;
  79. case "DishInfo":
  80. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
  81. case "StartTime":
  82. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeIcon.png", UriKind.Absolute));
  83. case "FaYuTime":
  84. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageIcon.png", UriKind.Absolute));
  85. }
  86. }
  87. switch (type)
  88. {
  89. case "DishHeadshot":
  90. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataHeadshot.png", UriKind.Absolute));
  91. case "DishName":
  92. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ABABAB"));
  93. case "EditButton":
  94. return Visibility.Hidden;
  95. case "AddButton":
  96. return Visibility.Visible;
  97. case "DishInfo":
  98. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ABABAB"));
  99. case "StartTime":
  100. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStartTimeIcon.png", UriKind.Absolute));
  101. case "FaYuTime":
  102. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStageIcon.png", UriKind.Absolute));
  103. }
  104. return null;
  105. }
  106. catch (Exception)
  107. {
  108. return null;
  109. }
  110. }
  111. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  112. {
  113. throw new NotImplementedException();
  114. }
  115. }
  116. public class DishInfoDataAndVipConvert1 : IMultiValueConverter
  117. {
  118. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  119. {
  120. var type = parameter.ToString();
  121. var value1 = values[0];
  122. var value2 = values[1];
  123. if ((value1 != null && value1 is Dish dish && dish.id > 0) || (value2 != null && value2 is Balance balance && balance.id > 0))
  124. {
  125. switch (type)
  126. {
  127. case "DishHeadshot":
  128. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishHeadshot.png", UriKind.Absolute));
  129. case "EditButton":
  130. return Visibility.Visible;
  131. case "AddButton":
  132. return Visibility.Hidden;
  133. case "DishInfo":
  134. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
  135. case "StartTime":
  136. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeIcon.png", UriKind.Absolute));
  137. case "FaYuTime":
  138. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageIcon.png", UriKind.Absolute));
  139. }
  140. }
  141. switch (type)
  142. {
  143. case "DishHeadshot":
  144. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataHeadshot.png", UriKind.Absolute));
  145. case "DishName":
  146. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ABABAB"));
  147. case "EditButton":
  148. return Visibility.Hidden;
  149. case "AddButton":
  150. return Visibility.Visible;
  151. case "DishInfo":
  152. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ABABAB"));
  153. case "StartTime":
  154. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStartTimeIcon.png", UriKind.Absolute));
  155. case "FaYuTime":
  156. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStageIcon.png", UriKind.Absolute));
  157. }
  158. return null;
  159. }
  160. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  161. {
  162. throw new NotImplementedException();
  163. }
  164. }
  165. public class DishInfoOnlyHouseConvert : IValueConverter
  166. {
  167. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  168. {
  169. try
  170. {
  171. var type = parameter.ToString();
  172. if (value is House house && house.id > 0 && ((house.embryoRecordVO != null && house.embryoRecordVO.id > 0) || (house.balanceVO != null && house.balanceVO.id > 0)))
  173. {
  174. switch (type)
  175. {
  176. case "Background":
  177. if (house.pressureAlarm == 1 || house.temperatureAlarm == 1) return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishInfoYuanAlarmBackgroundIcon.png", UriKind.Absolute));
  178. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishInfoYuanBackgroundIcon.png", UriKind.Absolute));
  179. case "CanvasBackground":
  180. if (house.pressureAlarm == 1 || house.temperatureAlarm == 1)
  181. {
  182. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishInfoAlarmBackgroundIcon.png", UriKind.Absolute));
  183. }
  184. else
  185. {
  186. if(house.houseState == (int)HouseStateEnum.AirSwapWorking)
  187. {
  188. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishInfoAirBackgroundIcon.png", UriKind.Absolute));
  189. }
  190. else
  191. {
  192. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishInfoBackgroundIcon.png", UriKind.Absolute));
  193. }
  194. }
  195. case "HouseForeground":
  196. if (house.pressureAlarm == 1 || house.temperatureAlarm == 1) return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#C85553"));
  197. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
  198. }
  199. }
  200. switch (type)
  201. {
  202. case "Background":
  203. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishInfoYuanNoDataBackgroundIcon.png", UriKind.Absolute));
  204. case "CanvasBackground":
  205. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishInfoBackgroundIcon.png", UriKind.Absolute));
  206. case "HouseForeground":
  207. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
  208. }
  209. return null;
  210. }
  211. catch (Exception)
  212. {
  213. return null;
  214. }
  215. }
  216. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  217. {
  218. throw new NotImplementedException();
  219. }
  220. }
  221. }