using ComPDFKitViewer.PdfViewer; using Dropbox.Api.FileProperties; using PDF_Master.EventAggregators; using PDF_Master.Model; using Prism.Commands; using Prism.Events; using Prism.Mvvm; using Prism.Regions; using System; using System.Collections.Generic; using System.Drawing.Printing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; namespace PDF_Master.ViewModels.EditTools.Background { public class BackgroundTemplateListBaseContentViewModel : BindableBase, INavigationAware { public IRegionManager backgroundTemplateListRegion; private readonly IEventAggregator eventAggregator; private string BackgroundTemplateListColorContentName = "BackgroundTemplateListColorContent"; public EnumColorOrFile CurrentCreateMod; private string _currentTemplateListModName; public string CurrentTemplateListModName { get { return _currentTemplateListModName; } set { _currentTemplateListModName = value; } } private string backgroundTemplateListRegionName; public string BackgroundTemplateListRegionName { get => backgroundTemplateListRegionName; set => SetProperty(ref backgroundTemplateListRegionName, value); } private System.Windows.Visibility backgroundTemplateListVisible; public System.Windows.Visibility BackgroundTemplateListVisible { get => backgroundTemplateListVisible; set => SetProperty(ref backgroundTemplateListVisible, value); } private bool isFirstEnter = true; public bool IsFirstEnter { get => isFirstEnter; set => isFirstEnter = value; } public DelegateCommand ChangeTemplateListModCommand { get; set; } public DelegateCommand EnterCreateCommand { get; set; } public string unicode = null; public string Unicode = null; public BackgroundTemplateListBaseContentViewModel(IRegionManager backgroundTemplateListRegion, IEventAggregator eventAggregator) { this.backgroundTemplateListRegion = backgroundTemplateListRegion; this.eventAggregator = eventAggregator; Unicode = App.mainWindowViewModel.SelectedItem.Unicode; BackgroundTemplateListRegionName = Guid.NewGuid().ToString(); ChangeTemplateListModCommand = new DelegateCommand(ChangeTemplateListMod); EnterCreateCommand = new DelegateCommand(EnterCreate); } public void EnterCreate() { this.eventAggregator.GetEvent().Publish(new EnumTemplateListOrCreateUnicode {Unicode=Unicode,Status= EnumTemplateListOrCreate.StatusCreate }); } public void EnterSelectedTemplateListMod(string currentTemplateListName) { NavigationParameters param = new NavigationParameters(); param.Add("UniCode", unicode); backgroundTemplateListRegion.RequestNavigate(BackgroundTemplateListRegionName, currentTemplateListName); backgroundTemplateListVisible = System.Windows.Visibility.Visible; } public void ChangeTemplateListMod(object e) { var args = e as Button; if (args != null) { CurrentTemplateListModName = args.Name; EnterSelectedTemplateListMod(CurrentTemplateListModName); eventAggregator.GetEvent().Publish(new stringUnicode { Unicode = Unicode,Status = CurrentTemplateListModName}); } } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } public void OnNavigatedTo(NavigationContext navigationContext) { navigationContext.Parameters.TryGetValue("UniCode", out unicode); if (IsFirstEnter) { CurrentTemplateListModName = BackgroundTemplateListColorContentName; EnterSelectedTemplateListMod(CurrentTemplateListModName); IsFirstEnter = false; } else { navigationContext.Parameters.TryGetValue("CurrentCreateModName", out CurrentCreateMod); if (CurrentCreateMod == EnumColorOrFile.StatusColor) { CurrentTemplateListModName = "BackgroundTemplateListColorContent"; } else { CurrentTemplateListModName = "BackgroundTemplateListFileContent"; } EnterSelectedTemplateListMod(CurrentTemplateListModName); eventAggregator.GetEvent().Publish(new stringUnicode { Unicode = Unicode, Status = CurrentTemplateListModName }); } } } }