BackgroundTemplateListBaseContentViewModel.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using Dropbox.Api.FileProperties;
  2. using PDF_Office.EventAggregators;
  3. using Prism.Commands;
  4. using Prism.Events;
  5. using Prism.Mvvm;
  6. using Prism.Regions;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Drawing.Printing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Controls;
  14. namespace PDF_Office.ViewModels.EditTools.Background
  15. {
  16. public class BackgroundTemplateListBaseContentViewModel : BindableBase, INavigationAware
  17. {
  18. public IRegionManager backgroundTemplateListRegion;
  19. private readonly IEventAggregator eventAggregator;
  20. private string _currentTemplateListName;
  21. public string CurrentTemplateListName
  22. {
  23. get { return _currentTemplateListName; }
  24. set { _currentTemplateListName = value; }
  25. }
  26. private string backgroundTemplateListRegionName;
  27. public string BackgroundTemplateListRegionName
  28. {
  29. get => backgroundTemplateListRegionName;
  30. set => SetProperty(ref backgroundTemplateListRegionName, value);
  31. }
  32. private System.Windows.Visibility backgroundTemplateListVisible;
  33. public System.Windows.Visibility BackgroundTemplateListVisible
  34. {
  35. get => backgroundTemplateListVisible;
  36. set => SetProperty(ref backgroundTemplateListVisible, value);
  37. }
  38. public DelegateCommand<object> ChangeTemplateListModCommand { get; set; }
  39. public DelegateCommand EnterCreateCommand { get; set; }
  40. public BackgroundTemplateListBaseContentViewModel(IRegionManager backgroundTemplateListRegion, IEventAggregator eventAggregator)
  41. {
  42. this.backgroundTemplateListRegion = backgroundTemplateListRegion;
  43. this.eventAggregator = eventAggregator;
  44. BackgroundTemplateListRegionName = Guid.NewGuid().ToString();
  45. ChangeTemplateListModCommand = new DelegateCommand<object>(ChangeTemplateListMod);
  46. EnterCreateCommand = new DelegateCommand(EnterCreate);
  47. EnterSelectedTemplateListMod("BackgroundTemplateListColorContent");
  48. }
  49. public void EnterCreate()
  50. {
  51. this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusCreate);
  52. }
  53. public void EnterSelectedTemplateListMod(string currentTemplateListName)
  54. {
  55. backgroundTemplateListRegion.RequestNavigate(BackgroundTemplateListRegionName, currentTemplateListName);
  56. backgroundTemplateListVisible = System.Windows.Visibility.Visible;
  57. }
  58. public void ChangeTemplateListMod(object e)
  59. {
  60. var args = e as Button;
  61. if (args != null)
  62. {
  63. CurrentTemplateListName = args.Name;
  64. EnterSelectedTemplateListMod(CurrentTemplateListName);
  65. }
  66. }
  67. public bool IsNavigationTarget(NavigationContext navigationContext)
  68. {
  69. return true;
  70. }
  71. public void OnNavigatedFrom(NavigationContext navigationContext)
  72. {
  73. }
  74. public void OnNavigatedTo(NavigationContext navigationContext)
  75. {
  76. }
  77. }
  78. }