RecipeViewModel.cs 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.UI.View.Common;
  4. using MECF.Framework.Common.CommonData;
  5. //using MECF.Framework.Common.CommonData;
  6. using MECF.Framework.Common.DataCenter;
  7. using MECF.Framework.Common.OperationCenter;
  8. using Microsoft.VisualBasic;
  9. using Newtonsoft.Json;
  10. using Prism.Commands;
  11. using Prism.Mvvm;
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Reflection;
  18. using System.Text;
  19. using System.Threading;
  20. using System.Windows;
  21. using System.Windows.Controls;
  22. using System.Windows.Data;
  23. using System.Windows.Input;
  24. using System.Windows.Media;
  25. using System.Windows.Threading;
  26. using System.Xml;
  27. using Venus_Core;
  28. using Venus_Core.Attributes;
  29. using Venus_MainPages.PMs;
  30. using Venus_MainPages.Unity;
  31. using Venus_MainPages.Views;
  32. using Venus_Themes.CustomControls;
  33. using Venus_Themes.UserControls;
  34. using WPF.Themes.UserControls;
  35. using Xceed.Wpf.Toolkit.Primitives;
  36. using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
  37. using RecipeStep = Venus_Core.RecipeStep;
  38. namespace Venus_MainPages.ViewModels
  39. {
  40. public enum EPDType
  41. {
  42. Socket,
  43. WCF,
  44. None
  45. }
  46. internal class RecipeViewModel : BindableBase
  47. {
  48. #region 私有字段
  49. public string ModuleName = "PMA";
  50. private string m_CurrentRecipeName;
  51. private UiRecipeManager m_uiRecipeManager = new UiRecipeManager();
  52. private RecipeView recipeView;
  53. private TreeView treeViewRcpList;
  54. private Recipe m_currentRecipe;
  55. private string m_recipeType;
  56. private bool firstLoad=true;
  57. private WrapPanel headWrapPanel;
  58. private StackPanel bodyStackPanel;
  59. private List<SolidColorBrush> solidColorBrushes = new List<SolidColorBrush>()
  60. {
  61. new SolidColorBrush(Colors.Coral),
  62. new SolidColorBrush(Colors.Cyan),
  63. new SolidColorBrush(Colors.Honeydew)
  64. };
  65. private Grid currentRecipeGrid;
  66. private int copyIndex = -1;
  67. private List<string> EPDCfgList=new List<string> ();
  68. private EPDType currentEPDType=EPDType.None;
  69. private JetChamber currentChamber;
  70. private bool isInstalledEPD;
  71. #endregion
  72. #region 属性
  73. public string CurrentRecipeName
  74. {
  75. get { return m_CurrentRecipeName; }
  76. set { SetProperty(ref m_CurrentRecipeName, value); }
  77. }
  78. public Recipe CurrentRecipe
  79. {
  80. get { return m_currentRecipe; }
  81. set
  82. {
  83. m_currentRecipe = value;
  84. RecipeType = m_currentRecipe.Header.Type.ToString();
  85. }
  86. }
  87. public string RecipeType
  88. {
  89. get { return m_recipeType; }
  90. set { SetProperty(ref m_recipeType, value); }
  91. }
  92. #endregion
  93. #region 命令
  94. private DelegateCommand<Object> _MouseRightButtonDownCommand;
  95. public DelegateCommand<Object> MouseRightButtonDownCommand =>
  96. _MouseRightButtonDownCommand ?? (_MouseRightButtonDownCommand = new DelegateCommand<Object>(OnMouseRightButtonDown));
  97. private DelegateCommand<Object> _LoadedCommand;
  98. public DelegateCommand<Object> LoadedCommand =>
  99. _LoadedCommand ?? (_LoadedCommand = new DelegateCommand<Object>(OnLoaded));
  100. private DelegateCommand _SaveRecipeCommand;
  101. public DelegateCommand SaveRecipeCommand =>
  102. _SaveRecipeCommand ?? (_SaveRecipeCommand = new DelegateCommand(OnSaveRecipe));
  103. private DelegateCommand _AddStepCommand;
  104. public DelegateCommand AddStepCommand =>
  105. _AddStepCommand ?? (_AddStepCommand = new DelegateCommand(OnAddStep));
  106. private DelegateCommand _DeleteStepCommand;
  107. public DelegateCommand DeleteStepCommand =>
  108. _DeleteStepCommand ?? (_DeleteStepCommand = new DelegateCommand(OnDeleteStep));
  109. #endregion
  110. #region 构造函数
  111. public RecipeViewModel()
  112. {
  113. }
  114. #endregion
  115. #region 命令方法
  116. private void OnAddStep()
  117. {
  118. if (CurrentRecipe != null)
  119. {
  120. var index = currentRecipeGrid.ColumnDefinitions.Count;
  121. RecipeStep recipeStep;
  122. if (copyIndex == -1)
  123. {
  124. recipeStep = new RecipeStep();
  125. switch (currentChamber)
  126. {
  127. case JetChamber.Venus:
  128. case JetChamber.Kepler2300:
  129. recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  130. recipeStep.LstUnit.Add(new TCPUnit());
  131. recipeStep.LstUnit.Add(new BiasUnit());
  132. recipeStep.LstUnit.Add(new GasControlUnit());
  133. recipeStep.LstUnit.Add(new ESCHVUnit());
  134. recipeStep.LstUnit.Add(new ProcessKitUnit());
  135. break;
  136. case JetChamber.Kepler2200A:
  137. recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  138. recipeStep.LstUnit.Add(new HeaterUnit());
  139. recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  140. break;
  141. }
  142. CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  143. }
  144. else
  145. {
  146. var t = JsonConvert.SerializeObject(CurrentRecipe);
  147. recipeStep = Recipe.Load(t).Steps[copyIndex - 1];
  148. CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  149. }
  150. RecipeStepToGridColumn(recipeStep, currentRecipeGrid, index, true);
  151. for (int i = 1; i <= CurrentRecipe.Steps.Count; i++)
  152. {
  153. CurrentRecipe.Steps[i - 1].StepNo = i;
  154. }
  155. }
  156. }
  157. private void OnDeleteStep()
  158. {
  159. if (CurrentRecipe != null)
  160. {
  161. OnDeleteStep(CurrentRecipe.Steps.Count - 1);
  162. }
  163. }
  164. private void OnSaveRecipe()
  165. {
  166. SaveRecipe(CurrentRecipeName, RecipeUnity.RecipeToString(CurrentRecipe));
  167. LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  168. }
  169. private void OnLoaded(Object myrecipeView)
  170. {
  171. if (firstLoad == true)
  172. {
  173. currentChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.ChamberType").ToString());
  174. isInstalledEPD = bool.Parse(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.EPD.IsEnabled").ToString()) ;
  175. firstLoad = false;
  176. recipeView = myrecipeView as RecipeView;
  177. treeViewRcpList = recipeView.treeViewRcpList;
  178. headWrapPanel = recipeView.headWrapPanel;
  179. bodyStackPanel = recipeView.bodyStackPanel;
  180. UpdateRecipeFileList();
  181. treeViewRcpList.SelectedItemChanged += TreeViewRcpList_SelectedItemChanged;
  182. DispatcherTimer timer = new DispatcherTimer();
  183. timer.Interval = TimeSpan.FromSeconds(1);
  184. timer.Tick += Timer_Tick; ;
  185. timer.Start();
  186. for (int i = 0; i < 5; i++)
  187. {
  188. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.EndPoint.SearchCfg");
  189. Thread.Sleep(200);
  190. currentEPDType = (EPDType)System.Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.EPD.EPDType"));
  191. if (currentEPDType == EPDType.Socket)
  192. {
  193. EPDCfgList = (List<string>)QueryDataClient.Instance.Service.GetData($"{ModuleName}.EPDCfgList");
  194. }
  195. if (EPDCfgList != null)
  196. {
  197. break;
  198. }
  199. }
  200. }
  201. }
  202. private void Timer_Tick(object sender, EventArgs e)
  203. {
  204. }
  205. TreeViewFileItem selectedItem;
  206. private void TreeViewRcpList_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  207. {
  208. selectedItem = e.NewValue as TreeViewFileItem;
  209. if (selectedItem == null)
  210. return;
  211. try
  212. {
  213. CurrentRecipeName = selectedItem.FileName;
  214. string xmlRecipeData = m_uiRecipeManager.LoadRecipe(ModuleName, selectedItem.FileName);
  215. if (xmlRecipeData == "")
  216. {
  217. treeViewRcpList.Items.Remove(selectedItem);
  218. return;
  219. }
  220. CurrentRecipe = Recipe.Load(xmlRecipeData);
  221. LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  222. LoadRecipe(CurrentRecipe);
  223. }
  224. catch (Exception ex)
  225. {
  226. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), ex.Message), Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
  227. }
  228. e.Handled = true;
  229. }
  230. public bool SaveRecipe(string recipeName, string recipeContent)
  231. {
  232. return m_uiRecipeManager.SaveRecipe(ModuleName, recipeName, recipeContent);
  233. }
  234. private void OnMouseRightButtonDown(Object treeView)
  235. {
  236. //treeViewRcpList = treeView as TreeView;
  237. treeViewRcpList.ContextMenu = new ContextMenu() { Background = new SolidColorBrush(Colors.AliceBlue)};
  238. MenuItem menuItem = new MenuItem();
  239. menuItem = new MenuItem();
  240. menuItem.Tag = "\\";
  241. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_CreateRecipe);
  242. menuItem.Header = "New Recipe";
  243. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  244. menuItem = new MenuItem();
  245. menuItem.Tag = "\\";
  246. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_DeleteRecipe);
  247. menuItem.Header = "Delete Recipe";
  248. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  249. menuItem = new MenuItem();
  250. menuItem.Tag = "\\";
  251. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_SaveAsRecipe);
  252. menuItem.Header = "Save As Recipe";
  253. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  254. menuItem = new MenuItem();
  255. menuItem.Tag = "\\";
  256. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_RenameRecipe);
  257. menuItem.Header = "Rename";
  258. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  259. treeViewRcpList.ContextMenu.Visibility = Visibility.Visible;
  260. }
  261. private void menuItem_MouseClick_CreateRecipe(object sender, RoutedEventArgs e)
  262. {
  263. MenuItem mit = sender as MenuItem;
  264. string folderName = mit.Tag as string;
  265. PerformCreateRecipe(folderName);
  266. }
  267. private void PerformCreateRecipe(string folderName)
  268. {
  269. try
  270. {
  271. RecipeNameInputDlg dlg = new RecipeNameInputDlg(Application.Current.Resources["GlobalLableMsgInputRecipeName"].ToString())
  272. {
  273. Owner = Application.Current.MainWindow
  274. };
  275. if (dlg.ShowDialog() == true)
  276. {
  277. var recipeName = folderName + "\\" + dlg.InputText;
  278. RecipeType type = (RecipeType)Enum.Parse(typeof(RecipeType), dlg.SelectedType);
  279. string newRecipe =RecipeUnity.CreateRecipe(currentChamber,type, dlg.InputText);
  280. //string recipeContent = m_uiRecipeManager.GetRecipeTemplate(ModuleName);
  281. //m_uiRecipeManager.SaveAsRecipe(ModuleName, recipeName, m_uiRecipeManager.LoadRecipe("system",folderName));
  282. if (SaveAsRecipe(recipeName, newRecipe))
  283. {
  284. //UpdateRecipeFileList();
  285. //SelectRecipe(recipeName);
  286. treeViewRcpList.Items.Add(new TreeViewFileItem(dlg.InputText));
  287. }
  288. else
  289. {
  290. WPFMessageBox.ShowError("Error");
  291. }
  292. }
  293. }
  294. catch (Exception ex)
  295. {
  296. LOG.WriteExeption(ex);
  297. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableMsgRecipeCreateException"].ToString(), ex.Message), Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
  298. }
  299. }
  300. private void menuItem_MouseClick_DeleteRecipe(object sender, RoutedEventArgs e)
  301. {
  302. if (CurrentRecipe == null)
  303. {
  304. return;
  305. }
  306. if (WPFMessageBox.ShowQuestion($"Delete {CurrentRecipeName}?","删除后无法恢复!!!") == MessageBoxResult.Yes)
  307. {
  308. MenuItem mit = sender as MenuItem;
  309. //string recipename = mit.Header.ToString();
  310. m_uiRecipeManager.DeleteRecipe(ModuleName, CurrentRecipeName);
  311. //PerformCreateRecipe(folderName);
  312. treeViewRcpList.Items.Remove(selectedItem);
  313. }
  314. }
  315. private void menuItem_MouseClick_SaveAsRecipe(object sender, RoutedEventArgs e)
  316. {
  317. if (CurrentRecipe == null)
  318. {
  319. return;
  320. }
  321. var newName = Interaction.InputBox(" ", "Save As Recipe", CurrentRecipeName, -1, -1);
  322. if (newName != CurrentRecipeName && newName != "")
  323. {
  324. var newRecipe = CurrentRecipe;
  325. newRecipe.Header.Name = newName;
  326. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  327. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, newName + ".rcp");
  328. File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  329. UpdateRecipeFileList();
  330. }
  331. }
  332. private void menuItem_MouseClick_RenameRecipe(object sender, RoutedEventArgs e)
  333. {
  334. if (CurrentRecipe == null)
  335. {
  336. return;
  337. }
  338. var newName= Interaction.InputBox(" ", "Rename Recipe", CurrentRecipeName, -1, -1);
  339. if (newName != CurrentRecipeName && newName!="")
  340. {
  341. var oldrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, CurrentRecipeName + ".rcp");
  342. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, newName + ".rcp");
  343. CurrentRecipe.Header.Name = newName;
  344. SaveRecipe(CurrentRecipeName, RecipeUnity.RecipeToString(CurrentRecipe));
  345. File.Move(oldrecipePath, newrecipePath);
  346. UpdateRecipeFileList();
  347. }
  348. }
  349. public bool SaveAsRecipe(string recipeName, string recipeContent)
  350. {
  351. return m_uiRecipeManager.SaveAsRecipe(ModuleName, recipeName, recipeContent);
  352. }
  353. public string GetXmlRecipeList()
  354. {
  355. return m_uiRecipeManager.GetXmlRecipeList(ModuleName, true) ?? "";
  356. }
  357. void CreateTreeViewItems(XmlElement curElementNode, ItemsControl itemsControl)
  358. {
  359. foreach (XmlElement ele in curElementNode.ChildNodes)
  360. {
  361. if (ele.Name == "File")
  362. {
  363. string fileName = ele.Attributes["Name"].Value;
  364. fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
  365. TreeViewFileItem item = new TreeViewFileItem(ele.Attributes["Name"].Value);
  366. item.Tag = ele.Attributes["Name"].Value;
  367. //item.ToolTip = fileName;
  368. itemsControl.Items.Add(item);
  369. }
  370. else if (ele.Name == "Folder")
  371. {
  372. string folderName = ele.Attributes["Name"].Value;
  373. folderName = folderName.Substring(folderName.LastIndexOf('\\') + 1);
  374. TreeViewFolderItem item = new TreeViewFolderItem(folderName);
  375. item.Tag = ele.Attributes["Name"].Value;
  376. CreateTreeViewItems(ele, item);
  377. item.IsExpanded = false;
  378. itemsControl.Items.Add(item);
  379. }
  380. }
  381. }
  382. private IEnumerable<string> GetFilesNames(string path)
  383. {
  384. return Directory.GetFiles(path, "*.rcp")?
  385. .Select(Path.GetFileNameWithoutExtension);
  386. }
  387. private void LoadHeadWrapPanel(WrapPanel HeadWrapPanel, Recipe recipe)
  388. {
  389. HeadWrapPanel.Children.Clear();
  390. Type type = recipe.Header.GetType();
  391. foreach (var propertyInfo in type.GetProperties())
  392. {
  393. TextBlock textBlock = new TextBlock();
  394. textBlock.FontSize = 15;
  395. //textBlock.Width = 100;
  396. switch (propertyInfo.Name)
  397. {
  398. case "ChuckRecipe":
  399. textBlock.Text = "Chuck:";
  400. break;
  401. case "DechuckRecipe":
  402. textBlock.Text = "DeChuck:";
  403. break;
  404. default:
  405. textBlock.Text = propertyInfo.Name + ":";
  406. break;
  407. }
  408. textBlock.Margin = new Thickness(15, 0, 0, 0);
  409. textBlock.VerticalAlignment = VerticalAlignment.Center;
  410. HeadWrapPanel.Children.Add(textBlock);
  411. Binding binding = new Binding()
  412. {
  413. Source = recipe.Header, // 数据源
  414. Path = new PropertyPath(propertyInfo.Name), // 需绑定的数据源属性名
  415. Mode = BindingMode.TwoWay, // 绑定模式
  416. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, //触发器
  417. };
  418. var propertyTypeName = propertyInfo.PropertyType.Name;
  419. var propertyInfoName = propertyInfo.Name;
  420. Control control = new Control();
  421. switch (propertyInfoName)
  422. {
  423. case "ChamberType":
  424. control = new ComboBox();
  425. control.Height = 23;
  426. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  427. ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  428. break;
  429. case "Type":
  430. ComboBox cb = new ComboBox();
  431. cb.SelectionChanged += ChangeUI;
  432. control = cb;
  433. control.Height = 23;
  434. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  435. ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  436. break;
  437. case "ChuckRecipe":
  438. string[] chucklist = new string[] { "" };
  439. ArrayList arrayList = new ArrayList(chucklist.ToList());
  440. IEnumerable<string> chlist= GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName)).ToList().Where(item => item.ToLower().Contains("chuck") && (item.ToLower().Contains("dechuck") == false));
  441. foreach (var i in chlist)
  442. {
  443. arrayList.Add(i);
  444. }
  445. chucklist = (string[])arrayList.ToArray(typeof(string));
  446. StringBuilder stringBuilder = new StringBuilder();
  447. //输出
  448. for (int i = 0; i < chucklist.Length; i++)
  449. {
  450. stringBuilder.Append(chucklist[i] + "\t");
  451. }
  452. control = new ComboBox()
  453. {
  454. ItemsSource = chucklist
  455. };
  456. control.Height = 23;
  457. control.MinWidth = 100;
  458. control.MaxWidth = 300;
  459. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  460. break;
  461. case "DechuckRecipe":
  462. string[] dechucklist = new string[] { "" };
  463. ArrayList dearrayList = new ArrayList(dechucklist.ToList());
  464. IEnumerable<string> delist = GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName)).ToList().Where(item => item.ToLower().Contains("dechuck"));
  465. foreach (var i in delist)
  466. {
  467. dearrayList.Add(i);
  468. }
  469. dechucklist = (string[])dearrayList.ToArray(typeof(string));
  470. StringBuilder destringBuilder = new StringBuilder();
  471. for (int i = 0; i < dechucklist.Length; i++)
  472. {
  473. destringBuilder.Append(dechucklist[i] + "\t");
  474. }
  475. control = new ComboBox()
  476. {
  477. ItemsSource= dechucklist
  478. };
  479. control.Height = 23;
  480. control.MinWidth = 100;
  481. control.MaxWidth = 300;
  482. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  483. break;
  484. default:
  485. control = new TextBox();
  486. control.Margin = new Thickness(1, 0, 0, 0);
  487. control.BorderThickness = new Thickness(0, 0, 0, 1);
  488. //control.BorderBrush = Brushes.Black;
  489. control.FontSize = 15;
  490. control.Foreground = Brushes.Green;
  491. control.Background = Brushes.Transparent;
  492. control.VerticalAlignment = VerticalAlignment.Center;
  493. control.MinWidth = 15;
  494. control.SetBinding(TextBox.TextProperty, binding);
  495. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  496. if (objAttrs.Length > 0)
  497. {
  498. (control as TextBox).IsReadOnly = true;
  499. }
  500. break;
  501. }
  502. //switch (propertyTypeName)
  503. //{
  504. // case "Int32":
  505. // case "String":
  506. // control = new TextBox();
  507. // control.Margin = new Thickness(1, 0, 0, 0);
  508. // control.BorderThickness = new Thickness(0, 0, 0, 1);
  509. // //control.BorderBrush = Brushes.Black;
  510. // control.FontSize = 15;
  511. // control.Foreground = Brushes.Green;
  512. // control.Background = Brushes.Transparent;
  513. // control.VerticalAlignment = VerticalAlignment.Center;
  514. // control.MinWidth = 15;
  515. // control.SetBinding(TextBox.TextProperty, binding);
  516. // object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  517. // if (objAttrs.Length > 0)
  518. // {
  519. // (control as TextBox).IsReadOnly = true;
  520. // }
  521. // break;
  522. // case "Boolean":
  523. // control = new CheckBox();
  524. // control.SetBinding(CheckBox.IsCheckedProperty, binding);
  525. // break;
  526. // default:
  527. // control = new ComboBox();
  528. // control.Height = 23;
  529. // control.SetBinding(ComboBox.SelectedItemProperty, binding);
  530. // ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  531. // break;
  532. //}
  533. HeadWrapPanel.Children.Add(control);
  534. }
  535. }
  536. private void ChangeUI(object sender, SelectionChangedEventArgs e)
  537. {
  538. var t = sender as ComboBox;
  539. if (t.SelectedValue.ToString() == "Chuck" || t.SelectedValue.ToString() == "DeChuck")
  540. {
  541. headWrapPanel.Children[8].Visibility = Visibility.Collapsed;
  542. headWrapPanel.Children[9].Visibility = Visibility.Collapsed;
  543. headWrapPanel.Children[10].Visibility = Visibility.Collapsed;
  544. headWrapPanel.Children[11].Visibility = Visibility.Collapsed;
  545. }
  546. else
  547. {
  548. headWrapPanel.Children[8].Visibility = Visibility.Visible;
  549. headWrapPanel.Children[9].Visibility = Visibility.Visible;
  550. headWrapPanel.Children[10].Visibility = Visibility.Visible;
  551. headWrapPanel.Children[11].Visibility = Visibility.Visible;
  552. }
  553. }
  554. private void MenuItemLeftInsert_Click(object sender, RoutedEventArgs e)
  555. {
  556. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  557. int insertIndex = Convert.ToInt32(t.Text);
  558. //OnAddStep(insertIndex);
  559. var recipeStep = new RecipeStep();
  560. switch (currentChamber)
  561. {
  562. case JetChamber.Venus:
  563. case JetChamber.Kepler2300:
  564. recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  565. recipeStep.LstUnit.Add(new TCPUnit());
  566. recipeStep.LstUnit.Add(new BiasUnit());
  567. recipeStep.LstUnit.Add(new GasControlUnit());
  568. recipeStep.LstUnit.Add(new ESCHVUnit());
  569. recipeStep.LstUnit.Add(new ProcessKitUnit());
  570. break;
  571. case JetChamber.Kepler2200A:
  572. recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  573. recipeStep.LstUnit.Add(new HeaterUnit());
  574. recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  575. break;
  576. }
  577. CurrentRecipe.Steps.Insert(insertIndex-1, recipeStep);
  578. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  579. {
  580. CurrentRecipe.Steps[i].StepNo = i + 1;
  581. }
  582. LoadRecipe(CurrentRecipe);
  583. }
  584. private void MenuItemRightInsert_Click(object sender, RoutedEventArgs e)
  585. {
  586. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  587. int insertIndex = Convert.ToInt32(t.Text);
  588. //OnAddStep(insertIndex + 1);
  589. var recipeStep = new RecipeStep();
  590. switch (currentChamber)
  591. {
  592. case JetChamber.Venus:
  593. case JetChamber.Kepler2300:
  594. recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  595. recipeStep.LstUnit.Add(new TCPUnit());
  596. recipeStep.LstUnit.Add(new BiasUnit());
  597. recipeStep.LstUnit.Add(new GasControlUnit());
  598. recipeStep.LstUnit.Add(new ESCHVUnit());
  599. recipeStep.LstUnit.Add(new ProcessKitUnit());
  600. break;
  601. case JetChamber.Kepler2200A:
  602. recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  603. recipeStep.LstUnit.Add(new HeaterUnit());
  604. recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  605. break;
  606. }
  607. CurrentRecipe.Steps.Insert(insertIndex, recipeStep);
  608. for (int i=0;i< CurrentRecipe.Steps.Count;i++)
  609. {
  610. CurrentRecipe.Steps[i].StepNo = i + 1;
  611. }
  612. LoadRecipe(CurrentRecipe);
  613. }
  614. private void MenuItemDelete_Click(object sender, RoutedEventArgs e)
  615. {
  616. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  617. int deleteIndex = Convert.ToInt32(t.Text);
  618. //OnDeleteStep(deleteIndex - 1);
  619. CurrentRecipe.Steps.RemoveAt(deleteIndex-1);
  620. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  621. {
  622. CurrentRecipe.Steps[i].StepNo = i + 1;
  623. }
  624. LoadRecipe(CurrentRecipe);
  625. }
  626. private void MenuItemCopy_Click(object sender, RoutedEventArgs e)
  627. {
  628. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  629. copyIndex = Convert.ToInt32(t.Text);
  630. }
  631. #endregion
  632. #region 私有方法
  633. private void RecipeStepToGridColumn(RecipeStep recipeStep, Grid grid, int index, bool isInsert)
  634. {
  635. int location = 1;
  636. if (isInsert == true)
  637. {
  638. location -= 1;
  639. }
  640. Type recipeType = recipeStep.GetType();
  641. int cycleCount = 1;
  642. if (index == 0)
  643. {
  644. cycleCount = 2;
  645. }
  646. for (int j = 0; j < cycleCount; j++)
  647. {
  648. int i = 0;
  649. ColumnDefinition col1 = new ColumnDefinition();
  650. //col1.MinWidth = 50;
  651. grid.ColumnDefinitions.Insert(index, col1);
  652. Binding stepcheckbinding = null;
  653. //grid.MinWidth = 200;
  654. foreach (PropertyInfo propertyInfo in recipeType.GetProperties())
  655. {
  656. string propertyInfoName = propertyInfo.Name;
  657. string propertyTypeName = propertyInfo.PropertyType.Name;
  658. if (propertyInfoName != "LstUnit")
  659. {
  660. if (index == 0 && grid.ColumnDefinitions.Count == 1)
  661. {
  662. RowDefinition row1 = new RowDefinition();
  663. grid.RowDefinitions.Add(row1);
  664. if ((propertyInfoName == "EPDConfig" || propertyInfoName == "MinEndPointTime" || propertyInfoName == "MaxEndPointTime") && isInstalledEPD == false)
  665. {
  666. row1.Height = new GridLength(0);
  667. }
  668. }
  669. if (grid.ColumnDefinitions.Count == 1 && j == 0)
  670. {
  671. TextBox textBlock = new TextBox();
  672. textBlock.IsReadOnly = true;
  673. textBlock.Text = propertyInfoName;
  674. grid.Children.Add(textBlock);
  675. textBlock.Background = new SolidColorBrush(Colors.BurlyWood);
  676. Grid.SetRow(textBlock, i);
  677. Grid.SetColumn(textBlock, 0);
  678. }
  679. else
  680. {
  681. Binding binding = new Binding()
  682. {
  683. Source = recipeStep, // 数据源
  684. Path = new PropertyPath(propertyInfoName), // 需绑定的数据源属性名
  685. Mode = BindingMode.TwoWay, // 绑定模式
  686. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  687. };
  688. switch (propertyTypeName)
  689. {
  690. case "Int32":
  691. case "String":
  692. if (propertyInfoName == "EPDConfig")
  693. {
  694. if (currentEPDType == EPDType.Socket)
  695. {
  696. ComboBox EPDcomboBox = new ComboBox();
  697. EPDcomboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  698. EPDcomboBox.Background = new SolidColorBrush(Colors.Black);
  699. EPDcomboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  700. EPDcomboBox.ItemsSource = EPDCfgList;
  701. grid.Children.Add(EPDcomboBox);
  702. Grid.SetRow(EPDcomboBox, i);
  703. Grid.SetColumn(EPDcomboBox, index + location);
  704. EPDcomboBox.DropDownOpened += EPDcomboBox_DropDownOpened;
  705. }
  706. else if (currentEPDType == EPDType.WCF)
  707. {
  708. Button EPDButton = new Button();
  709. EPDButton.Content = "EndPoint";
  710. EPDButton.Cursor = Cursors.Hand;
  711. EPDButton.Tag = $"{CurrentRecipeName}.{(index + location).ToString()}";
  712. EPDButton.Style = null;
  713. EPDButton.Click += EPDButton_Click;
  714. grid.Children.Add(EPDButton);
  715. Grid.SetRow(EPDButton, i);
  716. Grid.SetColumn(EPDButton, index + location);
  717. }
  718. break;
  719. }
  720. TextBox textBox = new TextBox();
  721. textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
  722. textBox.VerticalContentAlignment = VerticalAlignment.Center;
  723. if (stepcheckbinding == null)
  724. {
  725. textBox.IsEnabled = true;
  726. }
  727. else
  728. {
  729. textBox.SetBinding(TextBox.IsEnabledProperty, stepcheckbinding);
  730. }
  731. textBox.SetBinding(TextBox.TextProperty, binding);
  732. grid.Children.Add(textBox);
  733. Grid.SetRow(textBox, i);
  734. Grid.SetColumn(textBox, index + location);
  735. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  736. if (objAttrs.Length > 0)
  737. {
  738. textBox.IsReadOnly = true;
  739. ContextMenu contextmenu = new ContextMenu();
  740. textBox.ContextMenu = contextmenu;
  741. MenuItem menuItemDelete = new MenuItem();
  742. menuItemDelete.Header = "删除";
  743. menuItemDelete.Click += MenuItemDelete_Click;
  744. MenuItem menuItemLeftInsert = new MenuItem();
  745. menuItemLeftInsert.Header = "左插入";
  746. menuItemLeftInsert.Click += MenuItemLeftInsert_Click;
  747. MenuItem menuItemRightInsert = new MenuItem();
  748. menuItemRightInsert.Header = "右插入";
  749. menuItemRightInsert.Click += MenuItemRightInsert_Click;
  750. MenuItem menuItemCopy = new MenuItem();
  751. menuItemCopy.Tag = textBox.Text;
  752. menuItemCopy.Header = "复制";
  753. menuItemCopy.Click += MenuItemCopy_Click;
  754. contextmenu.Items.Add(menuItemCopy);
  755. contextmenu.Items.Add(menuItemDelete);
  756. contextmenu.Items.Add(menuItemLeftInsert);
  757. contextmenu.Items.Add(menuItemRightInsert);
  758. }
  759. break;
  760. case "Boolean":
  761. CheckBox checkBox = new CheckBox();
  762. checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
  763. grid.Children.Add(checkBox);
  764. Grid.SetRow(checkBox, i);
  765. Grid.SetColumn(checkBox, index + location);
  766. //if (stepcheckbinding == null)
  767. //{
  768. // stepcheckbinding = new Binding
  769. // {
  770. // Source = checkBox, // 数据源
  771. // Path = new PropertyPath("IsChecked"), // 需绑定的数据源属性名
  772. // Mode = BindingMode.TwoWay, // 绑定模式
  773. // UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  774. // };
  775. //}
  776. //else
  777. //{
  778. //}
  779. if (stepcheckbinding == null)
  780. {
  781. checkBox.IsEnabled = true;
  782. }
  783. else
  784. {
  785. checkBox.SetBinding(TextBox.IsEnabledProperty, stepcheckbinding);
  786. }
  787. break;
  788. default:
  789. ComboBox comboBox = new ComboBox();
  790. comboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  791. comboBox.Background = new SolidColorBrush(Colors.Black);
  792. comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  793. ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
  794. grid.Children.Add(comboBox);
  795. Grid.SetRow(comboBox, i);
  796. Grid.SetColumn(comboBox, index + location);
  797. if (stepcheckbinding == null)
  798. {
  799. comboBox.IsEnabled = true;
  800. }
  801. else
  802. {
  803. comboBox.SetBinding(TextBox.IsEnabledProperty, stepcheckbinding);
  804. }
  805. break;
  806. }
  807. }
  808. i++;
  809. }
  810. }
  811. int k = 0;
  812. recipeStep.LstUnit.ToList().ForEach(x =>
  813. {
  814. Type unitType = x.GetType();
  815. Binding checkbinding = null;
  816. foreach (PropertyInfo propertyInfo in unitType.GetProperties())
  817. {
  818. if (index == 0 && grid.ColumnDefinitions.Count == 1)
  819. {
  820. RowDefinition row1 = new RowDefinition();
  821. grid.RowDefinitions.Add(row1);
  822. }
  823. if (grid.ColumnDefinitions.Count == 1 && j == 0)
  824. {
  825. TextBox textBlock = new TextBox();
  826. textBlock.IsReadOnly = true;
  827. switch (propertyInfo.Name)
  828. {
  829. case "Gas1":
  830. var data1 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas1");
  831. textBlock.Text = $"{propertyInfo.Name}({data1.DisplayName},{data1.Scale})";
  832. break;
  833. case "Gas2":
  834. var data2 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas2");
  835. textBlock.Text = $"{propertyInfo.Name}({data2.DisplayName},{data2.Scale})";
  836. break;
  837. case "Gas3":
  838. var data3 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas3");
  839. textBlock.Text = $"{propertyInfo.Name}({data3.DisplayName},{data3.Scale})";
  840. break;
  841. case "Gas4":
  842. var data4 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas4");
  843. textBlock.Text = $"{propertyInfo.Name}({data4.DisplayName},{data4.Scale})";
  844. break;
  845. case "Gas5":
  846. var data5 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas5");
  847. textBlock.Text = $"{propertyInfo.Name}({data5.DisplayName},{data5.Scale})";
  848. break;
  849. case "Gas6":
  850. var data6 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas6");
  851. textBlock.Text = $"{propertyInfo.Name}({data6.DisplayName},{data6.Scale})";
  852. break;
  853. case "Gas7":
  854. var data7 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas7");
  855. textBlock.Text = $"{propertyInfo.Name}({data7.DisplayName},{data7.Scale})";
  856. break;
  857. case "Gas8":
  858. var data8 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas8");
  859. textBlock.Text = $"{propertyInfo.Name}({data8.DisplayName},{data8.Scale})";
  860. break;
  861. case "HeaterPressure":
  862. textBlock.Text = "Pressure(Pa)";
  863. break;
  864. case "HeaterTemp":
  865. textBlock.Text = "Heater Temp(℃)";
  866. break;
  867. case "HeaterRatio":
  868. textBlock.Text = "Heater Ratio";
  869. break;
  870. default:
  871. textBlock.Text = propertyInfo.Name;
  872. break;
  873. }
  874. textBlock.Background = solidColorBrushes[k % 3];
  875. grid.Children.Add(textBlock);
  876. Grid.SetRow(textBlock, i);
  877. Grid.SetColumn(textBlock, 0);
  878. }
  879. else
  880. {
  881. Binding binding = new Binding()
  882. {
  883. Source = recipeStep.LstUnit[k], // 数据源
  884. //Path = new PropertyPath($"LstUnit[{k}]." + propertyInfo.Name), // 需绑定的数据源属性名
  885. Path = new PropertyPath(propertyInfo.Name), // 需绑定的数据源属性名
  886. Mode = BindingMode.TwoWay, // 绑定模式
  887. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  888. };
  889. var item = propertyInfo.PropertyType.Name;
  890. if (propertyInfo.Name == "UnitName")
  891. {
  892. TextBox textBlock1 = new TextBox();
  893. textBlock1.HorizontalContentAlignment = HorizontalAlignment.Center;
  894. textBlock1.VerticalContentAlignment =VerticalAlignment.Center;
  895. textBlock1.Text = propertyInfo.GetValue(x).ToString();
  896. textBlock1.IsReadOnly = true;
  897. grid.Children.Add(textBlock1);
  898. Grid.SetRow(textBlock1, i);
  899. Grid.SetColumn(textBlock1, index + location);
  900. }
  901. else
  902. {
  903. switch (item)
  904. {
  905. case "Int32":
  906. case "String":
  907. TextBox textBox = new TextBox();
  908. textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
  909. textBox.VerticalContentAlignment = VerticalAlignment.Center;
  910. if (checkbinding == null)
  911. {
  912. textBox.IsEnabled = true;
  913. }
  914. else
  915. {
  916. textBox.SetBinding(TextBox.IsEnabledProperty, checkbinding);
  917. }
  918. switch (propertyInfo.Name)
  919. {
  920. case "Gas1":
  921. var data1 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas1");
  922. TextBoxMaxValue.SetMaxValue(textBox, (int)data1.Scale);
  923. break;
  924. case "Gas2":
  925. var data2 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas2");
  926. TextBoxMaxValue.SetMaxValue(textBox, (int)data2.Scale);
  927. break;
  928. case "Gas3":
  929. var data3 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas3");
  930. break;
  931. case "Gas4":
  932. var data4 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas4");
  933. break;
  934. case "Gas5":
  935. var data5 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas5");
  936. break;
  937. case "Gas6":
  938. var data6 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas6");
  939. break;
  940. case "Gas7":
  941. var data7 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas7");
  942. break;
  943. case "Gas8":
  944. var data8 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas8");
  945. break;
  946. }
  947. textBox.SetBinding(TextBox.TextProperty, binding);
  948. grid.Children.Add(textBox);
  949. Grid.SetRow(textBox, i);
  950. Grid.SetColumn(textBox, index + location);
  951. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  952. if (objAttrs.Length > 0)
  953. {
  954. textBox.IsReadOnly = true;
  955. }
  956. break;
  957. case "Boolean":
  958. CheckBox checkBox = new CheckBox();
  959. if (checkbinding == null)
  960. {
  961. checkbinding = new Binding
  962. {
  963. Source = checkBox, // 数据源
  964. Path = new PropertyPath("IsChecked"), // 需绑定的数据源属性名
  965. Mode = BindingMode.TwoWay, // 绑定模式
  966. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  967. };
  968. }
  969. checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
  970. grid.Children.Add(checkBox);
  971. Grid.SetRow(checkBox, i);
  972. Grid.SetColumn(checkBox, index + location);
  973. break;
  974. default:
  975. ComboBox comboBox = new ComboBox();
  976. comboBox.BorderBrush = Brushes.Gray;
  977. comboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  978. if (checkbinding == null)
  979. {
  980. comboBox.IsEnabled = true;
  981. }
  982. else
  983. {
  984. comboBox.SetBinding(TextBox.IsEnabledProperty, checkbinding);
  985. }
  986. comboBox.Background = Brushes.White;
  987. string path = propertyInfo.Name;
  988. comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  989. ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
  990. grid.Children.Add(comboBox);
  991. Grid.SetRow(comboBox, i);
  992. Grid.SetColumn(comboBox, index + location);
  993. break;
  994. }
  995. }
  996. }
  997. i++;
  998. }
  999. k++;
  1000. });
  1001. //index++;
  1002. }
  1003. }
  1004. private void EPDcomboBox_DropDownOpened(object sender, EventArgs e)
  1005. {
  1006. }
  1007. private void EPDButton_Click(object sender, RoutedEventArgs e)
  1008. {
  1009. Button button = sender as Button;
  1010. string para = button.Tag.ToString();
  1011. int stepno = Convert.ToInt32(para.Split('.')[1])-1;
  1012. var endpointconfigitem = new MECF.Framework.Common.CommonData.EndPointConfigItem();
  1013. if (CurrentRecipe.Steps[stepno].EPDConfig!=null && CurrentRecipe.Steps[stepno].EPDConfig.Length>20)
  1014. {
  1015. endpointconfigitem.SetValue(CurrentRecipe.Steps[stepno].EPDConfig);
  1016. }
  1017. (new EndPointDlg(para, endpointconfigitem,CurrentRecipe)).ShowDialog();
  1018. }
  1019. private void UpdateRecipeFileList()
  1020. {
  1021. XmlDocument doc = new XmlDocument();
  1022. doc.LoadXml(GetXmlRecipeList());
  1023. treeViewRcpList.Items.Clear();
  1024. CreateTreeViewItems(doc.DocumentElement, this.treeViewRcpList);
  1025. }
  1026. private void LoadRecipe(Recipe recipe)
  1027. {
  1028. copyIndex = -1;
  1029. bodyStackPanel.Children.Clear();
  1030. //CurrentRecipe = null;
  1031. GC.Collect(); // This should pick up the control removed at a previous MouseDown
  1032. GC.WaitForPendingFinalizers(); // Doesn't help either
  1033. GC.Collect();
  1034. GC.WaitForPendingFinalizers(); // Doesn't help either
  1035. CurrentRecipe = recipe;
  1036. Grid grid = new Grid();
  1037. grid.Margin = new Thickness(15);
  1038. //index = 0;
  1039. for (int i = 0; i < recipe.Steps.Count; i++)
  1040. {
  1041. RecipeStepToGridColumn(recipe.Steps[i], grid, i, false);
  1042. }
  1043. bodyStackPanel.Children.Add(grid);
  1044. currentRecipeGrid = grid;
  1045. }
  1046. private void OnAddStep(int index)
  1047. {
  1048. if (CurrentRecipe != null)
  1049. {
  1050. RecipeStep recipeStep;
  1051. if (copyIndex == -1)
  1052. {
  1053. recipeStep = new RecipeStep();
  1054. //recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  1055. //recipeStep.LstUnit.Add(new TCPUnit());
  1056. //recipeStep.LstUnit.Add(new BiasUnit());
  1057. //recipeStep.LstUnit.Add(new GasControlUnit());
  1058. //recipeStep.LstUnit.Add(new ESCHVUnit());
  1059. //recipeStep.LstUnit.Add(new ProcessKitUnit());
  1060. switch (currentChamber)
  1061. {
  1062. case JetChamber.Venus:
  1063. case JetChamber.Kepler2300:
  1064. recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  1065. recipeStep.LstUnit.Add(new TCPUnit());
  1066. recipeStep.LstUnit.Add(new BiasUnit());
  1067. recipeStep.LstUnit.Add(new GasControlUnit());
  1068. recipeStep.LstUnit.Add(new ESCHVUnit());
  1069. recipeStep.LstUnit.Add(new ProcessKitUnit());
  1070. break;
  1071. case JetChamber.Kepler2200A:
  1072. recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  1073. recipeStep.LstUnit.Add(new HeaterUnit());
  1074. recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  1075. break;
  1076. }
  1077. CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  1078. }
  1079. else
  1080. {
  1081. var t = JsonConvert.SerializeObject(CurrentRecipe);
  1082. recipeStep = Recipe.Load(t).Steps[copyIndex - 1];
  1083. CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  1084. }
  1085. RecipeStepToGridColumn(recipeStep, currentRecipeGrid, index, true);
  1086. for (int i = 1; i <= CurrentRecipe.Steps.Count; i++)
  1087. {
  1088. CurrentRecipe.Steps[i - 1].StepNo = i;
  1089. }
  1090. }
  1091. }
  1092. private void OnDeleteStep(int index)
  1093. {
  1094. if (CurrentRecipe != null && CurrentRecipe.Steps.Count > 1)
  1095. {
  1096. CurrentRecipe.Steps.RemoveAt(index);
  1097. currentRecipeGrid.Children.RemoveRange(currentRecipeGrid.RowDefinitions.Count * (index + 1), currentRecipeGrid.RowDefinitions.Count);
  1098. currentRecipeGrid.ColumnDefinitions.RemoveAt(index);
  1099. for (int i = 1; i <= CurrentRecipe.Steps.Count; i++)
  1100. {
  1101. CurrentRecipe.Steps[i - 1].StepNo = i;
  1102. }
  1103. }
  1104. }
  1105. #endregion
  1106. }
  1107. }