KeplerRecipeSequenceSelectView.xaml.cs 8.3 KB

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