RecipeViewModel.cs 66 KB

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