BackgroundCreateBaseContentViewModel.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using PDF_Office.EventAggregators;
  2. using Prism.Commands;
  3. using Prism.Events;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Controls;
  12. namespace PDF_Office.ViewModels.EditTools.Background
  13. {
  14. public class BackgroundCreateBaseContentViewModel : BindableBase, INavigationAware
  15. {
  16. IEventAggregator eventAggregator;
  17. IRegionManager backgroundCreateRegion;
  18. private string backgroundCreateRegionName;
  19. public string BackgroundCreateRegionName
  20. {
  21. get => backgroundCreateRegionName;
  22. set => SetProperty(ref backgroundCreateRegionName, value);
  23. }
  24. private string _currentCreateName;
  25. public string CurrentCreateName
  26. {
  27. get => _currentCreateName;
  28. set=>_currentCreateName= value;
  29. }
  30. private System.Windows.Visibility backgroundCreateVisible;
  31. public System.Windows.Visibility BackgroundCreateVisible
  32. {
  33. get => backgroundCreateVisible;
  34. set => SetProperty(ref backgroundCreateVisible, value);
  35. }
  36. public DelegateCommand<object> ChangeCreateModCommand { get; set; }
  37. public DelegateCommand EnterTemplateListCommand { get; set; }
  38. public BackgroundCreateBaseContentViewModel(IRegionManager regionManager,IEventAggregator eventAggregator)
  39. {
  40. this.eventAggregator = eventAggregator;
  41. this.backgroundCreateRegion = regionManager;
  42. BackgroundCreateRegionName = Guid.NewGuid().ToString();
  43. ChangeCreateModCommand = new DelegateCommand<object>(ChangeCreateMod);
  44. EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
  45. EnterSelectedCreateMod("BackgroundCreateColorContent");
  46. }
  47. public void EnterTemplateList()
  48. {
  49. this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusTemplate);
  50. }
  51. public void EnterSelectedCreateMod(string currentCreateName)
  52. {
  53. backgroundCreateRegion.RequestNavigate(BackgroundCreateRegionName, currentCreateName);
  54. backgroundCreateVisible = System.Windows.Visibility.Visible;
  55. }
  56. public void ChangeCreateMod(object e)
  57. {
  58. var args = e as Button;
  59. if (args != null)
  60. {
  61. CurrentCreateName = args.Name;
  62. EnterSelectedCreateMod(CurrentCreateName);
  63. }
  64. }
  65. public bool IsNavigationTarget(NavigationContext navigationContext)
  66. {
  67. return true;
  68. }
  69. public void OnNavigatedFrom(NavigationContext navigationContext)
  70. {
  71. }
  72. public void OnNavigatedTo(NavigationContext navigationContext)
  73. {
  74. }
  75. }
  76. }