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.Windows.Controls; namespace PDF_Office.ViewModels.EditTools.Watermark { public class WatermarkTemplateListBaseContentViewModel : BindableBase, INavigationAware { public IRegionManager watermarkTemplateListRegion; private readonly IEventAggregator eventAggregator; private string _currentTemplateListName; public string CurrentTemplateListName { get { return _currentTemplateListName; } set { _currentTemplateListName = value; } } private string watermarkTemplateListRegionName; public string WatermarkTemplateListRegionName { get => watermarkTemplateListRegionName; set => SetProperty(ref watermarkTemplateListRegionName, value); } private System.Windows.Visibility watermarkTemplateListVisible; public System.Windows.Visibility WatermarkTemplateListVisible { get => watermarkTemplateListVisible; set => SetProperty(ref watermarkTemplateListVisible, value); } public DelegateCommand ChangeTemplateListModCommand { get; set; } public DelegateCommand EnterCreateCommand { get; set; } public WatermarkTemplateListBaseContentViewModel(IRegionManager watermarkTemplateListRegion, IEventAggregator eventAggregator) { this.watermarkTemplateListRegion = watermarkTemplateListRegion; this.eventAggregator = eventAggregator; WatermarkTemplateListRegionName = Guid.NewGuid().ToString(); ChangeTemplateListModCommand = new DelegateCommand(ChangeTemplateListMod); EnterCreateCommand = new DelegateCommand(EnterCreate); EnterSelectedTemplateListMod("WatermarkTemplateListColorContent"); } public void EnterCreate() { this.eventAggregator.GetEvent().Publish(EnumTemplateListOrCreate.StatusCreate); } public void EnterSelectedTemplateListMod(string currentTemplateListName) { watermarkTemplateListRegion.RequestNavigate(WatermarkTemplateListRegionName, currentTemplateListName); watermarkTemplateListVisible = System.Windows.Visibility.Visible; } public void ChangeTemplateListMod(object e) { var args = e as Button; if (args != null) { CurrentTemplateListName = args.Name; EnterSelectedTemplateListMod(CurrentTemplateListName); } } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } public void OnNavigatedTo(NavigationContext navigationContext) { } } }