RecipeViewModel.cs 55 KB

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