RecipeViewModel.cs 66 KB

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