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; }
}
///
/// 退出EditTool
///
public DelegateCommand CloseEditToolCommand { get; set; }
public DelegateCommand 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(EnterSelectedContent);
eventAggregator.GetEvent().Subscribe(EnterTemplateListOrCreate);
}
public void CloseEditTool()
{
this.eventAggregator.GetEvent().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)
{
}
}
}