HouseInfoUserControlConvert.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. using ivf_tl_Entity.Entity.balance;
  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. using System.Windows.Media.Imaging;
  11. namespace ivf_tl_Manage.Converts
  12. {
  13. /// <summary>
  14. /// houseSN转换器 Foreground
  15. /// </summary>
  16. public class HouseSnForegroundConvert : IMultiValueConverter
  17. {
  18. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. string rsColor = null;
  21. var state = values[0].ToString();
  22. var temperatureAlarm = values[1].ToString();
  23. var pressureAlarm = values[2].ToString();
  24. if (state == "1")//在线
  25. {
  26. if (temperatureAlarm == "1" || pressureAlarm == "1")
  27. {
  28. rsColor = "#C85553";
  29. }
  30. else
  31. {
  32. rsColor = "#FFB000";
  33. }
  34. }
  35. else//非在线状态
  36. {
  37. rsColor = "#E39D00";
  38. }
  39. return new SolidColorBrush((Color)ColorConverter.ConvertFromString(rsColor));
  40. }
  41. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  42. {
  43. throw new NotImplementedException();
  44. }
  45. }
  46. /// <summary>
  47. /// 培养信息图片转换器
  48. /// </summary>
  49. public class HouseInfoImageConvert : IMultiValueConverter
  50. {
  51. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  52. {
  53. var sourceType = parameter.ToString();
  54. var state = values[0].ToString();
  55. var value1 = values[1];
  56. if (value1 != null && value1 is Dish dish && dish.id > 0)
  57. {
  58. if (state == "1")
  59. {
  60. switch (sourceType)
  61. {
  62. case "DishHeadshot":
  63. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishHeadshot.png", UriKind.Absolute));
  64. case "DishStartTime":
  65. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeIcon.png", UriKind.Absolute));
  66. case "DishStage":
  67. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageIcon.png", UriKind.Absolute));
  68. }
  69. }
  70. else
  71. {
  72. switch (sourceType)
  73. {
  74. case "DishHeadshot":
  75. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishState0Headshot.png", UriKind.Absolute));
  76. case "DishStartTime":
  77. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeState0Icon.png", UriKind.Absolute));
  78. case "DishStage":
  79. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageState0Icon.png", UriKind.Absolute));
  80. }
  81. }
  82. }
  83. else
  84. {
  85. if (state == "1")
  86. {
  87. switch (sourceType)
  88. {
  89. case "DishHeadshot":
  90. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataHeadshot.png", UriKind.Absolute));
  91. case "DishStartTime":
  92. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStartTimeIcon.png", UriKind.Absolute));
  93. case "DishStage":
  94. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStageIcon.png", UriKind.Absolute));
  95. }
  96. }
  97. else
  98. {
  99. switch (sourceType)
  100. {
  101. case "DishHeadshot":
  102. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0Headshot.png", UriKind.Absolute));
  103. case "DishStartTime":
  104. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StartTimeIcon.png", UriKind.Absolute));
  105. case "DishStage":
  106. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StageIcon.png", UriKind.Absolute));
  107. }
  108. }
  109. }
  110. return null;
  111. }
  112. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  113. {
  114. throw new NotImplementedException();
  115. }
  116. }
  117. public class HouseInfoImageConvert1 : IMultiValueConverter
  118. {
  119. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  120. {
  121. var sourceType = parameter.ToString();
  122. var state = values[0].ToString();
  123. var value1 = values[1];
  124. var value2 = values[2];
  125. if ((value1 != null && value1 is Dish dish && dish.id > 0) || (value2 != null && value2 is Balance balance && balance.id > 0))
  126. {
  127. if (state == "1")
  128. {
  129. switch (sourceType)
  130. {
  131. case "DishHeadshot":
  132. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishHeadshot.png", UriKind.Absolute));
  133. case "DishStartTime":
  134. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeIcon.png", UriKind.Absolute));
  135. case "DishStage":
  136. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageIcon.png", UriKind.Absolute));
  137. }
  138. }
  139. else
  140. {
  141. switch (sourceType)
  142. {
  143. case "DishHeadshot":
  144. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishState0Headshot.png", UriKind.Absolute));
  145. case "DishStartTime":
  146. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeState0Icon.png", UriKind.Absolute));
  147. case "DishStage":
  148. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageState0Icon.png", UriKind.Absolute));
  149. }
  150. }
  151. }
  152. else
  153. {
  154. if (state == "1")
  155. {
  156. switch (sourceType)
  157. {
  158. case "DishHeadshot":
  159. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataHeadshot.png", UriKind.Absolute));
  160. case "DishStartTime":
  161. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStartTimeIcon.png", UriKind.Absolute));
  162. case "DishStage":
  163. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStageIcon.png", UriKind.Absolute));
  164. }
  165. }
  166. else
  167. {
  168. switch (sourceType)
  169. {
  170. case "DishHeadshot":
  171. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0Headshot.png", UriKind.Absolute));
  172. case "DishStartTime":
  173. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StartTimeIcon.png", UriKind.Absolute));
  174. case "DishStage":
  175. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StageIcon.png", UriKind.Absolute));
  176. }
  177. }
  178. }
  179. return null;
  180. }
  181. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  182. {
  183. throw new NotImplementedException();
  184. }
  185. }
  186. /// <summary>
  187. /// 温度压力图片转换器
  188. /// </summary>
  189. public class HouseInfoAlarmImageConvert : IMultiValueConverter
  190. {
  191. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  192. {
  193. var sourceType = parameter.ToString();
  194. string rsSource = null;
  195. var state = values[0].ToString();
  196. var alarmSign = values[1].ToString();
  197. if (state == "1")//在线
  198. {
  199. if (alarmSign == "1")
  200. {
  201. switch (sourceType)
  202. {
  203. case "HouseTemperature":
  204. rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HouseTemperatureAlarmIcon.png";
  205. break;
  206. case "HousePressure":
  207. rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HousePressureAlarmIcon.png";
  208. break;
  209. }
  210. }
  211. else
  212. {
  213. switch (sourceType)
  214. {
  215. case "HouseTemperature":
  216. rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HouseTemperatureIcon.png";
  217. break;
  218. case "HousePressure":
  219. rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HousePressureIcon.png";
  220. break;
  221. }
  222. }
  223. }
  224. else//非在线状态
  225. {
  226. switch (sourceType)
  227. {
  228. case "HouseTemperature":
  229. rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HouseTemperatureState0Icon.png";
  230. break;
  231. case "HousePressure":
  232. rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HousePressureState0Icon.png";
  233. break;
  234. }
  235. }
  236. return new BitmapImage(new Uri(rsSource, UriKind.Absolute));
  237. }
  238. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  239. {
  240. throw new NotImplementedException();
  241. }
  242. }
  243. /// <summary>
  244. /// 培养信息转换器 Foreground
  245. /// </summary>
  246. public class DishInfoForegroundConver : IValueConverter
  247. {
  248. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  249. {
  250. var typePar = parameter.ToString();
  251. if (value.ToString() == "1")
  252. {
  253. switch (typePar)
  254. {
  255. case "button":
  256. return "#9B9B9B";
  257. case "text":
  258. return "#4D4D4D";
  259. case "housesn":
  260. return "#FFB000";
  261. case "funcSelected":
  262. return "#4D4D4D";
  263. }
  264. }
  265. else
  266. {
  267. switch (typePar)
  268. {
  269. case "button":
  270. return "#AAAAAA";
  271. case "text":
  272. return "#707070";
  273. case "housesn":
  274. return "#E39D00";
  275. case "funcSelected":
  276. return "#9B9B9B";
  277. }
  278. }
  279. return "#4D4D4D";
  280. }
  281. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  282. {
  283. throw new NotImplementedException();
  284. }
  285. }
  286. /// <summary>
  287. /// 培养信息展示转换器
  288. /// </summary>
  289. public class HouseInfoDishConvert : IValueConverter
  290. {
  291. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  292. {
  293. var typePar = parameter.ToString();
  294. if (value != null && (value is Dish dish) && dish.id > 0)
  295. {
  296. switch (typePar)
  297. {
  298. case "name":
  299. return $"{dish.wife}/{dish.husband}";
  300. }
  301. }
  302. else
  303. {
  304. switch (typePar)
  305. {
  306. case "name":
  307. return $"--/--";
  308. }
  309. }
  310. return null;
  311. }
  312. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  313. {
  314. throw new NotImplementedException();
  315. }
  316. }
  317. /// <summary>
  318. /// 培养信息字体颜色转换器
  319. /// </summary>
  320. public class HouseInfoForegroundConver : IMultiValueConverter
  321. {
  322. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  323. {
  324. //var sourceType = parameter.ToString();
  325. string rsColor = null;
  326. var state = values[0].ToString();
  327. var value1 = values[1];
  328. if (state != null && value1 is Dish dish && dish.id > 0)
  329. {
  330. if (state == "1")
  331. {
  332. rsColor = "#4D4D4D";
  333. }
  334. else
  335. {
  336. rsColor = "#707070";
  337. }
  338. }
  339. else
  340. {
  341. rsColor = "#ABABAB";
  342. }
  343. return new SolidColorBrush((Color)ColorConverter.ConvertFromString(rsColor));
  344. }
  345. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  346. {
  347. throw new NotImplementedException();
  348. }
  349. }
  350. public class HouseInfoForegroundConver1 : IMultiValueConverter
  351. {
  352. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  353. {
  354. //var sourceType = parameter.ToString();
  355. string rsColor = null;
  356. var state = values[0].ToString();
  357. var value1 = values[1];
  358. var value2 = values[2];
  359. if ((value1 != null && value1 is Dish dish && dish.id > 0) || (value2 != null && value2 is Balance balance && balance.id > 0))
  360. {
  361. if (state == "1")
  362. {
  363. rsColor = "#4D4D4D";
  364. }
  365. else
  366. {
  367. rsColor = "#707070";
  368. }
  369. }
  370. else
  371. {
  372. rsColor = "#ABABAB";
  373. }
  374. return new SolidColorBrush((Color)ColorConverter.ConvertFromString(rsColor));
  375. }
  376. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  377. {
  378. throw new NotImplementedException();
  379. }
  380. }
  381. }