RecipeViewModel.cs 60 KB

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