| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | 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<string>    {        #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");            }        }        /// </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()        {            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);        }    }}
 |