|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using BPA.Helper;
- using BPASmartClient.Model;
- using BPASmartClient.MorkM.Model;
- using BPA.Helper;
-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.MorkM.ViewModel
- {
- internal class SimOrderConfitViewModel: NotifyBase
- {
- bool IsEdit = false;
- SimOrderVisibleData simOrderVisibleData;
- string DeviceType = string.Empty;
- public SimOrderConfitViewModel()
- {
- // DeviceType = GeneralConfig.StartDevice;
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null)
- {
- if (o is SimOrderVisibleData sim)
- {
- Name = sim.Text;
- Max = sim.MaxValue;
- Min = sim.MinValue;
- IsEdit = true;
- simOrderVisibleData = sim;
- }
- }
- }), "SendSimData");
-
- ConfirmCommand = new BPARelayCommand(() =>
- {
- //if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(DeviceType))
- //{
- // Json<KeepDataBase>.Data.simOrderConfig.TryAdd(DeviceType, new ObservableCollection<SimOrderVisibleData>());
- //}
-
- if (!IsEdit)
- {
- Json<KeepDataBase>.Data.simOrderConfig.Add(new SimOrderVisibleData()
- {
- IsEnable = true,
- IsSelected = true,
- Text = Name,
- Loc = Min,
- MaxValue = Max,
- MinValue = Min,
- });
- }
- else
- {
- int index = Array.FindIndex(Json<KeepDataBase>.Data.simOrderConfig.ToArray(), p => p.Text == simOrderVisibleData.Text);
- if (index >= 0 && index < Json<KeepDataBase>.Data.simOrderConfig.Count())
- {
- Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).Text = Name;
- Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).MinValue = Min;
- Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).MaxValue = Max;
- Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).IsEnable = simOrderVisibleData.IsEnable;
- Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).IsSelected = simOrderVisibleData.IsSelected;
- }
- }
- ActionManage.GetInstance.Send("SimOrderConfitViewModelExit");
- });
- CancelCommand = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SimOrderConfitViewModelExit"); });
- }
-
-
- public BPARelayCommand ConfirmCommand { get; set; }
-
- public BPARelayCommand CancelCommand { get; set; }
-
- public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged();; } }
- private string _mName;
-
- public ushort Min { get { return _mMin; } set { _mMin = value; OnPropertyChanged(); } }
- private ushort _mMin;
-
- public ushort Max { get { return _mMax; } set { _mMax = value; OnPropertyChanged(); } }
- private ushort _mMax;
-
-
- }
- }
-
|