123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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";
- private string BackgroundTemplateListFileContentName = "BackgroundTemplateListFileContent";
- 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<object> 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<object>(ChangeTemplateListMod);
- EnterCreateCommand = new DelegateCommand(EnterCreate);
- }
- public void EnterCreate()
- {
- this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().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<SetCurrentTemplateListModEvent>().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<string>("UniCode", out unicode);
- if (IsFirstEnter)
- {
- CurrentTemplateListModName = BackgroundTemplateListColorContentName;
- EnterSelectedTemplateListMod(CurrentTemplateListModName);
- IsFirstEnter = false;
- }
- else
- {
- navigationContext.Parameters.TryGetValue<EnumColorOrFile>("CurrentCreateModName", out CurrentCreateMod);
- if (CurrentCreateMod == EnumColorOrFile.StatusColor)
- {
- CurrentTemplateListModName = "BackgroundTemplateListColorContent";
- }
- else
- {
- CurrentTemplateListModName = "BackgroundTemplateListFileContent";
- }
- EnterSelectedTemplateListMod(CurrentTemplateListModName);
- eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(new stringUnicode
- {
- Unicode = Unicode,
- Status = CurrentTemplateListModName
- });
- }
- }
- }
- }
|