DeviceInfoUserControl.xaml.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using ivf_tl_Entity.Entity.balance;
  2. using ivf_tl_Manage.ViewModels;
  3. using ivf_tl_Manage.Win;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Effects;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace ivf_tl_Manage.UserControls
  20. {
  21. /// <summary>
  22. /// DeviceInfoUserControl.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class DeviceInfoUserControl : UserControl
  25. {
  26. public event Action<long> EditClickEvent;
  27. public event Action<TLInfo> TlClickEvent;
  28. public event Action<TLInfo, House> HouseClickEvent;
  29. public event Action<string, string> HouseSettingClickEvent;
  30. public event Action<string, long> DelTLEvent;
  31. public event Action<TLInfo> HiddenTLEvent;
  32. public DeviceInfoUserControl()
  33. {
  34. InitializeComponent();
  35. }
  36. private void Del_Click(object sender, RoutedEventArgs e)
  37. {
  38. if (!this.IsLoaded) return;
  39. if (TlInfoSurce != null && TlInfoSurce.id > 0)
  40. {
  41. DelTLEvent?.Invoke(TlInfoSurce.tlName, TlInfoSurce.id);
  42. }
  43. e.Handled = true;
  44. }
  45. private void Edit_Click(object sender, RoutedEventArgs e)
  46. {
  47. if (!this.IsLoaded) return;
  48. if (TlInfoSurce != null && TlInfoSurce.id > 0)
  49. {
  50. EditClickEvent?.Invoke(TlInfoSurce.id);
  51. }
  52. e.Handled = true;
  53. }
  54. private void TLStateInfoUserControl_MouseDown(object sender, MouseButtonEventArgs e)
  55. {
  56. if (!this.IsLoaded) return;
  57. if (TlInfoSurce != null && TlInfoSurce.id > 0)
  58. {
  59. TlClickEvent?.Invoke(TlInfoSurce);
  60. }
  61. e.Handled = true;
  62. }
  63. private void HouseInfoUserControl_MouseDown(object sender, MouseButtonEventArgs e)
  64. {
  65. if (!(sender is HouseInfoUserControl source)) return;
  66. HouseClickEvent?.Invoke(TlInfoSurce, source.HouseSource);
  67. e.Handled = true;
  68. }
  69. private void HouseSetting_Click(object sender, RoutedEventArgs e)
  70. {
  71. if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "setting");
  72. e.Handled = true;
  73. }
  74. private void DishRecord_Click(object sender, RoutedEventArgs e)
  75. {
  76. if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "DishRecord");
  77. e.Handled = true;
  78. }
  79. private void TLAlarm_Click(object sender, RoutedEventArgs e)
  80. {
  81. if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "TLAlarm");
  82. e.Handled = true;
  83. }
  84. private void HouesChart_Click(object sender, RoutedEventArgs e)
  85. {
  86. if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "HouesChart");
  87. e.Handled = true;
  88. }
  89. /// <summary>
  90. /// 0离线 1在线 2解绑 3待初始化
  91. /// </summary>
  92. public TLInfo TlInfoSurce
  93. {
  94. get { return (TLInfo)GetValue(TlInfoSurceProperty); }
  95. set { SetValue(TlInfoSurceProperty, value); }
  96. }
  97. // Using a DependencyProperty as the backing store for TlInfoSurce. This enables animation, styling, binding, etc...
  98. public static readonly DependencyProperty TlInfoSurceProperty =
  99. DependencyProperty.Register("TlInfoSurce", typeof(TLInfo), typeof(DeviceInfoUserControl), new PropertyMetadata(null, new PropertyChangedCallback(TlInfoSurcePropertyChangedCallback)));
  100. private static void TlInfoSurcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  101. {
  102. if (!(d is DeviceInfoUserControl source)) return;
  103. if (e.NewValue != null && e.NewValue is TLInfo newTlInfo)
  104. {
  105. source.House1 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 1);
  106. source.House2 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 2);
  107. source.House3 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 3);
  108. source.House4 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 4);
  109. source.House5 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 5);
  110. source.House6 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 6);
  111. source.House7 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 7);
  112. source.House8 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 8);
  113. source.House9 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 9);
  114. source.House10 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 10);
  115. source.House11 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 11);
  116. }
  117. }
  118. public House House1
  119. {
  120. get { return (House)GetValue(House1Property); }
  121. set { SetValue(House1Property, value); }
  122. }
  123. // Using a DependencyProperty as the backing store for House1. This enables animation, styling, binding, etc...
  124. public static readonly DependencyProperty House1Property =
  125. DependencyProperty.Register("House1", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  126. public House House2
  127. {
  128. get { return (House)GetValue(House2Property); }
  129. set { SetValue(House2Property, value); }
  130. }
  131. // Using a DependencyProperty as the backing store for House2. This enables animation, styling, binding, etc...
  132. public static readonly DependencyProperty House2Property =
  133. DependencyProperty.Register("House2", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  134. public House House3
  135. {
  136. get { return (House)GetValue(House3Property); }
  137. set { SetValue(House3Property, value); }
  138. }
  139. // Using a DependencyProperty as the backing store for House3. This enables animation, styling, binding, etc...
  140. public static readonly DependencyProperty House3Property =
  141. DependencyProperty.Register("House3", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  142. public House House4
  143. {
  144. get { return (House)GetValue(House4Property); }
  145. set { SetValue(House4Property, value); }
  146. }
  147. // Using a DependencyProperty as the backing store for House4. This enables animation, styling, binding, etc...
  148. public static readonly DependencyProperty House4Property =
  149. DependencyProperty.Register("House4", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  150. public House House5
  151. {
  152. get { return (House)GetValue(House5Property); }
  153. set { SetValue(House5Property, value); }
  154. }
  155. // Using a DependencyProperty as the backing store for House5. This enables animation, styling, binding, etc...
  156. public static readonly DependencyProperty House5Property =
  157. DependencyProperty.Register("House5", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  158. public House House6
  159. {
  160. get { return (House)GetValue(House6Property); }
  161. set { SetValue(House6Property, value); }
  162. }
  163. // Using a DependencyProperty as the backing store for House6. This enables animation, styling, binding, etc...
  164. public static readonly DependencyProperty House6Property =
  165. DependencyProperty.Register("House6", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  166. public House House7
  167. {
  168. get { return (House)GetValue(House7Property); }
  169. set { SetValue(House7Property, value); }
  170. }
  171. // Using a DependencyProperty as the backing store for House7. This enables animation, styling, binding, etc...
  172. public static readonly DependencyProperty House7Property =
  173. DependencyProperty.Register("House7", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  174. public House House8
  175. {
  176. get { return (House)GetValue(House8Property); }
  177. set { SetValue(House8Property, value); }
  178. }
  179. // Using a DependencyProperty as the backing store for House8. This enables animation, styling, binding, etc...
  180. public static readonly DependencyProperty House8Property =
  181. DependencyProperty.Register("House8", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  182. public House House9
  183. {
  184. get { return (House)GetValue(House9Property); }
  185. set { SetValue(House9Property, value); }
  186. }
  187. // Using a DependencyProperty as the backing store for House9. This enables animation, styling, binding, etc...
  188. public static readonly DependencyProperty House9Property =
  189. DependencyProperty.Register("House9", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  190. public House House10
  191. {
  192. get { return (House)GetValue(House10Property); }
  193. set { SetValue(House10Property, value); }
  194. }
  195. // Using a DependencyProperty as the backing store for House10. This enables animation, styling, binding, etc...
  196. public static readonly DependencyProperty House10Property =
  197. DependencyProperty.Register("House10", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  198. public House House11
  199. {
  200. get { return (House)GetValue(House11Property); }
  201. set { SetValue(House11Property, value); }
  202. }
  203. // Using a DependencyProperty as the backing store for House11. This enables animation, styling, binding, etc...
  204. public static readonly DependencyProperty House11Property =
  205. DependencyProperty.Register("House11", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
  206. private void Hidden_Click(object sender, RoutedEventArgs e)
  207. {
  208. if (!this.IsLoaded) return;
  209. if (TlInfoSurce != null && TlInfoSurce.id > 0)
  210. {
  211. HiddenTLEvent?.Invoke(TlInfoSurce);
  212. }
  213. e.Handled = true;
  214. }
  215. public void SetisEn(int hou)
  216. {
  217. bool isen = false;
  218. switch (hou)
  219. {
  220. case 1:
  221. this.houseInfo1.IsEnabled = isen;
  222. break;
  223. case 2:
  224. this.houseInfo2.IsEnabled = isen;
  225. break;
  226. case 3:
  227. this.houseInfo3.IsEnabled = isen;
  228. break;
  229. case 4:
  230. this.houseInfo4.IsEnabled = isen;
  231. break;
  232. case 5:
  233. this.houseInfo5.IsEnabled = isen;
  234. break;
  235. case 6:
  236. this.houseInfo6.IsEnabled = isen;
  237. break;
  238. case 7:
  239. this.houseInfo7.IsEnabled = isen;
  240. break;
  241. case 8:
  242. this.houseInfo8.IsEnabled = isen;
  243. break;
  244. case 9:
  245. this.houseInfo9.IsEnabled = isen;
  246. break;
  247. case 10:
  248. this.houseInfo10.IsEnabled = isen;
  249. break;
  250. }
  251. }
  252. }
  253. }