RecipeViewModel.cs 76 KB

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