终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

254 linhas
10 KiB

  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. }