终端一体化运控平台
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.

HardwareStatusView.xaml.cs 10 KiB

пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using BPASmartClient.CustomResource.UserControls;
  2. using BPASmartClient.Helper;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Animation;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace BPASmartClient.JXJFoodBigStation.View
  19. {
  20. /// <summary>
  21. /// HardwareStatusView.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class HardwareStatusView : UserControl
  24. {
  25. Storyboard storyboard;
  26. public HardwareStatusView()
  27. {
  28. InitializeComponent();
  29. storyboard = Resources["Open"] as Storyboard;
  30. ActionManage.GetInstance.CancelRegister("StartTopDevice");
  31. ActionManage.GetInstance.CancelRegister("StopTopDevice");
  32. ActionManage.GetInstance.CancelRegister("StartBottomDevice");
  33. ActionManage.GetInstance.CancelRegister("StopBottomDevice");
  34. ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
  35. foreach (var item in this.FListView.Items)
  36. {
  37. var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
  38. // Getting the ContentPresenter of myListBoxItem
  39. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  40. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  41. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  42. var obj = myDataTemplate.FindName("path", myContentPresenter);
  43. Path pt = obj as Path;
  44. if (pt != null)
  45. {
  46. if (pt.Tag.ToString() == deviceName.ToString()&& storyboard != null)
  47. {
  48. pt.Visibility = Visibility.Visible;
  49. pt.BeginStoryboard(storyboard);
  50. }
  51. }
  52. }
  53. }),"StartTopDevice" );
  54. ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
  55. foreach (var item in this.FListView.Items)
  56. {
  57. var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
  58. // Getting the ContentPresenter of myListBoxItem
  59. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  60. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  61. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  62. var obj = myDataTemplate.FindName("path", myContentPresenter);
  63. Path pt = obj as Path;
  64. if (pt != null)
  65. {
  66. if (pt.Tag.ToString() == deviceName.ToString())
  67. pt.Visibility = Visibility.Collapsed;
  68. }
  69. }
  70. }), "StopTopDevice");
  71. ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
  72. foreach (var item in this.buttonListView.Items)
  73. {
  74. var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
  75. // Getting the ContentPresenter of myListBoxItem
  76. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  77. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  78. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  79. var obj = myDataTemplate.FindName("path1", myContentPresenter);
  80. Path pt = obj as Path;
  81. if (pt != null)
  82. {
  83. if (pt.Tag.ToString() == deviceName.ToString() && storyboard != null)
  84. {
  85. pt.Visibility = Visibility.Visible;
  86. pt.BeginStoryboard(storyboard);
  87. }
  88. }
  89. }
  90. }), "StartBottomDevice");
  91. ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
  92. foreach (var item in this.buttonListView.Items)
  93. {
  94. var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
  95. // Getting the ContentPresenter of myListBoxItem
  96. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  97. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  98. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  99. var obj = myDataTemplate.FindName("path1", myContentPresenter);
  100. Path pt = obj as Path;
  101. if (pt != null)
  102. {
  103. if (pt.Tag.ToString() == deviceName.ToString())
  104. pt.Visibility = Visibility.Collapsed;
  105. }
  106. }
  107. }), "StopBottomDevice");
  108. }
  109. //顶部启动下料动画
  110. private void IcoButton_Click(object sender, RoutedEventArgs e)
  111. {
  112. foreach (var item in this.FListView.Items)
  113. {
  114. var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
  115. // Getting the ContentPresenter of myListBoxItem
  116. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  117. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  118. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  119. var obj = myDataTemplate.FindName("path", myContentPresenter);
  120. Path pt = obj as Path;
  121. if (pt != null)
  122. {
  123. if (pt.Tag == (sender as IcoButton).Tag&&storyboard!=null)
  124. {
  125. pt.Visibility = Visibility.Visible;
  126. pt.BeginStoryboard(storyboard);
  127. }
  128. }
  129. }
  130. }
  131. //顶部停止下料动画
  132. private void IcoButton_Click_1(object sender, RoutedEventArgs e)
  133. {
  134. foreach (var item in this.FListView.Items)
  135. {
  136. var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
  137. // Getting the ContentPresenter of myListBoxItem
  138. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  139. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  140. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  141. var obj = myDataTemplate.FindName("path", myContentPresenter);
  142. Path pt = obj as Path;
  143. if (pt != null)
  144. {
  145. if (pt.Tag == (sender as IcoButton).Tag)
  146. pt.Visibility = Visibility.Collapsed;
  147. }
  148. }
  149. }
  150. //底部启动下料动画
  151. private void IcoButton_Click_2(object sender, RoutedEventArgs e)
  152. {
  153. foreach (var item in this.buttonListView.Items)
  154. {
  155. var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
  156. // Getting the ContentPresenter of myListBoxItem
  157. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  158. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  159. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  160. var obj = myDataTemplate.FindName("path1", myContentPresenter);
  161. Path pt = obj as Path;
  162. if (pt != null)
  163. {
  164. if (pt.Tag == (sender as IcoButton).Tag && storyboard != null)
  165. {
  166. pt.Visibility = Visibility.Visible;
  167. pt.BeginStoryboard(storyboard);
  168. }
  169. }
  170. }
  171. }
  172. //底部停止下料动画
  173. private void IcoButton_Click_3(object sender, RoutedEventArgs e)
  174. {
  175. foreach (var item in this.buttonListView.Items)
  176. {
  177. var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
  178. // Getting the ContentPresenter of myListBoxItem
  179. var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
  180. // Finding textBlock from the DataTemplate that is set on that ContentPresenter
  181. DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
  182. var obj = myDataTemplate.FindName("path1", myContentPresenter);
  183. Path pt = obj as Path;
  184. if (pt != null)
  185. {
  186. if (pt.Tag == (sender as IcoButton).Tag)
  187. pt.Visibility = Visibility.Collapsed;
  188. }
  189. }
  190. }
  191. private childItem FindVisualChild<childItem>(DependencyObject obj)
  192. where childItem : DependencyObject
  193. {
  194. for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
  195. {
  196. DependencyObject child = VisualTreeHelper.GetChild(obj, i);
  197. if (child != null && child is childItem)
  198. return (childItem)child;
  199. else
  200. {
  201. childItem childOfChild = FindVisualChild<childItem>(child);
  202. if (childOfChild != null)
  203. return childOfChild;
  204. }
  205. }
  206. return null;
  207. }
  208. }
  209. }