终端一体化运控平台
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

96 рядки
3.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.ObjectModel;
  8. using Microsoft.Toolkit.Mvvm.Input;
  9. namespace BPASmartClient.DosingSystem.ViewModel
  10. {
  11. public class ManualControlViewModel : ObservableObject
  12. {
  13. public ManualControlViewModel()
  14. {
  15. for (int i = 0; i < 15; i++)
  16. {
  17. cylinderModels.Add(new CylinderModel()
  18. {
  19. Name = $"升降气缸 {i + 1}",
  20. LeftTog = false,
  21. RightTog = false,
  22. });
  23. BlockCylinders.Add(new CylinderModel()
  24. {
  25. Name = $"阻挡气缸 {i + 1}",
  26. LeftTog = false,
  27. RightTog = false,
  28. });
  29. }
  30. for (int i = 0; i < 4; i++)
  31. {
  32. PalletCylinders.Add(new CylinderModel()
  33. {
  34. Name = $"托盘气缸 {i + 1}",
  35. LeftTog = false,
  36. RightTog = false,
  37. });
  38. }
  39. Open = new RelayCommand<object>((o) =>
  40. {
  41. int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
  42. cylinderModels.ElementAt(index).LeftTog = true;
  43. cylinderModels.ElementAt(index).RightTog = false;
  44. });
  45. Close = new RelayCommand<object>((o) =>
  46. {
  47. int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
  48. cylinderModels.ElementAt(index).LeftTog = false;
  49. cylinderModels.ElementAt(index).RightTog = true;
  50. });
  51. }
  52. /// <summary>
  53. /// 升降气缸
  54. /// </summary>
  55. public ObservableCollection<CylinderModel> cylinderModels { get; set; } = new ObservableCollection<CylinderModel>();
  56. /// <summary>
  57. /// 阻挡气缸
  58. /// </summary>
  59. public ObservableCollection<CylinderModel> BlockCylinders { get; set; } = new ObservableCollection<CylinderModel>();
  60. /// <summary>
  61. /// 托盘气缸
  62. /// </summary>
  63. public ObservableCollection<CylinderModel> PalletCylinders { get; set; } = new ObservableCollection<CylinderModel>();
  64. public RelayCommand<object> Open { get; set; }
  65. public RelayCommand<object> Close { get; set; }
  66. }
  67. public class CylinderModel : ObservableObject
  68. {
  69. public bool LeftTog { get { return _mLeftTog; } set { _mLeftTog = value; OnPropertyChanged(); } }
  70. private bool _mLeftTog;
  71. public bool RightTog { get { return _mRightTog; } set { _mRightTog = value; OnPropertyChanged(); } }
  72. private bool _mRightTog;
  73. public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } }
  74. private string _mName;
  75. }
  76. }