| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 | 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 WaferRobotParameterEditViewModel : DialogViewModel<string>    {        #region 页面构造函数及其重载方法        protected override void OnInitialize()        {            base.OnInitialize();            foreach (var item in TableNodeItems)            {                var key = $"{item.Path}.{item.Name}";                ValueList.Add(new PageValue() { Path = key, CurrentValue = item.CurrentValue, Max = item.Max, Min = item.Min, Type = item.Type });                OldValueList.Add(new PageValue() { Path = key, CurrentValue = item.CurrentValue, Max = item.Max, Min = item.Min, Type = item.Type });            }            _pName = TableNodeItems.FirstOrDefault().Path.Split('.').LastOrDefault();        }        #endregion        #region 模型字段        /// </summary>        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<ConfigItem> TableNodeItems { get; set; } = new List<ConfigItem>();        public ObservableCollection<PageValue> ValueList { get; set; } = new ObservableCollection<PageValue>();        public List<PageValue> OldValueList { get; set; } = new List<PageValue>();        #endregion        private void GetModifyValue()        {            IsModifyAll = true;        }        public void SaveBtnClick()        {            foreach (var item in ValueList)            {                if (!OldValueList.Where(a => a.Path.Equals(item.Path)).FirstOrDefault().CurrentValue.Equals(item.CurrentValue))                {                    if (item.Path.Contains("SetValue"))                    {                        if (!IsInRange(double.Parse(item.CurrentValue),item.Min,item.Max))                        {                            DialogBox.ShowError($"The input value:{item.CurrentValue} must be between  {item.Min} and {item.Max}!");                            return;                        }                        setValue = item.CurrentValue.PadLeft(11,'0');                    }                    InvokeClient.Instance.Service.DoOperation("System.SetConfig", item.Path, item.CurrentValue);                }            }            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);        }    }}
 |