|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.Helper;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace BPASmartClient.JXJFoodBigStation.View
- {
- /// <summary>
- /// HardwareStatusView.xaml 的交互逻辑
- /// </summary>
- public partial class HardwareStatusView : UserControl
- {
- Storyboard storyboard;
- public HardwareStatusView()
- {
- InitializeComponent();
- storyboard = Resources["Open"] as Storyboard;
- ActionManage.GetInstance.CancelRegister("StartTopDevice");
- ActionManage.GetInstance.CancelRegister("StopTopDevice");
- ActionManage.GetInstance.CancelRegister("StartBottomDevice");
- ActionManage.GetInstance.CancelRegister("StopBottomDevice");
- ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
- foreach (var item in this.FListView.Items)
- {
- var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag.ToString() == deviceName.ToString()&& storyboard != null)
- {
- pt.Visibility = Visibility.Visible;
- pt.BeginStoryboard(storyboard);
- }
-
- }
- }
-
- }),"StartTopDevice" );
-
- ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
- foreach (var item in this.FListView.Items)
- {
- var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag.ToString() == deviceName.ToString())
-
- pt.Visibility = Visibility.Collapsed;
- }
- }
-
- }), "StopTopDevice");
-
- ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
- foreach (var item in this.buttonListView.Items)
- {
- var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path1", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag.ToString() == deviceName.ToString() && storyboard != null)
- {
- pt.Visibility = Visibility.Visible;
- pt.BeginStoryboard(storyboard);
- }
-
- }
- }
-
- }), "StartBottomDevice");
-
- ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
- foreach (var item in this.buttonListView.Items)
- {
- var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path1", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag.ToString() == deviceName.ToString())
-
- pt.Visibility = Visibility.Collapsed;
- }
- }
-
- }), "StopBottomDevice");
-
- }
- //顶部启动下料动画
- private void IcoButton_Click(object sender, RoutedEventArgs e)
- {
- foreach (var item in this.FListView.Items)
- {
- var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag == (sender as IcoButton).Tag&&storyboard!=null)
- {
- pt.Visibility = Visibility.Visible;
- pt.BeginStoryboard(storyboard);
- }
-
- }
- }
- }
-
- //顶部停止下料动画
- private void IcoButton_Click_1(object sender, RoutedEventArgs e)
- {
- foreach (var item in this.FListView.Items)
- {
- var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag == (sender as IcoButton).Tag)
-
- pt.Visibility = Visibility.Collapsed;
- }
- }
- }
-
- //底部启动下料动画
- private void IcoButton_Click_2(object sender, RoutedEventArgs e)
- {
- foreach (var item in this.buttonListView.Items)
- {
- var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path1", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag == (sender as IcoButton).Tag && storyboard != null)
- {
- pt.Visibility = Visibility.Visible;
- pt.BeginStoryboard(storyboard);
- }
-
- }
- }
- }
- //底部停止下料动画
- private void IcoButton_Click_3(object sender, RoutedEventArgs e)
- {
- foreach (var item in this.buttonListView.Items)
- {
- var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);
-
- // Getting the ContentPresenter of myListBoxItem
- var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);
-
- // Finding textBlock from the DataTemplate that is set on that ContentPresenter
- DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
-
- var obj = myDataTemplate.FindName("path1", myContentPresenter);
- Path pt = obj as Path;
- if (pt != null)
- {
- if (pt.Tag == (sender as IcoButton).Tag)
-
- pt.Visibility = Visibility.Collapsed;
- }
- }
- }
-
- private childItem FindVisualChild<childItem>(DependencyObject obj)
- where childItem : DependencyObject
- {
- for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
- {
- DependencyObject child = VisualTreeHelper.GetChild(obj, i);
- if (child != null && child is childItem)
- return (childItem)child;
- else
- {
- childItem childOfChild = FindVisualChild<childItem>(child);
- if (childOfChild != null)
- return childOfChild;
- }
- }
- return null;
- }
- }
- }
|