DebugPackV2ViewModel.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Prism.Events;
  2. using ProjectManagementSystem.Common.Core;
  3. using ProjectManagementSystemView.Infrastructure.Events;
  4. using ProjectManagementSystemView.Infrastructure.Extensions;
  5. using ProjectManagementSystemView.Infrastructure.Models;
  6. using PropertyChanged;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace ProjectManagementSystemView.ViewModels
  14. {
  15. [AddINotifyPropertyChangedInterface]
  16. public class DebugPackV2ViewModel
  17. {
  18. public bool IsVisible { get; set; }
  19. public double TimeConsumption { get; set; }
  20. public ObservableCollection<VmPackStationV2> VmDatas { get; set; } = new ObservableCollection<VmPackStationV2>();
  21. public DebugPackV2ViewModel(IEventAggregator eventAggregator)
  22. {
  23. eventAggregator.GetEvent<UpdateViewEvent>().Subscribe(UpdateView);
  24. }
  25. private void UpdateView()
  26. {
  27. if (!IsVisible) return;
  28. TimeConsumption = PackControlCrms.Instance.TimeConsumption;
  29. var dataList = PackControlCrms.Instance.StationDictionary.Values.OrderBy(d => d.Id);
  30. VmDatas.Update(dataList, (s, v) => s.Id == v.Id);
  31. }
  32. }
  33. }