终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

91 line
3.3 KiB

  1. using BPA.Helper;
  2. using BPASmartClient.Model;
  3. using BPASmartClient.MorkM.Model;
  4. using BPA.Helper;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace BPASmartClient.MorkM.ViewModel
  11. {
  12. internal class SimOrderConfitViewModel: NotifyBase
  13. {
  14. bool IsEdit = false;
  15. SimOrderVisibleData simOrderVisibleData;
  16. string DeviceType = string.Empty;
  17. public SimOrderConfitViewModel()
  18. {
  19. // DeviceType = GeneralConfig.StartDevice;
  20. ActionManage.GetInstance.Register(new Action<object>((o) =>
  21. {
  22. if (o != null)
  23. {
  24. if (o is SimOrderVisibleData sim)
  25. {
  26. Name = sim.Text;
  27. Max = sim.MaxValue;
  28. Min = sim.MinValue;
  29. IsEdit = true;
  30. simOrderVisibleData = sim;
  31. }
  32. }
  33. }), "SendSimData");
  34. ConfirmCommand = new BPARelayCommand(() =>
  35. {
  36. //if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(DeviceType))
  37. //{
  38. // Json<KeepDataBase>.Data.simOrderConfig.TryAdd(DeviceType, new ObservableCollection<SimOrderVisibleData>());
  39. //}
  40. if (!IsEdit)
  41. {
  42. Json<KeepDataBase>.Data.simOrderConfig.Add(new SimOrderVisibleData()
  43. {
  44. IsEnable = true,
  45. IsSelected = true,
  46. Text = Name,
  47. Loc = Min,
  48. MaxValue = Max,
  49. MinValue = Min,
  50. });
  51. }
  52. else
  53. {
  54. int index = Array.FindIndex(Json<KeepDataBase>.Data.simOrderConfig.ToArray(), p => p.Text == simOrderVisibleData.Text);
  55. if (index >= 0 && index < Json<KeepDataBase>.Data.simOrderConfig.Count())
  56. {
  57. Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).Text = Name;
  58. Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).MinValue = Min;
  59. Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).MaxValue = Max;
  60. Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).IsEnable = simOrderVisibleData.IsEnable;
  61. Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).IsSelected = simOrderVisibleData.IsSelected;
  62. }
  63. }
  64. ActionManage.GetInstance.Send("SimOrderConfitViewModelExit");
  65. });
  66. CancelCommand = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SimOrderConfitViewModelExit"); });
  67. }
  68. public BPARelayCommand ConfirmCommand { get; set; }
  69. public BPARelayCommand CancelCommand { get; set; }
  70. public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged();; } }
  71. private string _mName;
  72. public ushort Min { get { return _mMin; } set { _mMin = value; OnPropertyChanged(); } }
  73. private ushort _mMin;
  74. public ushort Max { get { return _mMax; } set { _mMax = value; OnPropertyChanged(); } }
  75. private ushort _mMax;
  76. }
  77. }