RecipeViewModel.cs 65 KB

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