VpwRecipeViewModel.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using MECF.Framework.Common.RecipeCenter;
  4. using MECF.Framework.Common.Utilities;
  5. using Prism.Mvvm;
  6. using PunkHPX8_Core;
  7. using PunkHPX8_MainPages.PMs;
  8. using PunkHPX8_Themes.UserControls;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows;
  16. using System.Windows.Input;
  17. namespace PunkHPX8_MainPages.ViewModels
  18. {
  19. public class VpwRecipeViewModel : BindableBase
  20. {
  21. private const string ENGINEERING = "Engineering";
  22. #region 内部变量
  23. private Dictionary<string, RecipeNode> _recipeNodeDic = new Dictionary<string, RecipeNode>();
  24. private ObservableCollection<RecipeNode> _recipeNodes;
  25. private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
  26. private Dictionary<string, bool> _propertyValidResultDic = new Dictionary<string, bool>();
  27. private VpwRecipe _recipe;
  28. private bool _editEnable;
  29. private bool _createEnable;
  30. private RecipeNode _currentNode;
  31. private bool _enable = false;
  32. private bool _isEdit = false;
  33. private string _recipeErrorReason;
  34. private bool _isVacuumPrewetRinseAddInable = true;
  35. private bool _isVentPrewetRinseAddInable = true;
  36. private bool _isExtendCleanRinseAddInable = true;
  37. /// <summary>
  38. /// Wafer尺寸集合
  39. /// </summary>
  40. private List<int> _waferSizeLst = null;
  41. /// <summary>
  42. /// Vacuum Prewet step选择索引
  43. /// </summary>
  44. private int _selectedVacuumPrewetIndex = -1;
  45. /// <summary>
  46. /// Extend Clean step选择索引
  47. /// </summary>
  48. private int _selectedExtendCleanIndex = -1;
  49. /// <summary>
  50. /// Vent Prewet step选择索引
  51. /// </summary>
  52. private int _selectedVentPrewetIndex = -1;
  53. #endregion
  54. #region 属性
  55. public ObservableCollection<RecipeNode> RecipeNodes
  56. {
  57. get { return _recipeNodes; }
  58. set { SetProperty(ref _recipeNodes, value); }
  59. }
  60. public Dictionary<string, bool> PropertyValidResultDic
  61. {
  62. get { return _propertyValidResultDic; }
  63. set { SetProperty(ref _propertyValidResultDic, value); }
  64. }
  65. public RecipeNode CurrentNode
  66. {
  67. get { return _currentNode; }
  68. set { SetProperty(ref _currentNode, value); }
  69. }
  70. public bool Enable
  71. {
  72. get { return _enable; }
  73. set { SetProperty(ref _enable, value); }
  74. }
  75. public bool EditEnable
  76. {
  77. get { return _editEnable; }
  78. set { SetProperty(ref _editEnable, value); }
  79. }
  80. public bool CreateEnable
  81. {
  82. get { return _createEnable; }
  83. set { SetProperty(ref _createEnable, value); }
  84. }
  85. public VpwRecipe Recipe
  86. {
  87. get { return _recipe; }
  88. set { SetProperty(ref _recipe, value); }
  89. }
  90. /// <summary>
  91. /// Wafer 尺寸集合
  92. /// </summary>
  93. public List<int> WaferSizeLst
  94. {
  95. get { return _waferSizeLst; }
  96. set { SetProperty(ref _waferSizeLst, value); }
  97. }
  98. /// <summary>
  99. /// Vacuum Prewet step选择索引
  100. /// </summary>
  101. public int SelectedVacuumPrewetIndex
  102. {
  103. get { return _selectedVacuumPrewetIndex; }
  104. set { SetProperty(ref _selectedVacuumPrewetIndex, value); }
  105. }
  106. /// <summary>
  107. /// SelectedExtendCleanIndex选择索引
  108. /// </summary>
  109. public int SelectedExtendCleanIndex
  110. {
  111. get { return _selectedExtendCleanIndex; }
  112. set { SetProperty(ref _selectedExtendCleanIndex, value); }
  113. }
  114. /// <summary>
  115. /// SelectedVentPrewetIndex选择索引
  116. /// </summary>
  117. public int SelectedVentPrewetIndex
  118. {
  119. get { return _selectedVentPrewetIndex; }
  120. set { SetProperty(ref _selectedVentPrewetIndex, value); }
  121. }
  122. #region 指令
  123. public ICommand OperationCommand
  124. {
  125. get;
  126. private set;
  127. }
  128. [IgnorePropertyChange]
  129. public ICommand CreateCommand { get; private set; }
  130. [IgnorePropertyChange]
  131. public ICommand EditCommand { get; private set; }
  132. [IgnorePropertyChange]
  133. public ICommand SaveRecipeCommand { get; private set; }
  134. [IgnorePropertyChange]
  135. public ICommand SaveAsRecipeCommand { get; private set; }
  136. [IgnorePropertyChange]
  137. public ICommand IsSprayBarRetractFalseCommand { get; private set; }
  138. [IgnorePropertyChange]
  139. public ICommand AddBelowCommand { get; private set; }
  140. [IgnorePropertyChange]
  141. public ICommand AddAboveCommand { get; private set; }
  142. [IgnorePropertyChange]
  143. public ICommand MoveUpCommand { get; private set; }
  144. [IgnorePropertyChange]
  145. public ICommand MoveDownCommand { get; private set; }
  146. [IgnorePropertyChange]
  147. public ICommand DeleteCommand { get; private set; }
  148. public ICommand VentPrewetAddBelowCommand { get; private set; }
  149. [IgnorePropertyChange]
  150. public ICommand VentPrewetAddAboveCommand { get; private set; }
  151. [IgnorePropertyChange]
  152. public ICommand VentPrewetMoveUpCommand { get; private set; }
  153. [IgnorePropertyChange]
  154. public ICommand VentPrewetMoveDownCommand { get; private set; }
  155. [IgnorePropertyChange]
  156. public ICommand VentPrewetDeleteCommand { get; private set; }
  157. public ICommand ExtendCleanAddBelowCommand { get; private set; }
  158. [IgnorePropertyChange]
  159. public ICommand ExtendCleanAddAboveCommand { get; private set; }
  160. [IgnorePropertyChange]
  161. public ICommand ExtendCleanMoveUpCommand { get; private set; }
  162. [IgnorePropertyChange]
  163. public ICommand ExtendCleanMoveDownCommand { get; private set; }
  164. [IgnorePropertyChange]
  165. public ICommand ExtendCleanDeleteCommand { get; private set; }
  166. #endregion
  167. public VpwRecipeViewModel()
  168. {
  169. OperationCommand = new DelegateCommand<object>(SelectionChangedAction);
  170. CreateCommand = new DelegateCommand<object>(CreateAction);
  171. EditCommand = new DelegateCommand<object>(EditAction);
  172. SaveRecipeCommand = new DelegateCommand<object>(SaveAction);
  173. SaveAsRecipeCommand = new DelegateCommand<object>(SaveAsAction);
  174. IsSprayBarRetractFalseCommand = new DelegateCommand<object>(IsSprayBarRetractFalseAction);
  175. AddBelowCommand = new DelegateCommand<object>(AddBelowAction);
  176. AddAboveCommand = new DelegateCommand<object>(AddAboveAction);
  177. MoveUpCommand = new DelegateCommand<object>(MoveUpAction);
  178. MoveDownCommand = new DelegateCommand<object>(MoveDownAction);
  179. DeleteCommand = new DelegateCommand<object>(DeleteAction);
  180. VentPrewetAddBelowCommand = new DelegateCommand<object>(VentPrewetAddBelowAction);
  181. VentPrewetAddAboveCommand = new DelegateCommand<object>(VentPrewetAddAboveAction);
  182. VentPrewetMoveUpCommand = new DelegateCommand<object>(VentPrewetMoveUpAction);
  183. VentPrewetMoveDownCommand = new DelegateCommand<object>(VentPrewetMoveDownAction);
  184. VentPrewetDeleteCommand = new DelegateCommand<object>(VentPrewetDeleteAction);
  185. ExtendCleanAddBelowCommand = new DelegateCommand<object>(ExtendCleanAddBelowAction);
  186. ExtendCleanAddAboveCommand = new DelegateCommand<object>(ExtendCleanAddAboveAction);
  187. ExtendCleanMoveUpCommand = new DelegateCommand<object>(ExtendCleanMoveUpAction);
  188. ExtendCleanMoveDownCommand = new DelegateCommand<object>(ExtendCleanMoveDownAction);
  189. ExtendCleanDeleteCommand = new DelegateCommand<object>(ExtendCleanDeleteAction);
  190. //Wafer尺寸集合
  191. WaferSizeLst = new List<int>();
  192. WaferSizeLst.Add(100);
  193. WaferSizeLst.Add(150);
  194. WaferSizeLst.Add(200);
  195. WaferSizeLst.Add(300);
  196. InitializeProprtyValidResultDictionary();
  197. }
  198. #endregion
  199. private void InitializeProprtyValidResultDictionary()
  200. {
  201. //需要检验的参数
  202. PropertyValidResultDic["VacuumTarget"] = false;
  203. PropertyValidResultDic["DryHoldTime"] = false;
  204. PropertyValidResultDic["DiwLoopDoSet"] = false;
  205. PropertyValidResultDic["SpinSpeed"] = false;
  206. PropertyValidResultDic["SpinTime"] = false;
  207. PropertyValidResultDic["VacuumPrewetFlowSetPoint"] = false;
  208. PropertyValidResultDic["VacuumPrewetFlowWarningPercent"] = false;
  209. PropertyValidResultDic["VacuumPrewetFlowErrorPercent"] = false;
  210. PropertyValidResultDic["VentPrewetFlowSetPoint"] = false;
  211. PropertyValidResultDic["VentPrewetFlowWarningPercent"] = false;
  212. PropertyValidResultDic["VentPrewetFlowErrorPercent"] = false;
  213. PropertyValidResultDic["ExtendCleanFlowSetPoint"] = false;
  214. PropertyValidResultDic["ExtendCleanFlowWarningPercent"] = false;
  215. PropertyValidResultDic["ExtendCleanFlowErrorPercent"] = false;
  216. }
  217. public void LoadRecipeData()
  218. {
  219. RecipeNodes = _uiRecipeManager.GetRecipesByType("vpw");
  220. _recipeNodeDic.Clear();
  221. InitializeDictionary(RecipeNodes);
  222. }
  223. private void InitializeDictionary(ObservableCollection<RecipeNode> nodes)
  224. {
  225. if (nodes != null)
  226. {
  227. foreach (var node in nodes)
  228. {
  229. if (node.NodeType == RecipeNodeType.File)
  230. {
  231. _recipeNodeDic[node.Name] = node;
  232. }
  233. InitializeDictionary(node.Children);
  234. }
  235. }
  236. }
  237. private void SelectionChangedAction(object param)
  238. {
  239. if (_recipeNodeDic.ContainsKey(param.ToString()))
  240. {
  241. CurrentNode = _recipeNodeDic[param.ToString()];
  242. if (CurrentNode.NodeType == RecipeNodeType.File)
  243. {
  244. if (CurrentNode.RecipeLocation == ENGINEERING)
  245. {
  246. EditEnable = true;
  247. CreateEnable = true;
  248. }
  249. else
  250. {
  251. EditEnable = false;
  252. CreateEnable = false;
  253. }
  254. }
  255. Recipe = _uiRecipeManager.LoadRecipe<VpwRecipe>(CurrentNode.RecipeFullFileName);
  256. if (Recipe == null)
  257. {
  258. MessageBox.Show("Invalid Recipe", "Load Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  259. EditEnable = false;
  260. CreateEnable = false;
  261. }
  262. Enable = false;
  263. }
  264. else
  265. {
  266. if (param.ToString() == ENGINEERING)
  267. {
  268. CreateEnable = true;
  269. }
  270. else
  271. {
  272. CreateEnable = false;
  273. }
  274. CurrentNode = null;
  275. Recipe = null;
  276. EditEnable = false;
  277. Enable = false;
  278. }
  279. }
  280. private void CreateAction(object param)
  281. {
  282. RecipeNameDialog recipeNameDialog = new RecipeNameDialog();
  283. if (recipeNameDialog.ShowDialog().Value)
  284. {
  285. if (!CheckNameExist(recipeNameDialog.RecipeName))
  286. {
  287. Recipe = new VpwRecipe();
  288. Recipe.CreateDate = DateTime.Now;
  289. Recipe.Ppid = recipeNameDialog.RecipeName;
  290. Recipe.Description = recipeNameDialog.RecipeDescription;
  291. Recipe.VacuumRinseStep = new ObservableCollection<VpwRinseStep>();
  292. Recipe.VentRinseStep = new ObservableCollection<VpwRinseStep>();
  293. Recipe.ExtendCleanRinseStep = new ObservableCollection<VpwRinseStep>();
  294. Enable = true;
  295. _isEdit = false;
  296. }
  297. }
  298. }
  299. private void EditAction(object param)
  300. {
  301. Enable = true;
  302. _isEdit = false;
  303. }
  304. private bool CheckVpwRecipeRinseStepValueValid(VpwRecipe vpwRecipe,out string errorReason)
  305. {
  306. errorReason = "";
  307. foreach (var item in vpwRecipe.VacuumRinseStep)
  308. {
  309. if (item.DurationSeconds <= 0 || item.DurationSeconds > 200)
  310. {
  311. errorReason = "VacuumPrewet Rinse Step Time value is not in 0~200";
  312. return false;
  313. }
  314. if (item.RotationSpeed <= 0 || item.RotationSpeed > 800)
  315. {
  316. errorReason = "VacuumPrewet Rinse Step Speed value is not in 0~800";
  317. return false;
  318. }
  319. }
  320. foreach (var item in vpwRecipe.VentRinseStep)
  321. {
  322. if (item.DurationSeconds <= 0 || item.DurationSeconds > 200)
  323. {
  324. errorReason = "VentPrewet Rinse Step Rinse Step Time value is not in 0~200";
  325. return false;
  326. }
  327. if (item.RotationSpeed <= 0 || item.RotationSpeed > 800)
  328. {
  329. errorReason = "VentPrewet Rinse Step Speed value is not in 0~800";
  330. return false;
  331. }
  332. }
  333. foreach (var item in vpwRecipe.ExtendCleanRinseStep)
  334. {
  335. if (item.DurationSeconds <= 0 || item.DurationSeconds > 200)
  336. {
  337. errorReason = "ExtendClean Rinse Step Rinse Step Time value is not in 0~200";
  338. return false;
  339. }
  340. if (item.RotationSpeed <= 0 || item.RotationSpeed > 800)
  341. {
  342. errorReason = "ExtendClean Rinse Step Rinse Step Speed value is not in 0~800";
  343. return false;
  344. }
  345. }
  346. return true;
  347. }
  348. private void SaveAction(object param)
  349. {
  350. if (CheckValid(_isEdit))
  351. {
  352. if (!CheckVpwRecipeRinseStepValueValid(Recipe, out _recipeErrorReason))
  353. {
  354. MessageBox.Show($"{_recipeErrorReason}", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  355. return;
  356. }
  357. Recipe.SaveDate = DateTime.Now;
  358. try
  359. {
  360. _uiRecipeManager.SaveRecipe<VpwRecipe>(ENGINEERING, Recipe.Ppid, "vpw", Recipe);
  361. LoadRecipeData();
  362. MessageBox.Show("Save Recipe Success", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Information);
  363. Enable = false;
  364. }
  365. catch (Exception ex)
  366. {
  367. MessageBox.Show(ex.Message, "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  368. }
  369. }
  370. }
  371. /// <summary>
  372. /// 另存为
  373. /// </summary>
  374. /// <param name="param"></param>
  375. private void SaveAsAction(object param)
  376. {
  377. if (Recipe == null)
  378. {
  379. MessageBox.Show("Select a Recipe first", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  380. return;
  381. }
  382. VpwRecipe recipe = new VpwRecipe();
  383. if (CheckValid(_isEdit))
  384. {
  385. RecipeNameDialog recipeNameDialog = new RecipeNameDialog();
  386. if (recipeNameDialog.ShowDialog().Value)
  387. {
  388. if (!CheckNameExist(recipeNameDialog.RecipeName))
  389. {
  390. recipe = new VpwRecipe();
  391. recipe = (VpwRecipe)PropertyUtil.Clone(Recipe);
  392. recipe.CreateDate = DateTime.Now;
  393. recipe.Ppid = recipeNameDialog.RecipeName;
  394. recipe.Description = recipeNameDialog.RecipeDescription;
  395. }
  396. else if (recipeNameDialog.RecipeName != null)
  397. {
  398. MessageBox.Show("Name can not be Null", "Create Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  399. return;
  400. }
  401. else
  402. {
  403. return;
  404. }
  405. }
  406. try
  407. {
  408. _uiRecipeManager.SaveRecipe<VpwRecipe>(ENGINEERING, recipe.Ppid, "vpw", recipe);
  409. LoadRecipeData();
  410. MessageBox.Show("Save As Recipe Success", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Information);
  411. Enable = false;
  412. }
  413. catch (Exception ex)
  414. {
  415. MessageBox.Show(ex.Message, "Save As Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  416. }
  417. }
  418. }
  419. private bool CheckNameExist(string name)
  420. {
  421. foreach (string item in _recipeNodeDic.Keys)
  422. {
  423. if (item == name)
  424. {
  425. MessageBox.Show($"{name} is exsit", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  426. return true;
  427. }
  428. }
  429. return false;
  430. }
  431. private bool CheckValid(bool editType)
  432. {
  433. foreach (string key in _propertyValidResultDic.Keys)
  434. {
  435. bool valid = _propertyValidResultDic[key];
  436. if (!valid)
  437. {
  438. MessageBox.Show($"{key} data invalid", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  439. return false;
  440. }
  441. }
  442. return true;
  443. }
  444. private void IsSprayBarRetractFalseAction(object param)
  445. {
  446. Recipe.IsSprayBarRetract = false;
  447. }
  448. #region Vacuum prewet按钮
  449. /// <summary>
  450. /// 增加
  451. /// </summary>
  452. /// <param name="param"></param>
  453. private void AddBelowAction(object param)
  454. {
  455. if (Recipe!=null && Recipe.VacuumRinseStep.Count >= 5)
  456. {
  457. MessageBox.Show($"Vacuum Prewet Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);
  458. return;
  459. }
  460. if (Recipe != null)
  461. {
  462. VpwRinseStep currentRinseSteps = new VpwRinseStep();
  463. currentRinseSteps.Index = SelectedVacuumPrewetIndex + 1;
  464. for(int i = currentRinseSteps.Index; i<=Recipe.VacuumRinseStep.Count-1; i++)
  465. {
  466. Recipe.VacuumRinseStep[i].Index++;
  467. }
  468. Recipe.VacuumRinseStep.Insert(SelectedVacuumPrewetIndex + 1, currentRinseSteps);
  469. SelectedVacuumPrewetIndex++;
  470. }
  471. }
  472. /// <summary>
  473. /// 增加
  474. /// </summary>
  475. /// <param name="param"></param>
  476. private void AddAboveAction(object param)
  477. {
  478. if (Recipe != null && Recipe.VacuumRinseStep.Count >= 5)
  479. {
  480. MessageBox.Show($"Vacuum Prewet Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);
  481. return;
  482. }
  483. if (Recipe != null)
  484. {
  485. VpwRinseStep currentRinseSteps = new VpwRinseStep();
  486. if (SelectedVacuumPrewetIndex == -1)
  487. {
  488. Recipe.VacuumRinseStep.Add(currentRinseSteps);
  489. SelectedVacuumPrewetIndex = 0;
  490. }
  491. else
  492. {
  493. currentRinseSteps.Index = SelectedVacuumPrewetIndex;
  494. for (int i = currentRinseSteps.Index; i <= Recipe.VacuumRinseStep.Count-1; i++)
  495. {
  496. Recipe.VacuumRinseStep[i].Index++;
  497. }
  498. Recipe.VacuumRinseStep.Insert(SelectedVacuumPrewetIndex, currentRinseSteps);
  499. SelectedVacuumPrewetIndex--;
  500. }
  501. }
  502. }
  503. /// <summary>
  504. /// 上移
  505. /// </summary>
  506. /// <param name="param"></param>
  507. private void MoveUpAction(object param)
  508. {
  509. if (Recipe != null)
  510. {
  511. if (SelectedVacuumPrewetIndex > 0)
  512. {
  513. int currentIndex = SelectedVacuumPrewetIndex;
  514. VpwRinseStep currentRinseSteps = Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex];
  515. currentRinseSteps.Index -= 1;
  516. Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex-1].Index += 1;
  517. Recipe.VacuumRinseStep.RemoveAt(SelectedVacuumPrewetIndex);
  518. Recipe.VacuumRinseStep.Insert(currentIndex - 1, currentRinseSteps);
  519. SelectedVacuumPrewetIndex = currentIndex - 1;
  520. }
  521. }
  522. }
  523. /// <summary>
  524. /// 下移
  525. /// </summary>
  526. /// <param name="param"></param>
  527. private void MoveDownAction(object param)
  528. {
  529. if (Recipe != null)
  530. {
  531. if (SelectedVacuumPrewetIndex >= 0 && SelectedVacuumPrewetIndex < Recipe.VacuumRinseStep.Count - 1 && Recipe.VacuumRinseStep.Count > 1)
  532. {
  533. int currentIndex = SelectedVacuumPrewetIndex;
  534. VpwRinseStep currentRinseSteps = Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex];
  535. currentRinseSteps.Index += 1;
  536. Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex + 1].Index -= 1;
  537. Recipe.VacuumRinseStep.RemoveAt(SelectedVacuumPrewetIndex);
  538. Recipe.VacuumRinseStep.Insert(currentIndex + 1, currentRinseSteps);
  539. SelectedVacuumPrewetIndex = currentIndex + 1;
  540. }
  541. }
  542. }
  543. /// <summary>
  544. /// 删除
  545. /// </summary>
  546. /// <param name="param"></param>
  547. private void DeleteAction(object param)
  548. {
  549. if (SelectedVacuumPrewetIndex != -1)
  550. {
  551. if (Recipe != null && Recipe.VacuumRinseStep.Count > SelectedVacuumPrewetIndex)
  552. {
  553. for (int i = SelectedVacuumPrewetIndex + 1; i <= Recipe.VacuumRinseStep.Count - 1; i++)
  554. {
  555. Recipe.VacuumRinseStep[i].Index -= 1;
  556. }
  557. Recipe.VacuumRinseStep.RemoveAt(SelectedVacuumPrewetIndex);
  558. }
  559. }
  560. }
  561. #endregion
  562. #region Vent prewet按钮
  563. /// <summary>
  564. /// 增加
  565. /// </summary>
  566. /// <param name="param"></param>
  567. private void VentPrewetAddBelowAction(object param)
  568. {
  569. if (Recipe != null && Recipe.VentRinseStep.Count >= 5)
  570. {
  571. MessageBox.Show($"Vent Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);
  572. return;
  573. }
  574. if (Recipe != null)
  575. {
  576. VpwRinseStep currentRinseSteps = new VpwRinseStep();
  577. currentRinseSteps.Index = SelectedVentPrewetIndex + 1;
  578. for (int i = currentRinseSteps.Index; i <= Recipe.VentRinseStep.Count - 1; i++)
  579. {
  580. Recipe.VentRinseStep[i].Index++;
  581. }
  582. Recipe.VentRinseStep.Insert(SelectedVentPrewetIndex + 1, currentRinseSteps);
  583. SelectedVentPrewetIndex++;
  584. }
  585. }
  586. /// <summary>
  587. /// 增加
  588. /// </summary>
  589. /// <param name="param"></param>
  590. private void VentPrewetAddAboveAction(object param)
  591. {
  592. if (Recipe != null && Recipe.VentRinseStep.Count >= 5)
  593. {
  594. MessageBox.Show($"Vent Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);
  595. return;
  596. }
  597. if (Recipe != null)
  598. {
  599. VpwRinseStep currentRinseSteps = new VpwRinseStep();
  600. if (SelectedVentPrewetIndex == -1)
  601. {
  602. Recipe.VentRinseStep.Add(currentRinseSteps);
  603. SelectedVentPrewetIndex = 0;
  604. }
  605. else
  606. {
  607. currentRinseSteps.Index = SelectedVentPrewetIndex;
  608. for (int i = currentRinseSteps.Index; i <= Recipe.VentRinseStep.Count - 1; i++)
  609. {
  610. Recipe.VentRinseStep[i].Index++;
  611. }
  612. Recipe.VentRinseStep.Insert(SelectedVentPrewetIndex, currentRinseSteps);
  613. SelectedVentPrewetIndex--;
  614. }
  615. }
  616. }
  617. /// <summary>
  618. /// 上移
  619. /// </summary>
  620. /// <param name="param"></param>
  621. private void VentPrewetMoveUpAction(object param)
  622. {
  623. if (Recipe != null)
  624. {
  625. if (SelectedVentPrewetIndex > 0)
  626. {
  627. int currentIndex = SelectedVentPrewetIndex;
  628. VpwRinseStep currentRinseSteps = Recipe.VentRinseStep[SelectedVentPrewetIndex];
  629. currentRinseSteps.Index -= 1;
  630. Recipe.VentRinseStep[SelectedVentPrewetIndex - 1].Index += 1;
  631. Recipe.VentRinseStep.RemoveAt(SelectedVentPrewetIndex);
  632. Recipe.VentRinseStep.Insert(currentIndex - 1, currentRinseSteps);
  633. SelectedVentPrewetIndex = currentIndex - 1;
  634. }
  635. }
  636. }
  637. /// <summary>
  638. /// 下移
  639. /// </summary>
  640. /// <param name="param"></param>
  641. private void VentPrewetMoveDownAction(object param)
  642. {
  643. if (Recipe != null)
  644. {
  645. if (SelectedVentPrewetIndex >= 0 && SelectedVentPrewetIndex < Recipe.VentRinseStep.Count - 1 && Recipe.VentRinseStep.Count > 1)
  646. {
  647. int currentIndex = SelectedVentPrewetIndex;
  648. VpwRinseStep currentRinseSteps = Recipe.VentRinseStep[SelectedVentPrewetIndex];
  649. currentRinseSteps.Index += 1;
  650. Recipe.VentRinseStep[SelectedVentPrewetIndex + 1].Index -= 1;
  651. Recipe.VentRinseStep.RemoveAt(SelectedVentPrewetIndex);
  652. Recipe.VentRinseStep.Insert(currentIndex + 1, currentRinseSteps);
  653. SelectedVentPrewetIndex = currentIndex + 1;
  654. }
  655. }
  656. }
  657. /// <summary>
  658. /// 删除
  659. /// </summary>
  660. /// <param name="param"></param>
  661. private void VentPrewetDeleteAction(object param)
  662. {
  663. if (SelectedVentPrewetIndex != -1)
  664. {
  665. if (Recipe != null && Recipe.VentRinseStep.Count > SelectedVentPrewetIndex)
  666. {
  667. for (int i = SelectedVentPrewetIndex + 1; i <= Recipe.VentRinseStep.Count - 1; i++)
  668. {
  669. Recipe.VentRinseStep[i].Index -= 1;
  670. }
  671. Recipe.VentRinseStep.RemoveAt(SelectedVentPrewetIndex);
  672. }
  673. }
  674. }
  675. #endregion
  676. #region Extend Clean按钮
  677. /// <summary>
  678. /// 增加
  679. /// </summary>
  680. /// <param name="param"></param>
  681. private void ExtendCleanAddBelowAction(object param)
  682. {
  683. if (Recipe != null && Recipe.ExtendCleanRinseStep.Count >= 5)
  684. {
  685. MessageBox.Show($"Extend Clean Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);
  686. return;
  687. }
  688. if (Recipe != null)
  689. {
  690. VpwRinseStep currentRinseSteps = new VpwRinseStep();
  691. currentRinseSteps.Index = SelectedExtendCleanIndex + 1;
  692. for (int i = currentRinseSteps.Index; i <= Recipe.ExtendCleanRinseStep.Count - 1; i++)
  693. {
  694. Recipe.ExtendCleanRinseStep[i].Index++;
  695. }
  696. Recipe.ExtendCleanRinseStep.Insert(SelectedExtendCleanIndex + 1, currentRinseSteps);
  697. SelectedExtendCleanIndex++;
  698. }
  699. }
  700. /// <summary>
  701. /// 增加
  702. /// </summary>
  703. /// <param name="param"></param>
  704. private void ExtendCleanAddAboveAction(object param)
  705. {
  706. if (Recipe != null && Recipe.ExtendCleanRinseStep.Count >= 5)
  707. {
  708. MessageBox.Show($"Extend Clean Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);
  709. return;
  710. }
  711. if (Recipe != null)
  712. {
  713. VpwRinseStep currentRinseSteps = new VpwRinseStep();
  714. if (SelectedExtendCleanIndex == -1)
  715. {
  716. Recipe.ExtendCleanRinseStep.Add(currentRinseSteps);
  717. SelectedExtendCleanIndex = 0;
  718. }
  719. else
  720. {
  721. currentRinseSteps.Index = SelectedExtendCleanIndex;
  722. for (int i = currentRinseSteps.Index; i <= Recipe.ExtendCleanRinseStep.Count - 1; i++)
  723. {
  724. Recipe.ExtendCleanRinseStep[i].Index++;
  725. }
  726. Recipe.ExtendCleanRinseStep.Insert(SelectedExtendCleanIndex, currentRinseSteps);
  727. SelectedExtendCleanIndex--;
  728. }
  729. }
  730. }
  731. /// <summary>
  732. /// 上移
  733. /// </summary>
  734. /// <param name="param"></param>
  735. private void ExtendCleanMoveUpAction(object param)
  736. {
  737. if (Recipe != null)
  738. {
  739. if (SelectedExtendCleanIndex > 0)
  740. {
  741. int currentIndex = SelectedExtendCleanIndex;
  742. VpwRinseStep currentRinseSteps = Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex];
  743. currentRinseSteps.Index -= 1;
  744. Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex - 1].Index += 1;
  745. Recipe.ExtendCleanRinseStep.RemoveAt(SelectedExtendCleanIndex);
  746. Recipe.ExtendCleanRinseStep.Insert(currentIndex - 1, currentRinseSteps);
  747. SelectedExtendCleanIndex = currentIndex - 1;
  748. }
  749. }
  750. }
  751. /// <summary>
  752. /// 下移
  753. /// </summary>
  754. /// <param name="param"></param>
  755. private void ExtendCleanMoveDownAction(object param)
  756. {
  757. if (Recipe != null)
  758. {
  759. if (SelectedExtendCleanIndex >= 0 && SelectedExtendCleanIndex < Recipe.ExtendCleanRinseStep.Count - 1 && Recipe.ExtendCleanRinseStep.Count > 1)
  760. {
  761. int currentIndex = SelectedExtendCleanIndex;
  762. VpwRinseStep currentRinseSteps = Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex];
  763. currentRinseSteps.Index += 1;
  764. Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex + 1].Index -= 1;
  765. Recipe.ExtendCleanRinseStep.RemoveAt(SelectedExtendCleanIndex);
  766. Recipe.ExtendCleanRinseStep.Insert(currentIndex + 1, currentRinseSteps);
  767. SelectedExtendCleanIndex = currentIndex + 1;
  768. }
  769. }
  770. }
  771. /// <summary>
  772. /// 删除
  773. /// </summary>
  774. /// <param name="param"></param>
  775. private void ExtendCleanDeleteAction(object param)
  776. {
  777. if (SelectedExtendCleanIndex != -1)
  778. {
  779. if (Recipe != null && Recipe.ExtendCleanRinseStep.Count > SelectedExtendCleanIndex)
  780. {
  781. for (int i = SelectedExtendCleanIndex + 1; i <= Recipe.ExtendCleanRinseStep.Count - 1; i++)
  782. {
  783. Recipe.ExtendCleanRinseStep[i].Index -= 1;
  784. }
  785. Recipe.ExtendCleanRinseStep.RemoveAt(SelectedExtendCleanIndex);
  786. }
  787. }
  788. }
  789. #endregion
  790. }
  791. }