DebugPackViewModel.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 DebugPackViewModel
  17. {
  18. public bool IsVisible { get; set; }
  19. public ObservableCollection<VmPackStation> VmDatas { get; set; } = new ObservableCollection<VmPackStation>();
  20. public DebugPackViewModel(IEventAggregator eventAggregator)
  21. {
  22. eventAggregator.GetEvent<UpdateViewEvent>().Subscribe(UpdateView);
  23. }
  24. private void UpdateView()
  25. {
  26. if (!IsVisible) return;
  27. var dataList = PackControl.Instance.StationDictionary.Values.OrderBy(d => d.Id);
  28. VmDatas.Update(dataList, (s, v) => s.Id == v.Id);
  29. }
  30. }
  31. }