RecipeViewModel.cs 63 KB

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