VenusRecipeSequenceSelectView.xaml.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. private FileNode clean_currentFileNode;
  30. SerializableDictionary<string, string> recipeDictionary = new SerializableDictionary<string, string>();
  31. public string FullPath { get; private set; }
  32. string value;
  33. public VenusRecipeSequenceSelectView(string path)
  34. {
  35. InitializeComponent();
  36. value = path;
  37. }
  38. private void buttonCancel_Click(object sender, RoutedEventArgs e)
  39. {
  40. this.DialogResult = false;
  41. }
  42. private void buttonOK_Click(object sender, RoutedEventArgs e)
  43. {
  44. this.DialogResult = true;
  45. if (pre_currentFileNode != null && pre_currentFileNode.Parent.Name == "Clean")
  46. {
  47. recipeDictionary.Add("PreLotClean", pre_currentFileNode.Name);
  48. }
  49. else
  50. {
  51. recipeDictionary.Add("PreLotClean", "");
  52. }
  53. if (process_currentFileNode != null && process_currentFileNode.Parent.Name == "Process")
  54. {
  55. recipeDictionary.Add("Process", process_currentFileNode.Name);
  56. }
  57. else
  58. {
  59. recipeDictionary.Add("Process", "");
  60. }
  61. if (wtw_currentFileNode != null && wtw_currentFileNode.Parent.Name == "Clean")
  62. {
  63. recipeDictionary.Add("WTWClean", wtw_currentFileNode.Name);
  64. recipeDictionary.Add("WTWInterval", WTWInterval.Text);
  65. }
  66. else
  67. {
  68. recipeDictionary.Add("WTWClean", "");
  69. recipeDictionary.Add("WTWInterval", "");
  70. }
  71. if (post_currentFileNode != null && post_currentFileNode.Parent.Name == "Clean")
  72. {
  73. recipeDictionary.Add("PostLotClean", post_currentFileNode.Name);
  74. }
  75. else
  76. {
  77. recipeDictionary.Add("PostLotClean", "");
  78. }
  79. if (clean_currentFileNode != null && clean_currentFileNode.Parent.Name == "Clean")
  80. {
  81. recipeDictionary.Add("IdleClean", clean_currentFileNode.Name);
  82. recipeDictionary.Add("IdleTime", IdleTime.Text);
  83. }
  84. else
  85. {
  86. recipeDictionary.Add("IdleClean", "");
  87. recipeDictionary.Add("IdleTime", "");
  88. }
  89. this.FullPath = SerializeHelper.Instance.DictionaryToString(recipeDictionary);
  90. }
  91. private void PreClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  92. {
  93. pre_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  94. if (pre_currentFileNode.Parent.Name == "Clean")
  95. {
  96. preLotSelectedRecipeTextBlock.Text = pre_currentFileNode.Name;
  97. }
  98. else
  99. {
  100. preLotSelectedRecipeTextBlock.Text = "";
  101. }
  102. }
  103. private void Process_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  104. {
  105. process_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  106. if (process_currentFileNode.Parent.Name == "Process")
  107. {
  108. processSelectedRecipeTextBlock.Text = process_currentFileNode.Name;
  109. }
  110. else
  111. {
  112. processSelectedRecipeTextBlock.Text = "";
  113. }
  114. }
  115. private void WTWClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  116. {
  117. wtw_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  118. if (wtw_currentFileNode.Parent.Name == "Clean")
  119. {
  120. wtwSelectedRecipeTextBlock.Text = wtw_currentFileNode.Name;
  121. }
  122. else
  123. {
  124. wtwSelectedRecipeTextBlock.Text = "";
  125. }
  126. }
  127. private void PostClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  128. {
  129. post_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  130. if (post_currentFileNode.Parent.Name == "Clean")
  131. {
  132. postLotSelectedRecipeTextBlock.Text = post_currentFileNode.Name;
  133. }
  134. else
  135. {
  136. postLotSelectedRecipeTextBlock.Text = "";
  137. }
  138. }
  139. private void IdleClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  140. {
  141. clean_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  142. if (clean_currentFileNode.Parent.Name == "Clean")
  143. {
  144. idleLotSelectedRecipeTextBlock.Text = clean_currentFileNode.Name;
  145. }
  146. else
  147. {
  148. idleLotSelectedRecipeTextBlock.Text = "";
  149. }
  150. }
  151. private void Window_Loaded(object sender, RoutedEventArgs e)
  152. {
  153. var dictionary = SerializeHelper.Instance.StringToDictionary(value);
  154. if (dictionary.Keys.Contains("PreLotClean"))
  155. {
  156. preLotSelectedRecipeTextBlock.Text = dictionary["PreLotClean"];
  157. foreach (var item in PreLotTreeView.Items)
  158. {
  159. var tvi = (TreeViewItem)PreLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  160. SetSelect(tvi, dictionary["PreLotClean"]);
  161. }
  162. }
  163. if (dictionary.Keys.Contains("Process"))
  164. {
  165. processSelectedRecipeTextBlock.Text = dictionary["Process"];
  166. foreach (var item in ProcessTreeView.Items)
  167. {
  168. var tvi = (TreeViewItem)ProcessTreeView.ItemContainerGenerator.ContainerFromItem(item);
  169. SetSelect(tvi, dictionary["Process"]);
  170. }
  171. }
  172. if (dictionary.Keys.Contains("WTWClean"))
  173. {
  174. wtwSelectedRecipeTextBlock.Text = dictionary["WTWClean"];
  175. foreach (var item in WTWTreeView.Items)
  176. {
  177. var tvi = (TreeViewItem)WTWTreeView.ItemContainerGenerator.ContainerFromItem(item);
  178. SetSelect(tvi, dictionary["WTWClean"]);
  179. }
  180. }
  181. if (dictionary.Keys.Contains("PostLotClean"))
  182. {
  183. postLotSelectedRecipeTextBlock.Text = dictionary["PostLotClean"];
  184. foreach (var item in PostLotTreeView.Items)
  185. {
  186. var tvi = (TreeViewItem)PostLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  187. SetSelect(tvi, dictionary["PostLotClean"]);
  188. }
  189. }
  190. if (dictionary.Keys.Contains("IdleClean"))
  191. {
  192. idleLotSelectedRecipeTextBlock.Text = dictionary["IdleClean"];
  193. foreach (var item in LongIdleCleanTreeView.Items)
  194. {
  195. var tvi = (TreeViewItem)LongIdleCleanTreeView.ItemContainerGenerator.ContainerFromItem(item);
  196. SetSelect(tvi, dictionary["IdleClean"]);
  197. }
  198. }
  199. if (dictionary.Keys.Contains("IdleTime"))
  200. {
  201. IdleTime.Text = dictionary["IdleTime"];
  202. }
  203. if (dictionary.Keys.Contains("WTWInterval"))
  204. {
  205. WTWInterval.Text = dictionary["WTWInterval"];
  206. }
  207. }
  208. void SetSelect(TreeViewItem tvi, string value)
  209. {
  210. if (tvi.Items.Count > 0)
  211. {
  212. foreach (var item in tvi.Items)
  213. {
  214. var tviChild = (TreeViewItem)tvi.ItemContainerGenerator.ContainerFromItem(item);
  215. var model = (FileNode)item;
  216. if (model.Name == value)
  217. {
  218. tviChild.IsSelected = true;
  219. break;
  220. }
  221. else
  222. {
  223. SetSelect(tviChild, value);
  224. }
  225. }
  226. }
  227. }
  228. private void PreLotBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  229. {
  230. foreach (var item in PreLotTreeView.Items)
  231. {
  232. var tvi = (TreeViewItem)PreLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  233. SetSelect(tvi, "");
  234. }
  235. }
  236. private void ProcessBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  237. {
  238. foreach (var item in ProcessTreeView.Items)
  239. {
  240. var tvi = (TreeViewItem)ProcessTreeView.ItemContainerGenerator.ContainerFromItem(item);
  241. SetSelect(tvi, "");
  242. }
  243. }
  244. private void WTWBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  245. {
  246. foreach (var item in WTWTreeView.Items)
  247. {
  248. var tvi = (TreeViewItem)WTWTreeView.ItemContainerGenerator.ContainerFromItem(item);
  249. SetSelect(tvi, "");
  250. }
  251. }
  252. private void PostLotBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  253. {
  254. foreach (var item in PostLotTreeView.Items)
  255. {
  256. var tvi = (TreeViewItem)PostLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  257. SetSelect(tvi, "");
  258. }
  259. }
  260. private void IdleBorder_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  261. {
  262. foreach (var item in LongIdleCleanTreeView.Items)
  263. {
  264. var tvi = (TreeViewItem)LongIdleCleanTreeView.ItemContainerGenerator.ContainerFromItem(item);
  265. SetSelect(tvi, "");
  266. }
  267. }
  268. }
  269. }