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