RecipeViewModel.cs 71 KB

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