CalibrationViewModel.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using Prism.Commands;
  2. using Prism.Events;
  3. using Prism.Ioc;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using TeamAAS_VP.Core;
  11. using TeamAAS_VP.Events;
  12. using TeamAAS_VP.Interfaces;
  13. namespace TeamAAS_VP.ViewModels
  14. {
  15. public class CalibrationViewModel : BindableBase, IConfirmNavigationRequest
  16. {
  17. IRegionManager _regionManager;
  18. IRegionNavigationService _regionNavigationService;
  19. IContainerProvider _container;
  20. IDialogService _dialogService;
  21. IEventAggregator _eventAggregator;
  22. #region 属性
  23. #endregion
  24. #region 命令
  25. private DelegateCommand _LoadedCommand;
  26. public DelegateCommand LoadedCommand =>
  27. _LoadedCommand ?? (_LoadedCommand = new DelegateCommand(ExecuteLoadedCommand));
  28. #endregion
  29. #region 事件
  30. #endregion
  31. public CalibrationViewModel(IRegionManager regionManager, IEventAggregator ea, IRegionNavigationService regionNavigationService, IContainerProvider container, IDialogService dialogService)
  32. {
  33. _regionManager = regionManager;
  34. _regionNavigationService = regionNavigationService;
  35. _container = container;
  36. _dialogService = dialogService;
  37. _eventAggregator = ea;
  38. //订阅权限登录事件
  39. _eventAggregator.GetEvent<UserLoginNotification>().Subscribe(LoginChange);
  40. }
  41. #region 方法
  42. bool isFirstShow = false;
  43. void ExecuteLoadedCommand()
  44. {
  45. if (!isFirstShow)
  46. {
  47. _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationHome");
  48. isFirstShow = true;
  49. }
  50. }
  51. #endregion
  52. #region 继承
  53. /// <summary>
  54. /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
  55. /// </summary>
  56. /// <param name="navigationContext"></param>
  57. /// <param name="continuationCallback"></param>
  58. public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
  59. {
  60. continuationCallback(true);
  61. }
  62. /// <summary>
  63. /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
  64. /// </summary>
  65. /// <param name="navigationContext"></param>
  66. /// <exception cref="NotImplementedException"></exception>
  67. public async void OnNavigatedTo(NavigationContext navigationContext)
  68. {
  69. }
  70. /// <summary>
  71. /// 是否允许导航到此视图模型。
  72. /// </summary>
  73. /// <param name="navigationContext"></param>
  74. /// <returns></returns>
  75. public bool IsNavigationTarget(NavigationContext navigationContext)
  76. {
  77. return true;
  78. }
  79. /// <summary>
  80. /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
  81. /// </summary>
  82. /// <param name="navigationContext"></param>
  83. public void OnNavigatedFrom(NavigationContext navigationContext)
  84. {
  85. }
  86. #endregion
  87. private void LoginChange(Models.User user)
  88. {
  89. }
  90. }
  91. }