| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using Prism.Mvvm;
- using System.Linq;
- using Prism.Events;
- using Panuon.UI.Silver;
- using SHJX.Service.Common.Event;
- using SHJX.Service.Common.Interface;
- using System.Collections.ObjectModel;
- using SHJX.Service.Model.CRUDModules;
- using SHJX.Service.Control.Interface;
- namespace SHJX.Service.Shell.ViewModels.Setting
- {
- public class EquipmentSettingWindowViewModel : BindableBase
- {
- #region Field
- private readonly ILogService _log;
- private readonly IEventAggregator _ea;
- private readonly ISettingService _service;
- #endregion
- #region Property
- public ObservableCollection<MotorSpeed> MotorSpeeds { get; set; }
- public ObservableCollection<LiquidVolume> LiquidVolumes { get; set; }
- public ObservableCollection<LiquidTotal> LiquidTotals { get; set; }
-
- #endregion
- public EquipmentSettingWindowViewModel(IEventAggregator ea, ILogService log, ISettingService service)
- {
- _ea = ea;
- _log = log;
- _service = service;
- LiquidVolumes = new ObservableCollection<LiquidVolume>(_service.GetData<LiquidVolume>());
- MotorSpeeds = new ObservableCollection<MotorSpeed>(_service.GetData<MotorSpeed>());
- LiquidTotals=new ObservableCollection<LiquidTotal>(_service.GetData<LiquidTotal>());
- _ea.GetEvent<UpdateSettingEvent>().Subscribe(UpdateSetting);
- _ea.GetEvent<SettingClosingEvent>().Subscribe(() =>
- {
- _ea.GetEvent<UpdateSettingEvent>().Unsubscribe(UpdateSetting);
- });
- }
- #region Method
- public void UpdateSetting()
- {
- var ret = _service.UpdateSetting(LiquidVolumes.ToList());
- ret = ret && _service.UpdateSetting(MotorSpeeds.ToList());
- ret = ret && _service.UpdateSetting(LiquidTotals.ToList());
- Notice.Show($"设备相关设置更新{(ret ? "成功" : "失败")}", "Info", 3, Panuon.UI.Silver.MessageBoxIcon.Info);
- }
- #endregion
- }
- }
|