using PDF_Office.EventAggregators; using Prism.Commands; using Prism.Events; using Prism.Mvvm; using Prism.Regions; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; namespace PDF_Office.ViewModels.EditTools.Background { public class BackgroundCreateBaseContentViewModel : BindableBase, INavigationAware { IEventAggregator eventAggregator; IRegionManager backgroundCreateRegion; private string backgroundCreateRegionName; public string BackgroundCreateRegionName { get => backgroundCreateRegionName; set => SetProperty(ref backgroundCreateRegionName, value); } private string _currentCreateName; public string CurrentCreateName { get => _currentCreateName; set=>_currentCreateName= value; } private System.Windows.Visibility backgroundCreateVisible; public System.Windows.Visibility BackgroundCreateVisible { get => backgroundCreateVisible; set => SetProperty(ref backgroundCreateVisible, value); } public DelegateCommand ChangeCreateModCommand { get; set; } public DelegateCommand EnterTemplateListCommand { get; set; } public BackgroundCreateBaseContentViewModel(IRegionManager regionManager,IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; this.backgroundCreateRegion = regionManager; BackgroundCreateRegionName = Guid.NewGuid().ToString(); ChangeCreateModCommand = new DelegateCommand(ChangeCreateMod); EnterTemplateListCommand = new DelegateCommand(EnterTemplateList); EnterSelectedCreateMod("BackgroundCreateColorContent"); } public void EnterTemplateList() { this.eventAggregator.GetEvent().Publish(EnumTemplateListOrCreate.StatusTemplate); } public void EnterSelectedCreateMod(string currentCreateName) { backgroundCreateRegion.RequestNavigate(BackgroundCreateRegionName, currentCreateName); backgroundCreateVisible = System.Windows.Visibility.Visible; } public void ChangeCreateMod(object e) { var args = e as Button; if (args != null) { CurrentCreateName = args.Name; EnterSelectedCreateMod(CurrentCreateName); } } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } public void OnNavigatedTo(NavigationContext navigationContext) { } } }