2014-07-26 07:12:56 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace RainmeterStudio.UI.Controller
|
|
|
|
|
{
|
|
|
|
|
public class DocumentController
|
|
|
|
|
{
|
|
|
|
|
#region Commands
|
|
|
|
|
|
2014-07-26 10:49:11 +00:00
|
|
|
|
public Command _documentCreateCommand;
|
|
|
|
|
public Command DocumentCreateCommand
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_documentCreateCommand == null)
|
|
|
|
|
{
|
2014-07-28 17:18:18 +00:00
|
|
|
|
_documentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow());
|
2014-07-26 10:49:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _documentCreateCommand;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public event EventHandler<DocumentOpenedEventArgs> DocumentOpened
|
|
|
|
|
{
|
|
|
|
|
add
|
|
|
|
|
{
|
|
|
|
|
DocumentManager.Instance.DocumentOpened += value;
|
|
|
|
|
}
|
|
|
|
|
remove
|
|
|
|
|
{
|
|
|
|
|
DocumentManager.Instance.DocumentOpened -= value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public event EventHandler DocumentClosed;
|
|
|
|
|
|
|
|
|
|
public Window OwnerWindow { get; set; }
|
|
|
|
|
|
|
|
|
|
public DocumentController()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-26 10:49:11 +00:00
|
|
|
|
public void CreateWindow(DocumentTemplate defaultFormat = null, string defaultPath = "")
|
2014-07-26 07:12:56 +00:00
|
|
|
|
{
|
|
|
|
|
// Show dialog
|
|
|
|
|
var dialog = new CreateDocumentDialog()
|
|
|
|
|
{
|
|
|
|
|
Owner = OwnerWindow,
|
|
|
|
|
SelectedFormat = defaultFormat,
|
|
|
|
|
SelectedPath = defaultPath
|
|
|
|
|
};
|
|
|
|
|
bool? res = dialog.ShowDialog();
|
|
|
|
|
|
|
|
|
|
if (!res.HasValue || !res.Value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var format = dialog.SelectedFormat;
|
|
|
|
|
var path = dialog.SelectedPath;
|
|
|
|
|
|
|
|
|
|
// Call manager
|
|
|
|
|
DocumentManager.Instance.Create(format, path);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-26 10:49:11 +00:00
|
|
|
|
public void Create(DocumentTemplate format, string path)
|
2014-07-26 07:12:56 +00:00
|
|
|
|
{
|
|
|
|
|
// Call manager
|
|
|
|
|
DocumentManager.Instance.Create(format, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|