NewRecipeSequenceSelectView.xaml.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 NewRecipeSequenceSelectView : 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 NewRecipeSequenceSelectView(string path)
  26. {
  27. InitializeComponent();
  28. //this.buttonOK.IsEnabled = false;
  29. value = path;
  30. }
  31. private void buttonCancel_Click(object sender, RoutedEventArgs e)
  32. {
  33. this.DialogResult = false;
  34. }
  35. private void buttonOK_Click(object sender, RoutedEventArgs e)
  36. {
  37. this.DialogResult = true;
  38. //if (this.currentFileNode != null)
  39. //{
  40. // if (this.currentFileNode.IsFile)
  41. // {
  42. // this.FullPath = this.currentFileNode.FullPath.Trim();
  43. // }
  44. //}
  45. //StringBuilder recipeInfo = new StringBuilder(); ;
  46. if (pre_currentFileNode != null)
  47. {
  48. recipeDictionary.Add("PreLotClean", pre_currentFileNode.Name);
  49. }
  50. else
  51. {
  52. recipeDictionary.Add("PreLotClean", "");
  53. }
  54. if (process_currentFileNode != null)
  55. {
  56. recipeDictionary.Add("Process", process_currentFileNode.Name);
  57. }
  58. else
  59. {
  60. recipeDictionary.Add("Process", "");
  61. }
  62. if (wtw_currentFileNode != null)
  63. {
  64. recipeDictionary.Add("WTWClean", wtw_currentFileNode.Name);
  65. }
  66. else
  67. {
  68. recipeDictionary.Add("WTWClean", "");
  69. }
  70. if (post_currentFileNode != null)
  71. {
  72. recipeDictionary.Add("PostLotClean", post_currentFileNode.Name);
  73. }
  74. else
  75. {
  76. recipeDictionary.Add("PostLotClean", "");
  77. }
  78. this.FullPath = SerializeHelper.Instance.DictionaryToString(recipeDictionary);
  79. }
  80. private void PreClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  81. {
  82. pre_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  83. }
  84. private void Process_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  85. {
  86. process_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  87. }
  88. private void WTWClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  89. {
  90. wtw_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  91. }
  92. private void PostClean_PART_TREE_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  93. {
  94. post_currentFileNode = (FileNode)(sender as TreeView).SelectedItem;
  95. }
  96. private void Window_Loaded(object sender, RoutedEventArgs e)
  97. {
  98. var dictionary = SerializeHelper.Instance.StringToDictionary(value);
  99. if (dictionary.Keys.Contains("PreLotClean"))
  100. {
  101. foreach (var item in PreLotTreeView.Items)
  102. {
  103. var tvi = (TreeViewItem)PreLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  104. SetSelect(tvi, dictionary["PreLotClean"]);
  105. }
  106. }
  107. if (dictionary.Keys.Contains("Process"))
  108. {
  109. foreach (var item in ProcessTreeView.Items)
  110. {
  111. var tvi = (TreeViewItem)ProcessTreeView.ItemContainerGenerator.ContainerFromItem(item);
  112. SetSelect(tvi, dictionary["Process"]);
  113. }
  114. }
  115. if (dictionary.Keys.Contains("WTWClean"))
  116. {
  117. foreach (var item in WTWTreeView.Items)
  118. {
  119. var tvi = (TreeViewItem)WTWTreeView.ItemContainerGenerator.ContainerFromItem(item);
  120. SetSelect(tvi, dictionary["WTWClean"]);
  121. }
  122. }
  123. if (dictionary.Keys.Contains("PostLotClean"))
  124. {
  125. foreach (var item in PostLotTreeView.Items)
  126. {
  127. var tvi = (TreeViewItem)PostLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  128. SetSelect(tvi, dictionary["PostLotClean"]);
  129. }
  130. }
  131. }
  132. void SetSelect(TreeViewItem tvi, string value)
  133. {
  134. if (tvi.Items.Count > 0)
  135. {
  136. foreach (var item in tvi.Items)
  137. {
  138. var tviChild = (TreeViewItem)tvi.ItemContainerGenerator.ContainerFromItem(item);
  139. var model = (FileNode)item;
  140. if (model.Name == value)
  141. {
  142. tviChild.IsSelected = true;
  143. break;
  144. }
  145. else
  146. {
  147. SetSelect(tviChild, value);
  148. }
  149. }
  150. }
  151. else
  152. {
  153. }
  154. }
  155. }
  156. }