VisionSolutionViewModel.cs 3.3 KB

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