RecipeViewModel.cs 66 KB

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