using DocumentFormat.OpenXml.Wordprocessing; using MECF.Framework.Common.OperationCenter; using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig; using OpenSEMI.ClientBase; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FurnaceUI.Views.Maintenances { public class WaferRobotPositionEditViewModel : DialogViewModel { #region 页面构造函数及其重载方法 protected override void OnInitialize() { base.OnInitialize(); foreach (var item in TableNodeItems) { if (item.Name.Equals("StParam")) { SelectPositionIndex = item.Parameter.Split(';').ToList().FindIndex(a => a.Equals(item.CurrentValue)); } var key = $"{item.Path}.{item.Name}"; ValueList.Add(new PageValue() { Path = key, CurrentValue = item.CurrentValue, Max = item.Max, Min = item.Min, Type = item.Type, Parameters = item.Parameter.Split(';').ToList() }); OldValueList.Add(new PageValue() { Path = key, CurrentValue = item.CurrentValue, Max = item.Max, Min = item.Min, Type = item.Type, Parameters = item.Parameter.Split(';').ToList() }); } _pName = TableNodeItems.FirstOrDefault().Path.Split('.').LastOrDefault(); } #endregion #region 模型字段 private int _selectPositionIndex = 0; public int SelectPositionIndex { get { return _selectPositionIndex; } set { _selectPositionIndex = value; NotifyOfPropertyChange("SelectPositionIndex"); } } /// public string _pName; public string setValue; public string PName { get { return _pName; } set { _pName = value; this.NotifyOfPropertyChange(nameof(PName)); } } private bool _isModifyAll = false; public bool IsModifyAll { get { return _isModifyAll; } set { _isModifyAll = value; this.NotifyOfPropertyChange(nameof(IsModifyAll)); } } public List TableNodeItems { get; set; } = new List(); public ObservableCollection ValueList { get; set; } = new ObservableCollection(); public List OldValueList { get; set; } = new List(); #endregion private void GetModifyValue() { IsModifyAll = true; } public void SaveBtnClick() { var setValueItem = ValueList.Where(a => a.Path.EndsWith("SetValue")).FirstOrDefault(); var stParamItem = ValueList.Where(a => a.Path.EndsWith("StParam")).FirstOrDefault(); stParamItem.CurrentValue = stParamItem.Parameters[SelectPositionIndex]; foreach (var item in OldValueList) { if ((item.Path.EndsWith("SetValue") && item.CurrentValue != setValueItem.CurrentValue) || (item.Path.EndsWith("StParam") && item.CurrentValue != stParamItem.CurrentValue)) { InvokeClient.Instance.Service.DoOperation("System.SetConfig", item.Path, item.Path.EndsWith("SetValue")?setValueItem.CurrentValue: stParamItem.CurrentValue); setValue = $"{stParamItem.CurrentValue},{setValueItem.CurrentValue.PadLeft(11, '0')}"; } } IsCancel = true; TryClose(true); } private bool IsInRange(double num, double min, double max) { return (num >= min && num <= max); } public void CancelBtnClick() { IsCancel = true; TryClose(false); } } }