|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System.Collections.ObjectModel;
- using Microsoft.Toolkit.Mvvm.Input;
-
- namespace BPASmartClient.DosingSystem.ViewModel
- {
- public class ManualControlViewModel : ObservableObject
- {
- public ManualControlViewModel()
- {
- for (int i = 0; i < 15; i++)
- {
- cylinderModels.Add(new CylinderModel()
- {
- Name = $"升降气缸 {i + 1}",
- LeftTog = false,
- RightTog = false,
- });
-
- BlockCylinders.Add(new CylinderModel()
- {
- Name = $"阻挡气缸 {i + 1}",
- LeftTog = false,
- RightTog = false,
- });
- }
-
- for (int i = 0; i < 4; i++)
- {
- PalletCylinders.Add(new CylinderModel()
- {
- Name = $"托盘气缸 {i + 1}",
- LeftTog = false,
- RightTog = false,
- });
- }
-
- Open = new RelayCommand<object>((o) =>
- {
- int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
- cylinderModels.ElementAt(index).LeftTog = true;
- cylinderModels.ElementAt(index).RightTog = false;
- });
-
-
- Close = new RelayCommand<object>((o) =>
- {
- int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
- cylinderModels.ElementAt(index).LeftTog = false;
- cylinderModels.ElementAt(index).RightTog = true;
- });
- }
-
- /// <summary>
- /// 升降气缸
- /// </summary>
- public ObservableCollection<CylinderModel> cylinderModels { get; set; } = new ObservableCollection<CylinderModel>();
-
- /// <summary>
- /// 阻挡气缸
- /// </summary>
- public ObservableCollection<CylinderModel> BlockCylinders { get; set; } = new ObservableCollection<CylinderModel>();
-
- /// <summary>
- /// 托盘气缸
- /// </summary>
- public ObservableCollection<CylinderModel> PalletCylinders { get; set; } = new ObservableCollection<CylinderModel>();
-
- public RelayCommand<object> Open { get; set; }
-
- public RelayCommand<object> Close { get; set; }
-
- }
-
- public class CylinderModel : ObservableObject
- {
-
- public bool LeftTog { get { return _mLeftTog; } set { _mLeftTog = value; OnPropertyChanged(); } }
- private bool _mLeftTog;
-
- public bool RightTog { get { return _mRightTog; } set { _mRightTog = value; OnPropertyChanged(); } }
- private bool _mRightTog;
-
- public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } }
- private string _mName;
-
-
-
- }
- }
|