LightManualViewModel.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using Prism.Commands;
  2. using Prism.Events;
  3. using Prism.Ioc;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using TeamAAS_VP.Core;
  10. using TeamAAS_VP.Data;
  11. using TeamAAS_VP.Events;
  12. using TeamAAS_VP.Interfaces;
  13. using TeamAAS_VP.Resources.Languages;
  14. namespace TeamAAS_VP.ViewModels.DebugMod
  15. {
  16. public class LightManualViewModel : BindableBase
  17. {
  18. IContainerProvider _container;
  19. IEventAggregator _eventAggregator;
  20. ILightManagerService _lightManagerService;
  21. IConfigService _configService;
  22. ISystemDatabaseService _systemDatabaseService;
  23. #region 属性
  24. #endregion
  25. #region 命令
  26. private DelegateCommand _LoadedCommand;
  27. public DelegateCommand LoadedCommand =>
  28. _LoadedCommand ?? (_LoadedCommand = new DelegateCommand(ExecuteLoadedCommand));
  29. #endregion
  30. #region 事件
  31. #endregion
  32. public LightManualViewModel(IContainerProvider container, IEventAggregator ea, ILightManagerService lightManagerService, IConfigService configService, ISystemDatabaseService systemDatabaseService)
  33. {
  34. _container = container;
  35. _eventAggregator = ea;
  36. _lightManagerService = lightManagerService;
  37. _configService = configService;
  38. _systemDatabaseService = systemDatabaseService;
  39. //订阅权限登录事件
  40. _eventAggregator.GetEvent<UserLoginNotification>().Subscribe(LoginChange);
  41. }
  42. #region 方法
  43. void ExecuteLoadedCommand()
  44. {
  45. if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator)
  46. {
  47. IsAllowEdit = false;
  48. }
  49. else
  50. {
  51. IsAllowEdit = true;
  52. }
  53. }
  54. #endregion
  55. #region 继承
  56. /// <summary>
  57. /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
  58. /// </summary>
  59. /// <param name="navigationContext"></param>
  60. /// <param name="continuationCallback"></param>
  61. public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
  62. {
  63. continuationCallback(true);
  64. }
  65. /// <summary>
  66. /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
  67. /// </summary>
  68. /// <param name="navigationContext"></param>
  69. /// <exception cref="NotImplementedException"></exception>
  70. public async void OnNavigatedTo(NavigationContext navigationContext)
  71. {
  72. }
  73. /// <summary>
  74. /// 是否允许导航到此视图模型。
  75. /// </summary>
  76. /// <param name="navigationContext"></param>
  77. /// <returns></returns>
  78. public bool IsNavigationTarget(NavigationContext navigationContext)
  79. {
  80. return true;
  81. }
  82. /// <summary>
  83. /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
  84. /// </summary>
  85. /// <param name="navigationContext"></param>
  86. public void OnNavigatedFrom(NavigationContext navigationContext)
  87. {
  88. }
  89. #endregion
  90. private bool _IsAllowEdit = false;
  91. public bool IsAllowEdit
  92. {
  93. get { return _IsAllowEdit; }
  94. set { SetProperty(ref _IsAllowEdit, value); }
  95. }
  96. private void LoginChange(Models.User user)
  97. {
  98. if (user.userPart == Enums.UserPart.Operator)
  99. {
  100. IsAllowEdit = false;
  101. }
  102. else
  103. {
  104. IsAllowEdit = true;
  105. }
  106. }
  107. }
  108. }