NewRecipeViewModel.cs 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.IOCore;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.UI.View.Common;
  5. using MECF.Framework.Common.CommonData;
  6. using MECF.Framework.Common.DataCenter;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.Common.OperationCenter;
  9. using Microsoft.VisualBasic;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Linq;
  12. using Prism.Commands;
  13. using Prism.Mvvm;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Collections.ObjectModel;
  17. using System.IO;
  18. using System.Linq;
  19. using System.Reflection;
  20. using System.Text;
  21. using System.Threading.Tasks;
  22. using System.Windows;
  23. using System.Windows.Controls;
  24. using System.Windows.Data;
  25. using System.Windows.Input;
  26. using System.Windows.Media;
  27. using System.Xml;
  28. using Venus_Core;
  29. using Venus_Core.Attributes;
  30. using Venus_MainPages.PMs;
  31. using Venus_MainPages.Unity;
  32. using Venus_MainPages.Views;
  33. using Venus_Themes.UserControls;
  34. using WPF.Themes.UserControls;
  35. using MessageBox = System.Windows.MessageBox;
  36. using RecipeStep = Venus_Core.RecipeStep;
  37. namespace Venus_MainPages.ViewModels
  38. {
  39. internal class NewRecipeViewModel : BindableBase
  40. {
  41. #region 私有字段
  42. public string ModuleName = "PMA";
  43. private string m_CurrentRecipeName;
  44. private UiRecipeManager m_uiRecipeManager = new UiRecipeManager();
  45. private NewRecipeView recipeView;
  46. private TreeView treeViewRcpList;
  47. private Recipe m_currentRecipe;
  48. private string m_recipeType;
  49. private bool firstLoad = true;
  50. private WrapPanel headWrapPanel;
  51. private int copyIndex = -1;
  52. private List<string> EPDCfgList = new List<string>();
  53. private EPDType currentEPDType = EPDType.None;
  54. private JetChamber currentChamber;
  55. private bool isInstalledEPD;
  56. private bool m_IsFrozen;
  57. private bool m_PMAIsInstalled;
  58. private bool m_PMBIsInstalled;
  59. private bool m_PMCIsInstalled;
  60. private bool m_PMDIsInstalled;
  61. private readonly List<string> moduleList = new List<string>();
  62. TreeViewFileItem selectedItem;
  63. private string typeFolder = "";
  64. private bool m_HeadExpand = true;
  65. private Grid leftGrid;
  66. private Grid rightGrid;
  67. private readonly int controlHeight = 24;
  68. private readonly string tolerancePath = "_Tolerance_EAP";
  69. private readonly string eapPath = "_EAP";
  70. #endregion
  71. #region 属性
  72. public bool HeadExpand
  73. {
  74. get { return m_HeadExpand; }
  75. set { SetProperty(ref m_HeadExpand, value); }
  76. }
  77. public string CurrentRecipeName
  78. {
  79. get { return m_CurrentRecipeName; }
  80. set { SetProperty(ref m_CurrentRecipeName, value); }
  81. }
  82. public Recipe CurrentRecipe
  83. {
  84. get { return m_currentRecipe; }
  85. set
  86. {
  87. m_currentRecipe = value;
  88. RecipeType = m_currentRecipe?.Header?.Type.ToString();
  89. }
  90. }
  91. public string RecipeType
  92. {
  93. get { return m_recipeType; }
  94. set { SetProperty(ref m_recipeType, value); }
  95. }
  96. public bool IsFrozen
  97. {
  98. get { return m_IsFrozen; }
  99. set { SetProperty(ref m_IsFrozen, value); }
  100. }
  101. public bool PMAIsInstalled
  102. {
  103. get { return m_PMAIsInstalled; }
  104. set { SetProperty(ref m_PMAIsInstalled, value); }
  105. }
  106. public bool PMBIsInstalled
  107. {
  108. get { return m_PMBIsInstalled; }
  109. set { SetProperty(ref m_PMBIsInstalled, value); }
  110. }
  111. public bool PMCIsInstalled
  112. {
  113. get { return m_PMCIsInstalled; }
  114. set { SetProperty(ref m_PMCIsInstalled, value); }
  115. }
  116. public bool PMDIsInstalled
  117. {
  118. get { return m_PMDIsInstalled; }
  119. set { SetProperty(ref m_PMDIsInstalled, value); }
  120. }
  121. #endregion
  122. #region 命令
  123. private DelegateCommand<Object> _MouseRightButtonDownCommand;
  124. public DelegateCommand<Object> MouseRightButtonDownCommand =>
  125. _MouseRightButtonDownCommand ?? (_MouseRightButtonDownCommand = new DelegateCommand<Object>(OnMouseRightButtonDown));
  126. private DelegateCommand<Object> _LoadedCommand;
  127. public DelegateCommand<Object> LoadedCommand =>
  128. _LoadedCommand ?? (_LoadedCommand = new DelegateCommand<Object>(OnLoaded));
  129. private DelegateCommand _SaveRecipeCommand;
  130. public DelegateCommand SaveRecipeCommand =>
  131. _SaveRecipeCommand ?? (_SaveRecipeCommand = new DelegateCommand(OnSaveRecipe));
  132. private DelegateCommand<object> _SaveToRecipeCommand;
  133. public DelegateCommand<object> SaveToRecipeCommand =>
  134. _SaveToRecipeCommand ?? (_SaveToRecipeCommand = new DelegateCommand<object>(OnSaveToRecipe));
  135. private DelegateCommand _AddStepCommand;
  136. public DelegateCommand AddStepCommand =>
  137. _AddStepCommand ?? (_AddStepCommand = new DelegateCommand(OnAddStep));
  138. private DelegateCommand _DeleteStepCommand;
  139. public DelegateCommand DeleteStepCommand =>
  140. _DeleteStepCommand ?? (_DeleteStepCommand = new DelegateCommand(OnDeleteStep));
  141. private DelegateCommand _RefreshCommand;
  142. public DelegateCommand RefreshCommand =>
  143. _RefreshCommand ?? (_RefreshCommand = new DelegateCommand(OnRefresh));
  144. private DelegateCommand _ExpandCommand;
  145. public DelegateCommand ExpandCommand =>
  146. _ExpandCommand ?? (_ExpandCommand = new DelegateCommand(OnExpand));
  147. private DelegateCommand _UnloadCommand;
  148. public DelegateCommand UnloadCommand =>
  149. _UnloadCommand ?? (_UnloadCommand = new DelegateCommand(OnUnload));
  150. private DelegateCommand _ClearRecipeCommand;
  151. public DelegateCommand ClearRecipeCommand =>
  152. _ClearRecipeCommand ?? (_ClearRecipeCommand = new DelegateCommand(OnClearRecipe));
  153. private DelegateCommand<Object> _MouseLeftButtonDownCommand;
  154. public DelegateCommand<Object> MouseLeftButtonDownCommand =>
  155. _MouseLeftButtonDownCommand ?? (_MouseLeftButtonDownCommand = new DelegateCommand<Object>(OnMouseLeftButtonDown));
  156. #endregion
  157. #region 命令方法
  158. private void OnAddStep()
  159. {
  160. if (CurrentRecipe != null)
  161. {
  162. var index = rightGrid.ColumnDefinitions.Count;
  163. RecipeStep recipeStep;
  164. if (copyIndex == -1)
  165. {
  166. recipeStep = new RecipeStep();
  167. recipeStep.StepNo = index + 1;
  168. recipeStep.LstUnit = RecipeUnity.GetAllUnits(currentChamber, CurrentRecipe.Header.Type);
  169. CurrentRecipe.Steps.Add(recipeStep);
  170. }
  171. else
  172. {
  173. var t = JsonConvert.SerializeObject(CurrentRecipe);
  174. recipeStep = Recipe.Load(t).Steps[copyIndex - 1];
  175. recipeStep.StepNo = index + 1;
  176. CurrentRecipe.Steps.Add(recipeStep);
  177. }
  178. ColumnDefinition col1 = new ColumnDefinition();
  179. col1.Width = GridLength.Auto;
  180. rightGrid.ColumnDefinitions.Insert(index, col1);
  181. RecipeStepToGridColumn(recipeStep, rightGrid, index);
  182. }
  183. }
  184. private void OnDeleteStep()
  185. {
  186. if (CurrentRecipe != null)
  187. {
  188. OnDeleteStep(CurrentRecipe.Steps.Count - 1);
  189. }
  190. }
  191. private void OnSaveRecipe()
  192. {
  193. if (WPFMessageBox.ShowQuestion($"Save recipe file?", "") == MessageBoxResult.Yes)
  194. {
  195. var inLP1UseRecipe = QueryDataClient.Instance.Service.GetData($"Scheduler.LP1.InUsingRecipe");
  196. var inLP2UseRecipe = QueryDataClient.Instance.Service.GetData($"Scheduler.LP2.InUsingRecipe");
  197. var inLP3UseRecipe = QueryDataClient.Instance.Service.GetData($"Scheduler.LP3.InUsingRecipe");
  198. if (inLP1UseRecipe != null)
  199. {
  200. if ((inLP1UseRecipe as List<string>).Contains($"{ModuleName}.{CurrentRecipe.Header.Type}.{CurrentRecipeName}"))
  201. {
  202. WPFMessageBox.ShowError($"{CurrentRecipeName} Recipe is LP1 In Use,can not edit");
  203. return;
  204. }
  205. }
  206. if (inLP2UseRecipe != null)
  207. {
  208. if ((inLP2UseRecipe as List<string>).Contains($"{ModuleName}.{CurrentRecipe.Header.Type}.{CurrentRecipeName}"))
  209. {
  210. WPFMessageBox.ShowError($"{CurrentRecipeName} Recipe is LP2 In Use,can not edit");
  211. return;
  212. }
  213. }
  214. if (inLP3UseRecipe != null)
  215. {
  216. if ((inLP3UseRecipe as List<string>).Contains($"{ModuleName}.{CurrentRecipe.Header.Type}.{CurrentRecipeName}"))
  217. {
  218. WPFMessageBox.ShowError($"{CurrentRecipeName} Recipe is LP3 In Use,can not edit");
  219. return;
  220. }
  221. }
  222. }
  223. CurrentRecipe.Header.EditTime = DateTime.Now.ToString();
  224. //SaveRecipe(CurrentRecipeName, RecipeUnity.RecipeToString(CurrentRecipe));
  225. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, typeFolder, CurrentRecipeName + ".rcp");
  226. FileInfo fi = new FileInfo(newrecipePath);
  227. var di = fi.Directory;
  228. if (!di.Exists)
  229. {
  230. di.Create();
  231. }
  232. //File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(CurrentRecipe),Encoding.UTF8);
  233. string recipeContent = RecipeUnity.RecipeToString(CurrentRecipe);
  234. SaveRecipe(CurrentRecipe.Header.Name, CurrentRecipe.Header.Type.ToString(), recipeContent);
  235. //LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  236. SaveEAPRecipe(recipeContent);
  237. }
  238. private void OnSaveToRecipe(object obj)
  239. {
  240. if (CurrentRecipe == null)
  241. {
  242. return;
  243. }
  244. string moduleName = "";
  245. switch (obj.ToString())
  246. {
  247. case "0":
  248. moduleName = "PMA";
  249. break;
  250. case "1":
  251. moduleName = "PMB";
  252. break;
  253. case "2":
  254. moduleName = "PMC";
  255. break;
  256. case "3":
  257. moduleName = "PMD";
  258. break;
  259. case "4":
  260. moduleName = "ALL";
  261. break;
  262. }
  263. if (moduleName == "")
  264. {
  265. return;
  266. }
  267. if (moduleName == "ALL")
  268. {
  269. var newName = Interaction.InputBox(" ", $"Save Recipe To All", CurrentRecipeName, -1, -1);
  270. OnSaveRecipe();
  271. foreach (var x in moduleList)
  272. {
  273. if (newName != "")
  274. {
  275. var targetChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{x}.ChamberType").ToString());
  276. if (currentChamber != targetChamber || x == ModuleName)
  277. {
  278. continue;
  279. }
  280. var newRecipe = CurrentRecipe;
  281. newRecipe.Header.Name = newName;
  282. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  283. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", x, typeFolder, newName + ".rcp");
  284. FileInfo fi = new FileInfo(newrecipePath);
  285. var di = fi.Directory;
  286. if (!di.Exists)
  287. {
  288. di.Create();
  289. }
  290. //File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  291. if (m_uiRecipeManager.SaveAsRecipeWithType(x, CurrentRecipe.Header.Type.ToString(), newName, RecipeUnity.RecipeToString(newRecipe)))
  292. {
  293. UpdateRecipeFileList();
  294. }
  295. UpdateRecipeFileList();
  296. }
  297. }
  298. }
  299. else
  300. {
  301. var targetChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{moduleName}.ChamberType").ToString());
  302. if (currentChamber != targetChamber)
  303. {
  304. WPFMessageBox.ShowError($"Recipe can not from {currentChamber.ToString()} copy to {targetChamber.ToString()}");
  305. return;
  306. }
  307. var newName = Interaction.InputBox(" ", $"Save Recipe To {moduleName}", CurrentRecipeName, -1, -1);
  308. if (newName != "")
  309. {
  310. OnSaveRecipe();
  311. var newRecipe = CurrentRecipe;
  312. newRecipe.Header.Name = newName;
  313. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  314. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", moduleName, typeFolder, newName + ".rcp");
  315. FileInfo fi = new FileInfo(newrecipePath);
  316. var di = fi.Directory;
  317. if (!di.Exists)
  318. {
  319. di.Create();
  320. }
  321. //File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  322. if (m_uiRecipeManager.SaveAsRecipeWithType(moduleName, CurrentRecipe.Header.Type.ToString(), newName, RecipeUnity.RecipeToString(newRecipe)))
  323. {
  324. UpdateRecipeFileList();
  325. }
  326. //if (SaveAsRecipeWithType(newName, CurrentRecipe.Header.Type.ToString(), RecipeUnity.RecipeToString(newRecipe)))
  327. //{
  328. //}
  329. }
  330. }
  331. }
  332. private async void OnLoaded(Object myrecipeView)
  333. {
  334. if (firstLoad == true)
  335. {
  336. currentChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.ChamberType").ToString());
  337. if (currentChamber != JetChamber.Kepler2200A && currentChamber != JetChamber.Kepler2200B)
  338. {
  339. isInstalledEPD = bool.Parse(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.EPD.IsEnabled").ToString());
  340. }
  341. firstLoad = false;
  342. recipeView = myrecipeView as NewRecipeView;
  343. treeViewRcpList = recipeView.treeViewRcpList;
  344. headWrapPanel = recipeView.headWrapPanel;
  345. //bodyStackPanel = recipeView.bodyStackPanel;
  346. leftGrid = recipeView.leftGrid;
  347. rightGrid = recipeView.rightGrid;
  348. UpdateRecipeFileList();
  349. treeViewRcpList.SelectedItemChanged += TreeViewRcpList_SelectedItemChanged;
  350. string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();
  351. if (allModules.Contains("PMA"))
  352. {
  353. PMAIsInstalled = true;
  354. moduleList.Add("PMA");
  355. }
  356. if (allModules.Contains("PMB"))
  357. {
  358. PMBIsInstalled = true;
  359. moduleList.Add("PMB");
  360. }
  361. if (allModules.Contains("PMC"))
  362. {
  363. PMCIsInstalled = true;
  364. moduleList.Add("PMC");
  365. }
  366. if (allModules.Contains("PMD"))
  367. {
  368. PMDIsInstalled = true;
  369. moduleList.Add("PMD");
  370. }
  371. }
  372. if (isInstalledEPD)
  373. {
  374. for (int i = 0; i < 5; i++)
  375. {
  376. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.EndPoint.SearchCfg");
  377. await Task.Delay(200);
  378. currentEPDType = (EPDType)System.Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.EPD.EPDType"));
  379. if (currentEPDType == EPDType.Socket)
  380. {
  381. EPDCfgList = (List<string>)QueryDataClient.Instance.Service.GetData($"{ModuleName}.EPDCfgList");
  382. }
  383. if (EPDCfgList != null)
  384. {
  385. EPDCfgList.Add("");
  386. break;
  387. }
  388. }
  389. }
  390. UpdateRecipeFileList();
  391. }
  392. private void TreeViewRcpList_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  393. {
  394. //rightGrid.Visibility = Visibility.Visible;
  395. selectedItem = e.NewValue as TreeViewFileItem;
  396. if (selectedItem == null)
  397. return;
  398. try
  399. {
  400. string[] info = selectedItem.FileName.Split('\\');
  401. //string path;
  402. string xmlRecipeData = "";
  403. if (info.Length == 1)
  404. {
  405. CurrentRecipeName = info[0];
  406. typeFolder = "";
  407. string path = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, $"{CurrentRecipeName}.rcp");
  408. xmlRecipeData = m_uiRecipeManager.LoadRecipeByPath(path);
  409. }
  410. else if (info.Length == 2)
  411. {
  412. string type = info[0];
  413. typeFolder = type;
  414. CurrentRecipeName = info[1];
  415. string path = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, type, $"{CurrentRecipeName}.rcp");
  416. xmlRecipeData = m_uiRecipeManager.LoadRecipeByPath(path);
  417. }
  418. else
  419. {
  420. return;
  421. }
  422. if (xmlRecipeData == "")
  423. {
  424. treeViewRcpList.Items.Remove(selectedItem);
  425. return;
  426. }
  427. CurrentRecipe = Recipe.Load(xmlRecipeData);
  428. if (CurrentRecipe.Header.ChamberType != currentChamber)
  429. {
  430. WPFMessageBox.ShowError($"Can not Open {CurrentRecipe.Header.ChamberType} Recipe in {currentChamber} Chamber,please delete it.");
  431. return;
  432. }
  433. LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  434. LoadRecipe(CurrentRecipe);
  435. }
  436. catch (Exception ex)
  437. {
  438. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), ex.Message), Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
  439. }
  440. e.Handled = true;
  441. }
  442. public bool SaveRecipe(string recipeName, string type, string recipeContent)
  443. {
  444. return m_uiRecipeManager.SaveRecipeWithType(ModuleName, type, recipeName, recipeContent);
  445. }
  446. private void OnMouseRightButtonDown(Object treeView)
  447. {
  448. //treeViewRcpList = treeView as TreeView;
  449. treeViewRcpList.ContextMenu = new ContextMenu() { Background = new SolidColorBrush(Colors.AliceBlue) };
  450. MenuItem menuItem = new MenuItem();
  451. menuItem = new MenuItem();
  452. menuItem.Tag = "\\";
  453. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_CreateRecipe);
  454. menuItem.Header = "New Recipe";
  455. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  456. menuItem = new MenuItem();
  457. menuItem.Tag = "\\";
  458. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_DeleteRecipe);
  459. menuItem.Header = "Delete Recipe";
  460. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  461. menuItem = new MenuItem();
  462. menuItem.Tag = "\\";
  463. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_SaveAsRecipe);
  464. menuItem.Header = "Save As Recipe";
  465. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  466. menuItem = new MenuItem();
  467. menuItem.Tag = "\\";
  468. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_RenameRecipe);
  469. menuItem.Header = "Rename";
  470. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  471. treeViewRcpList.ContextMenu.Visibility = Visibility.Visible;
  472. }
  473. private void OnMouseLeftButtonDown(Object treeView)
  474. {
  475. //treeViewRcpList = treeView as TreeView;
  476. }
  477. private void menuItem_MouseClick_CreateRecipe(object sender, RoutedEventArgs e)
  478. {
  479. MenuItem mit = sender as MenuItem;
  480. string folderName = mit.Tag as string;
  481. PerformCreateRecipe(folderName);
  482. }
  483. private void PerformCreateRecipe(string folderName)
  484. {
  485. try
  486. {
  487. bool hasHV = false;
  488. if (currentChamber == JetChamber.VenusSE || currentChamber == JetChamber.VenusDE)
  489. {
  490. hasHV = true;
  491. }
  492. RecipeNameInputDlg dlg = new RecipeNameInputDlg(Application.Current.Resources["GlobalLableMsgInputRecipeName"].ToString(), hasHV)
  493. {
  494. Owner = Application.Current.MainWindow
  495. };
  496. if (dlg.ShowDialog() == true)
  497. {
  498. var recipeName = dlg.InputText;
  499. //var recipeName = folderName + dlg.InputText;
  500. //var recipeName = folderName + "\\" + dlg.InputText;
  501. if (!RecipeNameIsOk(recipeName))
  502. {
  503. return;
  504. }
  505. RecipeType type = (RecipeType)Enum.Parse(typeof(RecipeType), dlg.SelectedType);
  506. string newRecipe = RecipeUnity.CreateRecipe(currentChamber, type, dlg.InputText);
  507. if (SaveAsRecipeWithType(recipeName, type.ToString(), newRecipe))
  508. {
  509. UpdateRecipeFileList();
  510. }
  511. SaveEAPRecipe(newRecipe);
  512. }
  513. }
  514. catch (Exception ex)
  515. {
  516. LOG.WriteExeption(ex);
  517. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableMsgRecipeCreateException"].ToString(), ex.Message), Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
  518. }
  519. }
  520. private void menuItem_MouseClick_DeleteRecipe(object sender, RoutedEventArgs e)
  521. {
  522. //if (CurrentRecipe == null)
  523. //{
  524. // return;
  525. //}
  526. if (WPFMessageBox.ShowQuestion($"Delete {typeFolder}Recipe {CurrentRecipeName}?", "删除后无法恢复!!!") == MessageBoxResult.Yes)
  527. {
  528. //MenuItem mit = sender as MenuItem;
  529. //string recipename = mit.Header.ToString();
  530. string path = typeFolder == "" ? CurrentRecipeName : $"{typeFolder}\\{CurrentRecipeName}";
  531. m_uiRecipeManager.DeleteRecipe(ModuleName, path);
  532. DeleteEAPRecipe();
  533. DeleteToleranceRecipe();
  534. //PerformCreateRecipe(folderName);
  535. //treeViewRcpList.Items.Remove(selectedItem);
  536. UpdateRecipeFileList();
  537. }
  538. }
  539. private void menuItem_MouseClick_SaveAsRecipe(object sender, RoutedEventArgs e)
  540. {
  541. if (CurrentRecipe == null)
  542. {
  543. return;
  544. }
  545. var newName = Interaction.InputBox(" ", "Save As Recipe", CurrentRecipeName, -1, -1);
  546. if (!RecipeNameIsOk(newName))
  547. {
  548. return;
  549. }
  550. //newName = newName.Trim();
  551. if (newName != CurrentRecipeName && newName != "")
  552. {
  553. var newRecipe = CurrentRecipe;
  554. if (WPFMessageBox.ShowQuestion($"Save recipe file {newName} ?", "") == MessageBoxResult.Yes)
  555. {
  556. //MessageBox.Show($"Save as recipe {newName} ?", "Save As Recipe", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
  557. newRecipe.Header.Name = newName;
  558. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  559. //var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, typeFolder, newName + ".rcp");
  560. //File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  561. if (SaveAsRecipeWithType(newName, CurrentRecipe.Header.Type.ToString(), RecipeUnity.RecipeToString(newRecipe)))
  562. {
  563. UpdateRecipeFileList();
  564. CurrentRecipeName = newName;
  565. //LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  566. LoadRecipe(CurrentRecipe);
  567. }
  568. }
  569. }
  570. else if (newName == CurrentRecipeName || newName == "")
  571. {
  572. WPFMessageBox.Show("Please input right recipename", MessageBoxButton.OK);
  573. }
  574. }
  575. private void menuItem_MouseClick_RenameRecipe(object sender, RoutedEventArgs e)
  576. {
  577. if (CurrentRecipe == null)
  578. {
  579. return;
  580. }
  581. var newName = Interaction.InputBox(" ", "Rename Recipe", CurrentRecipeName, -1, -1);
  582. //newName = newName.Trim();
  583. if (!RecipeNameIsOk(newName))
  584. {
  585. return;
  586. }
  587. if (newName != CurrentRecipeName && newName != "")
  588. {
  589. var newRecipe = CurrentRecipe;
  590. if (WPFMessageBox.ShowQuestion($"Save recipe file {newName} ?", "") == MessageBoxResult.Yes)
  591. {
  592. newRecipe.Header.Name = newName;
  593. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  594. var oldrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, typeFolder, CurrentRecipeName + ".rcp");
  595. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, typeFolder, newName + ".rcp");
  596. File.Delete(oldrecipePath);
  597. File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  598. UpdateRecipeFileList();
  599. }
  600. }
  601. else if (newName == CurrentRecipeName || newName == "")
  602. {
  603. WPFMessageBox.Show("Please input right recipename", MessageBoxButton.OK);
  604. }
  605. }
  606. public bool SaveAsRecipeWithType(string recipeName, string type, string recipeContent)
  607. {
  608. return m_uiRecipeManager.SaveAsRecipeWithType(ModuleName, type, recipeName, recipeContent);
  609. }
  610. public string GetXmlRecipeList()
  611. {
  612. return m_uiRecipeManager.GetXmlRecipeList(ModuleName, true) ?? "";
  613. }
  614. void CreateTreeViewItems(XmlElement curElementNode, ItemsControl itemsControl)
  615. {
  616. foreach (XmlElement ele in curElementNode.ChildNodes)
  617. {
  618. if (ele.Name == "File")
  619. {
  620. string fileName = ele.Attributes["Name"].Value;
  621. fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
  622. TreeViewFileItem item = new TreeViewFileItem(ele.Attributes["Name"].Value);
  623. item.Tag = ele.Attributes["Name"].Value;
  624. if (!item.Tag.ToString().Contains("\\"))
  625. {
  626. continue;
  627. }
  628. itemsControl.Items.Add(item);
  629. }
  630. else if (ele.Name == "Folder")
  631. {
  632. string folderName = ele.Attributes["Name"].Value;
  633. folderName = folderName.Substring(folderName.LastIndexOf('\\') + 1);
  634. if (folderName == Venus_Core.RecipeType.Process.ToString() || folderName == Venus_Core.RecipeType.Clean.ToString() || folderName == Venus_Core.RecipeType.Chuck.ToString() || folderName == Venus_Core.RecipeType.DeChuck.ToString())
  635. {
  636. TreeViewFolderItem item = new TreeViewFolderItem(folderName);
  637. item.Tag = ele.Attributes["Name"].Value;
  638. CreateTreeViewItems(ele, item);
  639. item.IsExpanded = false;
  640. itemsControl.Items.Add(item);
  641. }
  642. }
  643. }
  644. }
  645. private IEnumerable<string> GetFilesNames(string path)
  646. {
  647. if (Directory.Exists(path))
  648. {
  649. return Directory.GetFiles(path, "*.rcp")?
  650. .Select(Path.GetFileNameWithoutExtension);
  651. }
  652. else
  653. {
  654. return new List<string>();
  655. }
  656. }
  657. private void LoadHeadWrapPanel(WrapPanel HeadWrapPanel, Recipe recipe)
  658. {
  659. HeadWrapPanel.Children.Clear();
  660. Type type = recipe.Header.GetType();
  661. foreach (var propertyInfo in type.GetProperties())
  662. {
  663. TextBlock textBlock = new TextBlock();
  664. textBlock.FontSize = 16;
  665. textBlock.Margin = new Thickness(0, 20, 0, 0);
  666. textBlock.Width = 200;
  667. switch (propertyInfo.Name)
  668. {
  669. case "ChuckRecipe":
  670. if (currentChamber != JetChamber.VenusSE && currentChamber != JetChamber.VenusDE)
  671. {
  672. continue;
  673. }
  674. textBlock.Text = "Chuck:";
  675. break;
  676. case "DechuckRecipe":
  677. if (currentChamber != JetChamber.VenusSE && currentChamber != JetChamber.VenusDE)
  678. {
  679. continue;
  680. }
  681. textBlock.Text = "DeChuck:";
  682. break;
  683. case "WallTemperature":
  684. if (currentChamber != JetChamber.VenusSE && currentChamber != JetChamber.VenusDE)
  685. {
  686. continue;
  687. }
  688. break;
  689. case "BiasRFHoldTime":
  690. if (currentChamber != JetChamber.VenusSE && currentChamber != JetChamber.VenusDE && currentChamber != JetChamber.Kepler2300)
  691. {
  692. continue;
  693. }
  694. break;
  695. default:
  696. object[] NameAttrs = propertyInfo.GetCustomAttributes(typeof(CustomName), true);
  697. string name;
  698. if (NameAttrs.Length > 0)
  699. {
  700. name = (NameAttrs[0] as CustomName).Name;
  701. }
  702. else
  703. {
  704. name = propertyInfo.Name;
  705. }
  706. textBlock.Text = name + ":";
  707. break;
  708. }
  709. textBlock.Margin = new Thickness(15, 0, 0, 0);
  710. textBlock.VerticalAlignment = VerticalAlignment.Center;
  711. HeadWrapPanel.Children.Add(textBlock);
  712. Binding binding = new Binding()
  713. {
  714. Source = recipe.Header, // 数据源
  715. Path = new PropertyPath(propertyInfo.Name), // 需绑定的数据源属性名
  716. Mode = BindingMode.TwoWay, // 绑定模式
  717. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, //触发器
  718. };
  719. var propertyTypeName = propertyInfo.PropertyType.Name;
  720. var propertyInfoName = propertyInfo.Name;
  721. Control control = new Control();
  722. switch (propertyInfoName)
  723. {
  724. //case "ChamberType":
  725. // control = new ComboBox();
  726. // control.IsEnabled = false;
  727. // //control.Height = 23;
  728. // control.SetBinding(ComboBox.SelectedItemProperty, binding);
  729. // control.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  730. // ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  731. // break;
  732. //case "Type":
  733. // ComboBox cb = new ComboBox();
  734. // cb.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  735. // cb.IsEnabled = false;
  736. // cb.SelectionChanged += ChangeUI;
  737. // control = cb;
  738. // //control.Height = 23;
  739. // ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  740. // control.SetBinding(ComboBox.SelectedItemProperty, binding);
  741. // break;
  742. case "ChuckRecipe":
  743. StringBuilder stringBuilder = new StringBuilder();
  744. control = new ComboBox()
  745. {
  746. ItemsSource = GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", $"{ModuleName}\\Chuck"))
  747. };
  748. //control.Height = 23;
  749. control.MinWidth = 100;
  750. control.MaxWidth = 300;
  751. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  752. control.PreviewMouseLeftButtonDown += ChuckControl_PreviewMouseLeftButtonDown;
  753. break;
  754. case "DechuckRecipe":
  755. //if (currentChamber != JetChamber.Venus)
  756. //{
  757. // continue;
  758. //}
  759. //string[] dechucklist = new string[] { "" };
  760. //ArrayList dearrayList = new ArrayList(dechucklist.ToList());
  761. //IEnumerable<string> delist = GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName)).ToList().Where(item => item.ToLower().Contains("dechuck"));
  762. //foreach (var i in delist)
  763. //{
  764. // dearrayList.Add(i);
  765. //}
  766. //dechucklist = (string[])dearrayList.ToArray(typeof(string));
  767. //StringBuilder destringBuilder = new StringBuilder();
  768. //for (int i = 0; i < dechucklist.Length; i++)
  769. //{
  770. // destringBuilder.Append(dechucklist[i] + "\t");
  771. //}
  772. control = new ComboBox()
  773. {
  774. ItemsSource = GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", $"{ModuleName}\\DeChuck"))
  775. };
  776. //control.Height = 23;
  777. control.MinWidth = 100;
  778. control.MaxWidth = 300;
  779. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  780. control.PreviewMouseLeftButtonDown += DechuckControl_PreviewMouseLeftButtonDown;
  781. break;
  782. case "IsShowTolerance":
  783. control = new CheckBox();
  784. control.SetBinding(CheckBox.IsCheckedProperty, binding);
  785. control.Style = null;
  786. control.VerticalAlignment = VerticalAlignment.Center;
  787. (control as CheckBox).Checked += RecipeViewModel_Checked;
  788. (control as CheckBox).Unchecked += RecipeViewModel_Checked;
  789. break;
  790. default:
  791. control = new TextBox();
  792. control.Margin = new Thickness(1, 0, 0, 0);
  793. control.BorderThickness = new Thickness(0, 0, 0, 1);
  794. control.BorderBrush = Brushes.White;
  795. control.FontSize = 15;
  796. control.Foreground = Brushes.Green;
  797. control.Background = Brushes.Transparent;
  798. control.VerticalAlignment = VerticalAlignment.Center;
  799. control.MinWidth = 15;
  800. control.SetBinding(TextBox.TextProperty, binding);
  801. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  802. if (objAttrs.Length > 0)
  803. {
  804. (control as TextBox).IsReadOnly = true;
  805. }
  806. break;
  807. }
  808. control.Margin = new Thickness(20, 3, 0, 7);
  809. control.Width = 250;
  810. HeadWrapPanel.Children.Add(control);
  811. }
  812. }
  813. private void RecipeViewModel_Checked(object sender, RoutedEventArgs e)
  814. {
  815. LoadRecipe(CurrentRecipe);
  816. }
  817. private void ChuckControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  818. {
  819. var items = GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", $"{ModuleName}\\Chuck")).ToList();
  820. items.Add("");
  821. (sender as ComboBox).ItemsSource = items;
  822. }
  823. private void DechuckControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  824. {
  825. var items = GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", $"{ModuleName}\\DeChuck")).ToList();
  826. items.Add("");
  827. (sender as ComboBox).ItemsSource = items;
  828. }
  829. private void ChangeUI(object sender, SelectionChangedEventArgs e)
  830. {
  831. var t = sender as ComboBox;
  832. if (t.SelectedValue.ToString() != "Process")
  833. {
  834. headWrapPanel.Children[8].Visibility = Visibility.Collapsed;
  835. headWrapPanel.Children[9].Visibility = Visibility.Collapsed;
  836. headWrapPanel.Children[10].Visibility = Visibility.Collapsed;
  837. headWrapPanel.Children[11].Visibility = Visibility.Collapsed;
  838. }
  839. else
  840. {
  841. headWrapPanel.Children[8].Visibility = Visibility.Visible;
  842. headWrapPanel.Children[9].Visibility = Visibility.Visible;
  843. headWrapPanel.Children[10].Visibility = Visibility.Visible;
  844. headWrapPanel.Children[11].Visibility = Visibility.Visible;
  845. }
  846. }
  847. private void MenuItemLeftInsert_Click(object sender, RoutedEventArgs e)
  848. {
  849. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  850. int insertIndex = Convert.ToInt32(t.Text)-1;
  851. RecipeStep recipeStep;
  852. if (copyIndex == -1)
  853. {
  854. recipeStep = new RecipeStep();
  855. recipeStep.LstUnit = RecipeUnity.GetAllUnits(currentChamber, CurrentRecipe.Header.Type);
  856. CurrentRecipe.Steps.Insert(insertIndex, recipeStep);
  857. }
  858. else
  859. {
  860. var t1 = JsonConvert.SerializeObject(CurrentRecipe);
  861. recipeStep = Recipe.Load(t1).Steps[copyIndex - 1];
  862. CurrentRecipe.Steps.Insert(insertIndex, recipeStep);
  863. }
  864. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  865. {
  866. CurrentRecipe.Steps[i].StepNo = i + 1;
  867. }
  868. ColumnDefinition col1 = new ColumnDefinition();
  869. col1.Width = GridLength.Auto;
  870. rightGrid.ColumnDefinitions.Add(col1);
  871. for (int i = 0; i < rightGrid.Children.Count; i++)
  872. {
  873. if (Grid.GetColumn(rightGrid.Children[i]) >= insertIndex)
  874. {
  875. Grid.SetColumn(rightGrid.Children[i], Grid.GetColumn(rightGrid.Children[i])+1);
  876. }
  877. }
  878. RecipeStepToGridColumn(recipeStep, rightGrid, insertIndex);
  879. }
  880. private void MenuItemRightInsert_Click(object sender, RoutedEventArgs e)
  881. {
  882. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  883. int insertIndex = Convert.ToInt32(t.Text);
  884. RecipeStep recipeStep;
  885. if (copyIndex == -1)
  886. {
  887. recipeStep = new RecipeStep();
  888. recipeStep.LstUnit = RecipeUnity.GetAllUnits(currentChamber, CurrentRecipe.Header.Type);
  889. CurrentRecipe.Steps.Insert(insertIndex, recipeStep);
  890. }
  891. else
  892. {
  893. var t1 = JsonConvert.SerializeObject(CurrentRecipe);
  894. recipeStep = Recipe.Load(t1).Steps[copyIndex - 1];
  895. CurrentRecipe.Steps.Insert(insertIndex, recipeStep);
  896. }
  897. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  898. {
  899. CurrentRecipe.Steps[i].StepNo = i + 1;
  900. }
  901. ColumnDefinition col1 = new ColumnDefinition();
  902. col1.Width = GridLength.Auto;
  903. rightGrid.ColumnDefinitions.Add(col1);
  904. for (int i = 0; i < rightGrid.Children.Count; i++)
  905. {
  906. if (Grid.GetColumn(rightGrid.Children[i]) >= insertIndex)
  907. {
  908. Grid.SetColumn(rightGrid.Children[i], Grid.GetColumn(rightGrid.Children[i]) + 1);
  909. }
  910. }
  911. RecipeStepToGridColumn(recipeStep, rightGrid, insertIndex);
  912. }
  913. private void MenuItemDelete_Click(object sender, RoutedEventArgs e)
  914. {
  915. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  916. int deleteIndex = Convert.ToInt32(t.Text)-1;
  917. CurrentRecipe.Steps.RemoveAt(deleteIndex);
  918. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  919. {
  920. CurrentRecipe.Steps[i].StepNo = i + 1;
  921. }
  922. RemoveColumnFromGrid(rightGrid, deleteIndex);
  923. rightGrid.ColumnDefinitions.RemoveAt(deleteIndex);
  924. for (int i = 0; i < rightGrid.Children.Count; i++)
  925. {
  926. if (Grid.GetColumn(rightGrid.Children[i]) >= deleteIndex)
  927. {
  928. Grid.SetColumn(rightGrid.Children[i], Grid.GetColumn(rightGrid.Children[i]) - 1);
  929. }
  930. }
  931. }
  932. private void MenuItemCopy_Click(object sender, RoutedEventArgs e)
  933. {
  934. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  935. copyIndex = Convert.ToInt32(t.Text);
  936. }
  937. #endregion
  938. #region 私有方法
  939. private void RecipeStepToGridColumn(RecipeStep recipeStep, Grid grid, int columnIndex)
  940. {
  941. Type recipeType = recipeStep.GetType();
  942. int rowIndex = 0;
  943. foreach (PropertyInfo propertyInfo in recipeType.GetProperties())
  944. {
  945. string propertyInfoName = propertyInfo.Name;
  946. string propertyTypeName = propertyInfo.PropertyType.Name;
  947. if (propertyInfoName != "LstUnit")
  948. {
  949. if ((propertyInfoName == "EPDConfig" || propertyInfoName == "MinEndPointTime" || propertyInfoName == "MaxEndPointTime" || propertyInfoName == "OverEtchPercent") && isInstalledEPD == false)
  950. {
  951. continue;
  952. }
  953. if (columnIndex == 0)
  954. {
  955. RowDefinition row1 = new RowDefinition();
  956. row1.Height = new GridLength(controlHeight);
  957. grid.RowDefinitions.Add(row1);
  958. }
  959. Binding binding = new Binding()
  960. {
  961. Source = recipeStep, // 数据源
  962. Path = new PropertyPath(propertyInfoName), // 需绑定的数据源属性名
  963. Mode = BindingMode.TwoWay, // 绑定模式
  964. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  965. };
  966. switch (propertyTypeName)
  967. {
  968. case "Int32":
  969. case "String":
  970. case "Single":
  971. case "Double":
  972. if (propertyInfoName == "EPDConfig")
  973. {
  974. if (currentEPDType == EPDType.Socket)
  975. {
  976. ComboBox EPDcomboBox = new ComboBox();
  977. EPDcomboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  978. EPDcomboBox.Background = new SolidColorBrush(Colors.Black);
  979. EPDcomboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  980. EPDcomboBox.ItemsSource = EPDCfgList;
  981. grid.Children.Add(EPDcomboBox);
  982. Grid.SetRow(EPDcomboBox, rowIndex);
  983. Grid.SetColumn(EPDcomboBox, columnIndex);
  984. }
  985. else if (currentEPDType == EPDType.WCF)
  986. {
  987. Button EPDButton = new Button();
  988. EPDButton.Content = "EndPoint";
  989. EPDButton.Cursor = Cursors.Hand;
  990. EPDButton.Tag = $"{CurrentRecipeName}.{(columnIndex).ToString()}";
  991. EPDButton.Style = null;
  992. EPDButton.Click += EPDButton_Click;
  993. grid.Children.Add(EPDButton);
  994. Grid.SetRow(EPDButton, rowIndex);
  995. Grid.SetColumn(EPDButton, columnIndex);
  996. }
  997. break;
  998. }
  999. TextBox textBox = new TextBox();
  1000. textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
  1001. textBox.VerticalContentAlignment = VerticalAlignment.Center;
  1002. textBox.SetBinding(TextBox.TextProperty, binding);
  1003. grid.Children.Add(textBox);
  1004. Grid.SetRow(textBox, rowIndex);
  1005. Grid.SetColumn(textBox, columnIndex);
  1006. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  1007. if (objAttrs.Length > 0)
  1008. {
  1009. textBox.IsReadOnly = true;
  1010. ContextMenu contextmenu = new ContextMenu();
  1011. textBox.ContextMenu = contextmenu;
  1012. MenuItem menuItemDelete = new MenuItem();
  1013. menuItemDelete.Header = "Delete";
  1014. menuItemDelete.Click += MenuItemDelete_Click;
  1015. MenuItem menuItemLeftInsert = new MenuItem();
  1016. menuItemLeftInsert.Header = "Left Insert";
  1017. menuItemLeftInsert.Click += MenuItemLeftInsert_Click;
  1018. MenuItem menuItemRightInsert = new MenuItem();
  1019. menuItemRightInsert.Header = "Right Insert";
  1020. menuItemRightInsert.Click += MenuItemRightInsert_Click;
  1021. MenuItem menuItemCopy = new MenuItem();
  1022. menuItemCopy.Tag = textBox.Text;
  1023. menuItemCopy.Header = "Copy";
  1024. menuItemCopy.Click += MenuItemCopy_Click;
  1025. contextmenu.Items.Add(menuItemCopy);
  1026. contextmenu.Items.Add(menuItemDelete);
  1027. contextmenu.Items.Add(menuItemLeftInsert);
  1028. contextmenu.Items.Add(menuItemRightInsert);
  1029. }
  1030. break;
  1031. case "Boolean":
  1032. CheckBox checkBox = new CheckBox();
  1033. checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
  1034. grid.Children.Add(checkBox);
  1035. Grid.SetRow(checkBox, rowIndex);
  1036. Grid.SetColumn(checkBox, columnIndex);
  1037. break;
  1038. default:
  1039. ComboBox comboBox = new ComboBox();
  1040. comboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  1041. comboBox.Background = new SolidColorBrush(Colors.Black);
  1042. comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  1043. ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
  1044. grid.Children.Add(comboBox);
  1045. Grid.SetRow(comboBox, rowIndex);
  1046. Grid.SetColumn(comboBox, columnIndex);
  1047. break;
  1048. }
  1049. rowIndex++;
  1050. }
  1051. }
  1052. int unitIndex = 0;
  1053. foreach (var x in recipeStep.LstUnit.ToList())
  1054. {
  1055. Type unitType = x.GetType();
  1056. Binding checkbinding = null;
  1057. foreach (PropertyInfo propertyInfo in unitType.GetProperties())
  1058. {
  1059. object[] IgnoreAttrs = propertyInfo.GetCustomAttributes(typeof(IsCanConfigIgnore), true);
  1060. bool IsEnableRecipeExtension = Convert.ToBoolean(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.IsEnableRecipeExtension"));
  1061. if (IgnoreAttrs.Length > 0 && IsEnableRecipeExtension == false)
  1062. {
  1063. break;
  1064. }
  1065. object[] toleranceAttrs = propertyInfo.GetCustomAttributes(typeof(IsTolerance), true);
  1066. if (toleranceAttrs.Length > 0 && CurrentRecipe.Header.IsShowTolerance == false)
  1067. {
  1068. continue;
  1069. }
  1070. if (propertyInfo.Name == "UnitName")
  1071. {
  1072. continue;
  1073. }
  1074. if (columnIndex == 0)
  1075. {
  1076. RowDefinition row1 = new RowDefinition();
  1077. row1.Height = new GridLength(controlHeight);
  1078. grid.RowDefinitions.Add(row1);
  1079. }
  1080. Binding binding = new Binding()
  1081. {
  1082. Source = recipeStep.LstUnit[unitIndex], // 数据源
  1083. //Path = new PropertyPath($"LstUnit[{k}]." + propertyInfo.Name), // 需绑定的数据源属性名
  1084. Path = new PropertyPath(propertyInfo.Name), // 需绑定的数据源属性名
  1085. Mode = BindingMode.TwoWay, // 绑定模式
  1086. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  1087. };
  1088. var item = propertyInfo.PropertyType.Name;
  1089. switch (item)
  1090. {
  1091. case "Int32":
  1092. case "String":
  1093. case "Single":
  1094. case "Double":
  1095. TextBox textBox = new TextBox();
  1096. textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
  1097. textBox.VerticalContentAlignment = VerticalAlignment.Center;
  1098. if (checkbinding == null)
  1099. {
  1100. textBox.IsEnabled = true;
  1101. }
  1102. else
  1103. {
  1104. textBox.SetBinding(TextBox.IsEnabledProperty, checkbinding);
  1105. }
  1106. textBox.SetBinding(TextBox.TextProperty, binding);
  1107. grid.Children.Add(textBox);
  1108. Grid.SetRow(textBox, rowIndex);
  1109. Grid.SetColumn(textBox, columnIndex);
  1110. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  1111. if (objAttrs.Length > 0)
  1112. {
  1113. textBox.IsReadOnly = true;
  1114. }
  1115. break;
  1116. case "Boolean":
  1117. CheckBox checkBox = new CheckBox();
  1118. if (checkbinding == null)
  1119. {
  1120. checkbinding = new Binding
  1121. {
  1122. Source = checkBox, // 数据源
  1123. Path = new PropertyPath("IsChecked"), // 需绑定的数据源属性名
  1124. Mode = BindingMode.TwoWay, // 绑定模式
  1125. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  1126. };
  1127. }
  1128. checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
  1129. grid.Children.Add(checkBox);
  1130. Grid.SetRow(checkBox, rowIndex);
  1131. Grid.SetColumn(checkBox, columnIndex);
  1132. break;
  1133. default:
  1134. //if (checkbinding != null)
  1135. //{
  1136. // break;
  1137. //}
  1138. ComboBox comboBox = new ComboBox();
  1139. comboBox.BorderBrush = Brushes.Gray;
  1140. comboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  1141. if (checkbinding == null)
  1142. {
  1143. comboBox.IsEnabled = true;
  1144. }
  1145. else
  1146. {
  1147. comboBox.SetBinding(TextBox.IsEnabledProperty, checkbinding);
  1148. }
  1149. comboBox.Background = Brushes.White;
  1150. string path = propertyInfo.Name;
  1151. comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  1152. ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
  1153. grid.Children.Add(comboBox);
  1154. Grid.SetRow(comboBox, rowIndex);
  1155. Grid.SetColumn(comboBox, columnIndex);
  1156. break;
  1157. }
  1158. rowIndex++;
  1159. }
  1160. unitIndex++;
  1161. }
  1162. }
  1163. private void RecipeStepToGridColumnOnlyTitle(RecipeStep recipeStep, Grid grid)
  1164. {
  1165. Type recipeType = recipeStep.GetType();
  1166. int i = 0;
  1167. ColumnDefinition col1 = new ColumnDefinition();
  1168. grid.ColumnDefinitions.Add(col1);
  1169. foreach (PropertyInfo propertyInfo in recipeType.GetProperties())
  1170. {
  1171. string propertyInfoName = propertyInfo.Name;
  1172. string propertyTypeName = propertyInfo.PropertyType.Name;
  1173. if (propertyInfoName != "LstUnit")
  1174. {
  1175. if ((propertyInfoName == "EPDConfig" || propertyInfoName == "MinEndPointTime" || propertyInfoName == "MaxEndPointTime" || propertyInfoName == "OverEtchPercent") && isInstalledEPD == false)
  1176. {
  1177. continue;
  1178. }
  1179. RowDefinition row1 = new RowDefinition();
  1180. row1.Height = new GridLength(controlHeight);
  1181. grid.RowDefinitions.Add(row1);
  1182. Border border = new Border();
  1183. TextBlock textBlock = new TextBlock();
  1184. textBlock.Padding = new Thickness(5, 3, 0, 0);
  1185. border.Child = textBlock;
  1186. border.BorderBrush = Brushes.Silver;
  1187. border.BorderThickness = new Thickness(1);
  1188. //textBlock.IsReadOnly = true;
  1189. object[] NameAttrs = propertyInfo.GetCustomAttributes(typeof(CustomName), true);
  1190. string name;
  1191. if (NameAttrs.Length > 0)
  1192. {
  1193. name = (NameAttrs[0] as CustomName).Name;
  1194. }
  1195. else
  1196. {
  1197. name = propertyInfo.Name;
  1198. }
  1199. textBlock.Text = name;
  1200. //textBlock.FontSize = 15;
  1201. grid.Children.Add(border);
  1202. border.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FAFAFA"));
  1203. Grid.SetRow(border, i);
  1204. Grid.SetColumn(border, 0);
  1205. i++;
  1206. }
  1207. }
  1208. foreach (var x in recipeStep.LstUnit.ToList())
  1209. {
  1210. Type unitType = x.GetType();
  1211. bool isUnitFirstRow = true;
  1212. foreach (PropertyInfo propertyInfo in unitType.GetProperties())
  1213. {
  1214. object[] IgnoreAttrs = propertyInfo.GetCustomAttributes(typeof(IsCanConfigIgnore), true);
  1215. bool IsEnableRecipeExtension = Convert.ToBoolean(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.IsEnableRecipeExtension"));
  1216. if (IgnoreAttrs.Length > 0 && IsEnableRecipeExtension == false)
  1217. {
  1218. break;
  1219. }
  1220. object[] toleranceAttrs = propertyInfo.GetCustomAttributes(typeof(IsTolerance), true);
  1221. if (toleranceAttrs.Length > 0 && CurrentRecipe.Header.IsShowTolerance == false)
  1222. {
  1223. continue;
  1224. }
  1225. if (propertyInfo.Name == "UnitName")
  1226. {
  1227. continue;
  1228. }
  1229. if (propertyInfo.Name.Contains("Gas"))
  1230. {
  1231. if (!(bool)QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.MfcGas1.Enable"))
  1232. {
  1233. continue;
  1234. }
  1235. }
  1236. RowDefinition row1 = new RowDefinition();
  1237. row1.Height = new GridLength(controlHeight);
  1238. grid.RowDefinitions.Add(row1);
  1239. Border border = new Border();
  1240. TextBlock textBlock = new TextBlock();
  1241. //textBlock.Padding = new Thickness(0, 3, 0, 0);
  1242. border.Child = textBlock;
  1243. border.BorderBrush = Brushes.Silver;
  1244. border.BorderThickness = new Thickness(1);
  1245. if (isUnitFirstRow)
  1246. {
  1247. textBlock.FontWeight = FontWeights.Bold;
  1248. textBlock.FontSize = 15;
  1249. isUnitFirstRow = false;
  1250. textBlock.Padding = new Thickness(5, 2, 5, 0);
  1251. }
  1252. else
  1253. {
  1254. textBlock.Padding = new Thickness(5, 3, 5, 0);
  1255. }
  1256. switch (propertyInfo.Name)
  1257. {
  1258. case "Gas1":
  1259. var data1 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas1");
  1260. textBlock.Text = $"{propertyInfo.Name}({data1.DisplayName},{data1.Scale})";
  1261. break;
  1262. case "Gas2":
  1263. var data2 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas2");
  1264. textBlock.Text = $"{propertyInfo.Name}({data2.DisplayName},{data2.Scale})";
  1265. break;
  1266. case "Gas3":
  1267. var data3 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas3");
  1268. textBlock.Text = $"{propertyInfo.Name}({data3.DisplayName},{data3.Scale})";
  1269. break;
  1270. case "Gas4":
  1271. var data4 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas4");
  1272. textBlock.Text = $"{propertyInfo.Name}({data4.DisplayName},{data4.Scale})";
  1273. break;
  1274. case "Gas5":
  1275. var data5 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas5");
  1276. textBlock.Text = $"{propertyInfo.Name}({data5.DisplayName},{data5.Scale})";
  1277. break;
  1278. case "Gas6":
  1279. var data6 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas6");
  1280. textBlock.Text = $"{propertyInfo.Name}({data6.DisplayName},{data6.Scale})";
  1281. break;
  1282. case "Gas7":
  1283. var data7 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas7");
  1284. textBlock.Text = $"{propertyInfo.Name}({data7.DisplayName},{data7.Scale})";
  1285. break;
  1286. case "Gas8":
  1287. var data8 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas8");
  1288. textBlock.Text = $"{propertyInfo.Name}({data8.DisplayName},{data8.Scale})";
  1289. break;
  1290. case "Gas9":
  1291. var data9 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas9");
  1292. textBlock.Text = $"{propertyInfo.Name}({data9.DisplayName},{data9.Scale})";
  1293. break;
  1294. case "Gas10":
  1295. var data10 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas10");
  1296. textBlock.Text = $"{propertyInfo.Name}({data10.DisplayName},{data10.Scale})";
  1297. break;
  1298. case "Gas11":
  1299. var data11 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas11");
  1300. textBlock.Text = $"{propertyInfo.Name}({data11.DisplayName},{data11.Scale})";
  1301. break;
  1302. case "Gas12":
  1303. var data12 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas12");
  1304. textBlock.Text = $"{propertyInfo.Name}({data12.DisplayName},{data12.Scale})";
  1305. break;
  1306. default:
  1307. object[] NameAttrs = propertyInfo.GetCustomAttributes(typeof(CustomName), true);
  1308. string name;
  1309. if (NameAttrs.Length > 0)
  1310. {
  1311. name = (NameAttrs[0] as CustomName).Name;
  1312. }
  1313. else
  1314. {
  1315. name = propertyInfo.Name;
  1316. }
  1317. textBlock.Text = name;
  1318. break;
  1319. }
  1320. grid.Children.Add(border);
  1321. border.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FAFAFA"));
  1322. Grid.SetRow(border, i);
  1323. Grid.SetColumn(border, 0);
  1324. i++;
  1325. }
  1326. }
  1327. }
  1328. private void EPDButton_Click(object sender, RoutedEventArgs e)
  1329. {
  1330. Button button = sender as Button;
  1331. string para = button.Tag.ToString();
  1332. int stepno = Convert.ToInt32(para.Split('.')[1]) - 1;
  1333. var endpointconfigitem = new MECF.Framework.Common.CommonData.EndPointConfigItem();
  1334. if (CurrentRecipe.Steps[stepno].EPDConfig != null && CurrentRecipe.Steps[stepno].EPDConfig.Length > 20)
  1335. {
  1336. endpointconfigitem.SetValue(CurrentRecipe.Steps[stepno].EPDConfig);
  1337. }
  1338. (new EndPointDlg(para, endpointconfigitem, CurrentRecipe)).ShowDialog();
  1339. }
  1340. private void UpdateRecipeFileList()
  1341. {
  1342. XmlDocument doc = new XmlDocument();
  1343. doc.LoadXml(GetXmlRecipeList());
  1344. treeViewRcpList.Items.Clear();
  1345. CreateTreeViewItems(doc.DocumentElement, this.treeViewRcpList);
  1346. ExpandAllItems(this.treeViewRcpList);
  1347. }
  1348. private void LoadRecipe(Recipe recipe)
  1349. {
  1350. copyIndex = -1;
  1351. OnClearRecipe();
  1352. CurrentRecipe = recipe;
  1353. RecipeStepToGridColumnOnlyTitle(recipe.Steps[0], leftGrid);
  1354. for (int i = 0; i < recipe.Steps.Count; i++)
  1355. {
  1356. ColumnDefinition col1 = new ColumnDefinition();
  1357. col1.Width = GridLength.Auto;
  1358. rightGrid.ColumnDefinitions.Insert(i, col1);
  1359. RecipeStepToGridColumn(recipe.Steps[i], rightGrid, i);
  1360. }
  1361. string recipeContent = RecipeUnity.RecipeToString(CurrentRecipe);
  1362. SaveEAPRecipe(recipeContent);
  1363. }
  1364. private void OnDeleteStep(int index)
  1365. {
  1366. if (CurrentRecipe != null && CurrentRecipe.Steps.Count > 1)
  1367. {
  1368. RemoveColumnFromGrid(rightGrid, index);
  1369. rightGrid.ColumnDefinitions.RemoveAt(index);
  1370. CurrentRecipe.Steps.RemoveAt(index);
  1371. }
  1372. }
  1373. /// <summary>
  1374. /// 删除Grid某列数据
  1375. /// </summary>
  1376. /// <param name="grid"></param>
  1377. /// <param name="column"></param>
  1378. public void RemoveColumnFromGrid(Grid grid, int column)
  1379. {
  1380. List<UIElement> listControl=new List<UIElement>();
  1381. for (int i = 0; i < grid.Children.Count; i++)
  1382. {
  1383. var child = grid.Children[i];
  1384. if (Grid.GetColumn(child) == column)
  1385. {
  1386. listControl.Add(child);
  1387. }
  1388. }
  1389. listControl.ForEach(x =>
  1390. {
  1391. grid.Children.Remove(x);
  1392. });
  1393. }
  1394. private void OnRefresh()
  1395. {
  1396. if (CurrentRecipeName != "")
  1397. {
  1398. string path = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, typeFolder, $"{CurrentRecipeName}.rcp");
  1399. string xmlRecipeData = m_uiRecipeManager.LoadRecipeByPath(path);
  1400. CurrentRecipe = Recipe.Load(xmlRecipeData);
  1401. LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  1402. LoadRecipe(CurrentRecipe);
  1403. }
  1404. }
  1405. private void OnExpand()
  1406. {
  1407. HeadExpand = !HeadExpand;
  1408. if (HeadExpand)
  1409. {
  1410. recipeView.expandGrid.Width = 300;
  1411. }
  1412. else
  1413. {
  1414. recipeView.expandGrid.Width = 30;
  1415. }
  1416. }
  1417. private void OnUnload()
  1418. {
  1419. //if (CurrentRecipeName == null || CurrentRecipeName == "")
  1420. //{
  1421. // return;
  1422. //}
  1423. //if (WPFMessageBox.ShowQuestion($"Is Save Recipe {CurrentRecipeName}", "", false) == MessageBoxResult.Yes)
  1424. //{
  1425. // OnSaveRecipe();
  1426. //}
  1427. }
  1428. private void OnClearRecipe()
  1429. {
  1430. for (int i = 0; i < rightGrid.ColumnDefinitions.Count; i++)
  1431. {
  1432. rightGrid.ColumnDefinitions[i].Width = new GridLength(75);
  1433. }
  1434. leftGrid.Children.Clear();
  1435. rightGrid.Children.Clear();
  1436. leftGrid.ColumnDefinitions.Clear();
  1437. rightGrid.ColumnDefinitions.Clear();
  1438. rightGrid.RowDefinitions.Clear();
  1439. leftGrid.RowDefinitions.Clear();
  1440. GC.Collect(); // This should pick up the control removed at a previous MouseDown
  1441. GC.WaitForPendingFinalizers(); // Doesn't help either
  1442. //rightGrid.Visibility = Visibility.Visible;
  1443. }
  1444. private void ExpandAllItems(ItemsControl control)
  1445. {
  1446. if (control == null)
  1447. {
  1448. return;
  1449. }
  1450. foreach (Object item in control.Items)
  1451. {
  1452. System.Windows.Controls.TreeViewItem treeItem = control.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
  1453. if (treeItem == null || !treeItem.HasItems)
  1454. {
  1455. continue;
  1456. }
  1457. treeItem.IsExpanded = true;
  1458. ExpandAllItems(treeItem as ItemsControl);
  1459. }
  1460. }
  1461. private bool RecipeNameIsOk(string recipeName)
  1462. {
  1463. if (recipeName.Contains(' '))
  1464. {
  1465. WPFMessageBox.ShowError("Recipe Name 包含空格,不符合规格");
  1466. return false;
  1467. }
  1468. if (recipeName.Length > 25)
  1469. {
  1470. WPFMessageBox.ShowError("Recipe Name 大于25个字符,不符合规格");
  1471. return false;
  1472. }
  1473. return true;
  1474. }
  1475. private void SaveEAPRecipe(string recipeContent)
  1476. {
  1477. if (currentChamber == JetChamber.Kepler2200A || currentChamber == JetChamber.Kepler2200B)
  1478. {
  1479. var newrecipePath2 = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, $"{typeFolder}{eapPath}", CurrentRecipeName + ".rcp");
  1480. FileInfo fi2 = new FileInfo(newrecipePath2);
  1481. var di2 = fi2.Directory;
  1482. if (!di2.Exists)
  1483. {
  1484. di2.Create();
  1485. }
  1486. var newContent = Recipe.ShowEAPRecipe(recipeContent, CurrentRecipe.Steps);
  1487. File.WriteAllText(newrecipePath2, newContent, Encoding.UTF8);
  1488. var newrecipePath3 = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, $"{typeFolder}{tolerancePath}", CurrentRecipeName + ".rcp");
  1489. FileInfo fi3 = new FileInfo(newrecipePath3);
  1490. var di3 = fi3.Directory;
  1491. if (!di3.Exists)
  1492. {
  1493. di3.Create();
  1494. }
  1495. var newContent3 = Recipe.ShowToleranceRecipe(recipeContent, CurrentRecipe.Steps);
  1496. File.WriteAllText(newrecipePath3, newContent3, Encoding.UTF8);
  1497. }
  1498. }
  1499. private bool DeleteEAPRecipe()
  1500. {
  1501. var path = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, $"{typeFolder}{eapPath}", CurrentRecipeName + ".rcp");
  1502. if (File.Exists(path))
  1503. {
  1504. File.Delete(path);
  1505. }
  1506. var path2 = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, $"{typeFolder}{tolerancePath}", CurrentRecipeName + ".rcp");
  1507. if (File.Exists(path))
  1508. {
  1509. File.Delete(path2);
  1510. }
  1511. return true;
  1512. }
  1513. private bool DeleteToleranceRecipe()
  1514. {
  1515. return true;
  1516. }
  1517. #endregion
  1518. }
  1519. }