WaferRobotPositionEditViewModel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. 
  2. using DocumentFormat.OpenXml.Wordprocessing;
  3. using MECF.Framework.Common.OperationCenter;
  4. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  5. using OpenSEMI.ClientBase;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace FurnaceUI.Views.Maintenances
  13. {
  14. public class WaferRobotPositionEditViewModel : DialogViewModel<string>
  15. {
  16. #region 页面构造函数及其重载方法
  17. protected override void OnInitialize()
  18. {
  19. base.OnInitialize();
  20. foreach (var item in TableNodeItems)
  21. {
  22. if (item.Name.Equals("StParam"))
  23. {
  24. SelectPositionIndex = item.Parameter.Split(';').ToList().FindIndex(a => a.Equals(item.CurrentValue));
  25. }
  26. var key = $"{item.Path}.{item.Name}";
  27. ValueList.Add(new PageValue() { Path = key, CurrentValue = item.CurrentValue, Max = item.Max, Min = item.Min, Type = item.Type, Parameters = item.Parameter.Split(';').ToList() });
  28. OldValueList.Add(new PageValue() { Path = key, CurrentValue = item.CurrentValue, Max = item.Max, Min = item.Min, Type = item.Type, Parameters = item.Parameter.Split(';').ToList() });
  29. }
  30. _pName = TableNodeItems.FirstOrDefault().Path.Split('.').LastOrDefault();
  31. }
  32. #endregion
  33. #region 模型字段
  34. private int _selectPositionIndex = 0;
  35. public int SelectPositionIndex
  36. {
  37. get { return _selectPositionIndex; }
  38. set
  39. {
  40. _selectPositionIndex = value;
  41. NotifyOfPropertyChange("SelectPositionIndex");
  42. }
  43. }
  44. /// </summary>
  45. public string _pName;
  46. public string setValue;
  47. public string PName
  48. {
  49. get { return _pName; }
  50. set { _pName = value; this.NotifyOfPropertyChange(nameof(PName)); }
  51. }
  52. private bool _isModifyAll = false;
  53. public bool IsModifyAll
  54. {
  55. get { return _isModifyAll; }
  56. set { _isModifyAll = value; this.NotifyOfPropertyChange(nameof(IsModifyAll)); }
  57. }
  58. public List<ConfigItem> TableNodeItems { get; set; } = new List<ConfigItem>();
  59. public ObservableCollection<PageValue> ValueList { get; set; } = new ObservableCollection<PageValue>();
  60. public List<PageValue> OldValueList { get; set; } = new List<PageValue>();
  61. #endregion
  62. private void GetModifyValue()
  63. {
  64. IsModifyAll = true;
  65. }
  66. public void SaveBtnClick()
  67. {
  68. var setValueItem = ValueList.Where(a => a.Path.EndsWith("SetValue")).FirstOrDefault();
  69. var stParamItem = ValueList.Where(a => a.Path.EndsWith("StParam")).FirstOrDefault();
  70. stParamItem.CurrentValue = stParamItem.Parameters[SelectPositionIndex];
  71. foreach (var item in OldValueList)
  72. {
  73. if ((item.Path.EndsWith("SetValue") && item.CurrentValue != setValueItem.CurrentValue) || (item.Path.EndsWith("StParam") && item.CurrentValue != stParamItem.CurrentValue))
  74. {
  75. InvokeClient.Instance.Service.DoOperation("System.SetConfig", item.Path, item.Path.EndsWith("SetValue")?setValueItem.CurrentValue: stParamItem.CurrentValue);
  76. setValue = $"{stParamItem.CurrentValue},{setValueItem.CurrentValue.PadLeft(11, '0')}";
  77. }
  78. }
  79. IsCancel = true;
  80. TryClose(true);
  81. }
  82. private bool IsInRange(double num, double min, double max)
  83. {
  84. return (num >= min && num <= max);
  85. }
  86. public void CancelBtnClick()
  87. {
  88. IsCancel = true;
  89. TryClose(false);
  90. }
  91. }
  92. }