StepGroupSelectViewModel.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using FurnaceUI.Models;
  2. using MECF.Framework.Common.DataCenter;
  3. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  4. using MECF.Framework.UI.Client.CenterViews.Editors;
  5. using MECF.Framework.UI.Client.ClientBase;
  6. using OpenSEMI.ClientBase;
  7. using RecipeEditorLib.RecipeModel.Params;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. namespace FurnaceUI.Views.Scheduled
  15. {
  16. public class StepGroupSelectViewModel : FurnaceUIViewModelBase
  17. {
  18. public string SelectedGroupName = string.Empty;
  19. private ConfigNode _currentNode;
  20. public ConfigNode CurrentNode
  21. {
  22. get { return _currentNode; }
  23. set { _currentNode = value; this.NotifyOfPropertyChange(nameof(CurrentNode)); }
  24. }
  25. private ConfigNode _rootNode;
  26. protected override void OnInitialize()
  27. {
  28. base.OnInitialize();
  29. this.SystemName = "System";
  30. _rootNode = SystemConfigProvider.Instance.GetConfig(true);
  31. CurrentNode = FindNodeByName(_rootNode, $"PM1.RecipeEditParameter.StepGroup");
  32. if (CurrentNode != null && CurrentNode.Items != null)
  33. {
  34. foreach (var item in CurrentNode.Items)
  35. {
  36. item.IsExpanded = false;
  37. if (item.Name == SelectedGroupName)
  38. {
  39. item.IsExpanded = true;
  40. }
  41. }
  42. }
  43. }
  44. private ConfigNode FindNodeByName(ConfigNode parentNode, string strName)
  45. {
  46. string strCates = strName.Split('.')[0];
  47. ConfigNode node = parentNode.SubNodes.Find((x) => x.Name == strCates);
  48. if (node == null)
  49. return parentNode;
  50. else
  51. return FindNodeByName(node, strName.Replace(strCates + ".", ""));
  52. }
  53. public void StepGroupEdit(string groupName)
  54. {
  55. SelectedGroupName = groupName;
  56. ((Window)GetView()).DialogResult = true;
  57. }
  58. }
  59. }