using System; using System.Collections.Generic; using System.Linq; using System.Text; using RainmeterStudio.Business; using RainmeterStudio.UI.Dialogs; using RainmeterStudio.Model.Events; using RainmeterStudio.Model; using System.Windows; using System.Windows.Input; using System.Windows.Media.Imaging; using RainmeterStudio.Documents; namespace RainmeterStudio.UI.Controller { public class DocumentController { #region Managers /// /// Gets or sets the document manager /// protected DocumentManager DocumentManager { get; private set; } /// /// Gets or sets the project manager /// protected ProjectManager ProjectManager { get; private set; } #endregion #region Commands public Command DocumentCreateCommand { get; private set; } #endregion /// /// Triggered when a document is opened /// public event EventHandler DocumentOpened { add { DocumentManager.DocumentOpened += value; } remove { DocumentManager.DocumentOpened -= value; } } /// /// Triggered when a document is closed /// public event EventHandler DocumentClosed { add { DocumentManager.DocumentClosed += value; } remove { DocumentManager.DocumentClosed -= value; } } public Window OwnerWindow { get; set; } public DocumentController(DocumentManager documentManager, ProjectManager projectManager) { DocumentManager = documentManager; ProjectManager = projectManager; DocumentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow()); } public void CreateWindow(DocumentTemplate defaultFormat = null, string defaultPath = "") { // Show dialog var dialog = new CreateDocumentDialog() { Owner = OwnerWindow, SelectedTemplate = defaultFormat, SelectedPath = defaultPath }; bool? res = dialog.ShowDialog(); if (!res.HasValue || !res.Value) return; var format = dialog.SelectedTemplate; var path = dialog.SelectedPath; // Call manager DocumentManager.Create(format); } public void Create(DocumentTemplate format) { // Call manager DocumentManager.Create(format); } } }