123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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 WatermarkTemplateListTextContentName = "WatermarkTemplateListTextContent";
- private string WatermarkTemplateListFileContentName = "WatermarkTemplateListFileContent";
- public bool IsFirstEnter=true;
- public EnumTextOrFile CurrentCreateMod;
- private string _currentTemplateListModName;
- public string CurrentTemplateListModName
- {
- get { return _currentTemplateListModName; }
- set { _currentTemplateListModName = 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<object> 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<object>(ChangeTemplateListMod);
- EnterCreateCommand = new DelegateCommand(EnterCreate);
- EnterSelectedTemplateListMod("WatermarkTemplateListColorContent");
- }
- public void EnterCreate()
- {
- this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().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)
- {
- CurrentTemplateListModName = args.Name;
- EnterSelectedTemplateListMod(CurrentTemplateListModName);
- eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(CurrentTemplateListModName);
- }
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- if (IsFirstEnter)
- {
- CurrentTemplateListModName = WatermarkTemplateListTextContentName;
- EnterSelectedTemplateListMod(CurrentTemplateListModName);
- IsFirstEnter = false;
- }
- else
- {
- navigationContext.Parameters.TryGetValue<EnumTextOrFile>("CurrentCreateModName", out CurrentCreateMod);
- if (CurrentCreateMod == EnumTextOrFile.StatusText)
- {
- CurrentTemplateListModName = WatermarkTemplateListTextContentName;
- }
- else
- {
- CurrentTemplateListModName = WatermarkTemplateListFileContentName;
- }
- EnterSelectedTemplateListMod(CurrentTemplateListModName);
- eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(CurrentTemplateListModName);
- }
- }
- }
- }
|