VpwRinseStep.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using MECF.Framework.Common.CommonData;
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MECF.Framework.Common.RecipeCenter
  10. {
  11. public class VpwRinseStep : NotifiableItem,IDataErrorInfo, INotifyPropertyChanged
  12. {
  13. #region 内部变量
  14. private int _durationSeconds;
  15. private int _rotationSpeed;
  16. private int _index;
  17. private int _step;
  18. #endregion
  19. #region 属性
  20. [JsonProperty]
  21. public int DurationSeconds { get { return _durationSeconds; } set { _durationSeconds = value; InvokePropertyChanged(nameof(DurationSeconds)); } }
  22. [JsonProperty]
  23. public int RotationSpeed { get { return _rotationSpeed; } set { _rotationSpeed = value; InvokePropertyChanged(nameof(RotationSpeed)); } }
  24. [JsonProperty]
  25. public int Index { get { return _index; }
  26. set { _index = value;_step = _index + 1; InvokePropertyChanged(nameof(Index)); InvokePropertyChanged(nameof(Step)); } }
  27. [JsonProperty]
  28. public int Step { get { return _step; } set { _step = value; InvokePropertyChanged(nameof(Step)); } }
  29. #endregion
  30. // IDataErrorInfo 实现
  31. public string Error => null;
  32. public string this[string columnName]
  33. {
  34. get
  35. {
  36. switch (columnName)
  37. {
  38. case nameof(DurationSeconds):
  39. if (DurationSeconds <= 0 || DurationSeconds > 200)
  40. return "Time must be between 0 and 200 seconds!";
  41. break;
  42. case nameof(RotationSpeed):
  43. if (RotationSpeed <= 0 || RotationSpeed > 800)
  44. return "Speed must be between 0 and 800 rpm!";
  45. break;
  46. }
  47. return null;
  48. }
  49. }
  50. // INotifyPropertyChanged 实现
  51. public event PropertyChangedEventHandler PropertyChanged;
  52. protected void OnPropertyChanged(string name) =>
  53. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  54. }
  55. }