1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using Dropbox.Api.Sharing;
- using PDF_Office.EventAggregators;
- using Prism.Commands;
- using Prism.Events;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Windows;
- using System.Linq;
- using System.Windows.Controls;
- using Visibility = System.Windows.Visibility;
- using Dropbox.Api.FileProperties;
- namespace PDF_Office.ViewModels.EditTools.Background
- {
- public class BackgroundContentViewModel : BindableBase,INavigationAware
- {
- public IEventAggregator eventAggregator;
- public IRegionManager backgroundRegion;
- public string TemplateListName = "BackgroundTemplateListBaseContent";
- public string CreateName = "BackgroundCreateBaseContent";
- private string _backgroundSettingsRegionName;
- public string BackgroundSettingsRegionName
- {
- get { return _backgroundSettingsRegionName; }
- set { _backgroundSettingsRegionName = value;}
- }
- private Visibility _backgroundSettingsVisible = Visibility.Collapsed;
- public Visibility BackgroundSettingsVisible
- {
- get { return _backgroundSettingsVisible; }
- set { _backgroundSettingsVisible = value; }
- }
- /// <summary>
- /// 退出EditTool
- /// </summary>
- public DelegateCommand CloseEditToolCommand { get; set; }
- public DelegateCommand<string> EnterSelectedContentCommand { get; set; }
- public BackgroundContentViewModel( IRegionManager regionManager, IEventAggregator eventAggregator)
- {
- this.eventAggregator = eventAggregator;
- this.backgroundRegion = regionManager;
- BackgroundSettingsVisible = Visibility.Visible;
- BackgroundSettingsRegionName = Guid.NewGuid().ToString();
- CloseEditToolCommand = new DelegateCommand(CloseEditTool);
- EnterSelectedContentCommand = new DelegateCommand<string>(EnterSelectedContent);
- eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate);
- }
- public void CloseEditTool()
- {
- this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish();
- }
- public void EnterTemplateListOrCreate(EnumTemplateListOrCreate enumTemplateListOrCreate)
- {
- if(enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
- {
- EnterSelectedContent(TemplateListName);
- }
- else
- {
- EnterSelectedContent(CreateName);
- }
- }
- public void EnterSelectedContent(string SelectedContentName)
- {
- backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, SelectedContentName);
- BackgroundSettingsVisible = Visibility.Visible;
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- EnterSelectedContent(TemplateListName);
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- }
- }
|