VenusRecipeSequenceSelectView.xaml.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using Aitex.Core.Util;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using Venus_MainPages.Sequence;
  17. using Venus_Unity;
  18. namespace Venus_MainPages.Views
  19. {
  20. /// <summary>
  21. /// VenusRecipeSequenceSelectView.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class VenusRecipeSequenceSelectView : Window
  24. {
  25. private FileNode pre_currentFileNode;
  26. private FileNode process_currentFileNode;
  27. private FileNode wtw_currentFileNode;
  28. private FileNode post_currentFileNode;
  29. SerializableDictionary<string, string> recipeDictionary = new SerializableDictionary<string, string>();
  30. public string FullPath { get; private set; }
  31. string value;
  32. public VenusRecipeSequenceSelectView(string path)
  33. {
  34. InitializeComponent();
  35. value = path;
  36. }
  37. private void buttonCancel_Click(object sender, RoutedEventArgs e)
  38. {
  39. this.DialogResult = false;
  40. }
  41. private void buttonOK_Click(object sender, RoutedEventArgs e)
  42. {
  43. this.DialogResult = true;
  44. if (pre_currentFileNode != null && pre_currentFileNode.Parent.Name == "Clean")
  45. {
  46. recipeDictionary.Add("PreLotClean", pre_currentFileNode.Name);
  47. }
  48. else
  49. {
  50. recipeDictionary.Add("PreLotClean", "");
  51. }
  52. if (process_currentFileNode != null && process_currentFileNode.Parent.Name == "Process")
  53. {
  54. recipeDictionary.Add("Process", process_currentFileNode.Name);
  55. }
  56. else
  57. {
  58. recipeDictionary.Add("Process", "");
  59. }
  60. if (wtw_currentFileNode != null && wtw_currentFileNode.Parent.Name == "Clean")
  61. {
  62. recipeDictionary.Add("WTWClean", wtw_currentFileNode.Name);
  63. }
  64. else
  65. {
  66. recipeDictionary.Add("WTWClean", "");
  67. }
  68. if (post_currentFileNode != null && post_currentFileNode.Parent.Name == "Clean")
  69. {
  70. recipeDictionary.Add("PostLotClean", post_currentFileNode.Name);
  71. }
  72. else
  73. {
  74. recipeDictionary.Add("PostLotClean", "");
  75. }
  76. this.FullPath = SerializeHelper.Instance.DictionaryToString(recipeDictionary);
  77. }
  78. private void PreClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  79. {
  80. pre_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  81. if (pre_currentFileNode.Parent.Name == "Clean")
  82. {
  83. preLotSelectedRecipeTextBlock.Text = pre_currentFileNode.Name;
  84. }
  85. else
  86. {
  87. preLotSelectedRecipeTextBlock.Text = "";
  88. }
  89. }
  90. private void Process_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  91. {
  92. process_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  93. if (process_currentFileNode.Parent.Name == "Process")
  94. {
  95. processSelectedRecipeTextBlock.Text = process_currentFileNode.Name;
  96. }
  97. else
  98. {
  99. processSelectedRecipeTextBlock.Text = "";
  100. }
  101. }
  102. private void WTWClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  103. {
  104. wtw_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  105. if (wtw_currentFileNode.Parent.Name == "Clean")
  106. {
  107. wtwSelectedRecipeTextBlock.Text = wtw_currentFileNode.Name;
  108. }
  109. else
  110. {
  111. wtwSelectedRecipeTextBlock.Text = "";
  112. }
  113. }
  114. private void PostClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  115. {
  116. post_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  117. if (post_currentFileNode.Parent.Name == "Clean")
  118. {
  119. postLotSelectedRecipeTextBlock.Text = post_currentFileNode.Name;
  120. }
  121. else
  122. {
  123. postLotSelectedRecipeTextBlock.Text = "";
  124. }
  125. }
  126. private void Window_Loaded(object sender, RoutedEventArgs e)
  127. {
  128. var dictionary = SerializeHelper.Instance.StringToDictionary(value);
  129. if (dictionary.Keys.Contains("PreLotClean"))
  130. {
  131. preLotSelectedRecipeTextBlock.Text = dictionary["PreLotClean"];
  132. foreach (var item in PreLotTreeView.Items)
  133. {
  134. var tvi = (TreeViewItem)PreLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  135. SetSelect(tvi, dictionary["PreLotClean"]);
  136. }
  137. }
  138. if (dictionary.Keys.Contains("Process"))
  139. {
  140. processSelectedRecipeTextBlock.Text = dictionary["Process"];
  141. foreach (var item in ProcessTreeView.Items)
  142. {
  143. var tvi = (TreeViewItem)ProcessTreeView.ItemContainerGenerator.ContainerFromItem(item);
  144. SetSelect(tvi, dictionary["Process"]);
  145. }
  146. }
  147. if (dictionary.Keys.Contains("WTWClean"))
  148. {
  149. wtwSelectedRecipeTextBlock.Text = dictionary["WTWClean"];
  150. foreach (var item in WTWTreeView.Items)
  151. {
  152. var tvi = (TreeViewItem)WTWTreeView.ItemContainerGenerator.ContainerFromItem(item);
  153. SetSelect(tvi, dictionary["WTWClean"]);
  154. }
  155. }
  156. if (dictionary.Keys.Contains("PostLotClean"))
  157. {
  158. postLotSelectedRecipeTextBlock.Text = dictionary["PostLotClean"];
  159. foreach (var item in PostLotTreeView.Items)
  160. {
  161. var tvi = (TreeViewItem)PostLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  162. SetSelect(tvi, dictionary["PostLotClean"]);
  163. }
  164. }
  165. }
  166. void SetSelect(TreeViewItem tvi, string value)
  167. {
  168. if (tvi.Items.Count > 0)
  169. {
  170. foreach (var item in tvi.Items)
  171. {
  172. var tviChild = (TreeViewItem)tvi.ItemContainerGenerator.ContainerFromItem(item);
  173. var model = (FileNode)item;
  174. if (model.Name == value)
  175. {
  176. tviChild.IsSelected = true;
  177. break;
  178. }
  179. else
  180. {
  181. SetSelect(tviChild, value);
  182. }
  183. }
  184. }
  185. }
  186. private void PreLotBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  187. {
  188. foreach (var item in PreLotTreeView.Items)
  189. {
  190. var tvi = (TreeViewItem)PreLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  191. SetSelect(tvi, "");
  192. }
  193. }
  194. private void ProcessBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  195. {
  196. foreach (var item in ProcessTreeView.Items)
  197. {
  198. var tvi = (TreeViewItem)ProcessTreeView.ItemContainerGenerator.ContainerFromItem(item);
  199. SetSelect(tvi, "");
  200. }
  201. }
  202. private void WTWBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  203. {
  204. foreach (var item in WTWTreeView.Items)
  205. {
  206. var tvi = (TreeViewItem)WTWTreeView.ItemContainerGenerator.ContainerFromItem(item);
  207. SetSelect(tvi, "");
  208. }
  209. }
  210. private void PostLotBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  211. {
  212. foreach (var item in PostLotTreeView.Items)
  213. {
  214. var tvi = (TreeViewItem)PostLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  215. SetSelect(tvi, "");
  216. }
  217. }
  218. }
  219. }