RecipeViewModel.cs 61 KB

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