using MECF.Framework.Common.CommonData; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MECF.Framework.Common.RecipeCenter { public class VpwRinseStep : NotifiableItem,IDataErrorInfo, INotifyPropertyChanged { #region 内部变量 private int _durationSeconds; private int _rotationSpeed; private int _index; private int _step; #endregion #region 属性 [JsonProperty] public int DurationSeconds { get { return _durationSeconds; } set { _durationSeconds = value; InvokePropertyChanged(nameof(DurationSeconds)); } } [JsonProperty] public int RotationSpeed { get { return _rotationSpeed; } set { _rotationSpeed = value; InvokePropertyChanged(nameof(RotationSpeed)); } } [JsonProperty] public int Index { get { return _index; } set { _index = value;_step = _index + 1; InvokePropertyChanged(nameof(Index)); InvokePropertyChanged(nameof(Step)); } } [JsonProperty] public int Step { get { return _step; } set { _step = value; InvokePropertyChanged(nameof(Step)); } } #endregion // IDataErrorInfo 实现 public string Error => null; public string this[string columnName] { get { switch (columnName) { case nameof(DurationSeconds): if (DurationSeconds <= 0 || DurationSeconds > 200) return "Time must be between 0 and 200 seconds!"; break; case nameof(RotationSpeed): if (RotationSpeed <= 0 || RotationSpeed > 800) return "Speed must be between 0 and 800 rpm!"; break; } return null; } } // INotifyPropertyChanged 实现 public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } }