NewRecipeSequenceSelectView.xaml.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. foreach (var item in PreLotTreeView.Items)
  100. {
  101. var tvi = (TreeViewItem)PreLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  102. SetSelect(tvi, dictionary["PreLotClean"]);
  103. }
  104. foreach (var item in ProcessTreeView.Items)
  105. {
  106. var tvi = (TreeViewItem)ProcessTreeView.ItemContainerGenerator.ContainerFromItem(item);
  107. SetSelect(tvi, dictionary["Process"]);
  108. }
  109. foreach (var item in WTWTreeView.Items)
  110. {
  111. var tvi = (TreeViewItem)WTWTreeView.ItemContainerGenerator.ContainerFromItem(item);
  112. SetSelect(tvi, dictionary["WTWClean"]);
  113. }
  114. foreach (var item in PostLotTreeView.Items)
  115. {
  116. var tvi = (TreeViewItem)PostLotTreeView.ItemContainerGenerator.ContainerFromItem(item);
  117. SetSelect(tvi, dictionary["PostLotClean"]);
  118. }
  119. }
  120. void SetSelect(TreeViewItem tvi, string value)
  121. {
  122. if (tvi.Items.Count > 0)
  123. {
  124. foreach (var item in tvi.Items)
  125. {
  126. var tviChild = (TreeViewItem)tvi.ItemContainerGenerator.ContainerFromItem(item);
  127. var model = (FileNode)item;
  128. if (model.Name == value)
  129. {
  130. tviChild.IsSelected = true;
  131. break;
  132. }
  133. else
  134. {
  135. SetSelect(tviChild, value);
  136. }
  137. }
  138. }
  139. else
  140. {
  141. }
  142. }
  143. }
  144. }