mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Work on document manager
This commit is contained in:
@ -1,14 +0,0 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace RainmeterStudio.Model
|
||||
{
|
||||
public class DocumentTemplate
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public ImageSource Icon { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string DefaultExtension { get; set; }
|
||||
public IDocumentEditorFactory Factory { get; set; }
|
||||
public string Category { get; set; }
|
||||
}
|
||||
}
|
35
RainmeterStudio/Model/DocumentTemplate.cs
Normal file
35
RainmeterStudio/Model/DocumentTemplate.cs
Normal file
@ -0,0 +1,35 @@
|
||||
namespace RainmeterStudio.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a document template
|
||||
/// </summary>
|
||||
public abstract class DocumentTemplate
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the document template name
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default extension of this template
|
||||
/// </summary>
|
||||
public string DefaultExtension { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the document template
|
||||
/// </summary>
|
||||
/// <param name="name">Name of template</param>
|
||||
/// <param name="defaultExtension">Default extension</param>
|
||||
public DocumentTemplate(string name, string defaultExtension)
|
||||
{
|
||||
Name = name;
|
||||
DefaultExtension = defaultExtension;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a document using this template
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract IDocument CreateDocument();
|
||||
}
|
||||
}
|
@ -2,16 +2,59 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RainmeterStudio.Documents;
|
||||
|
||||
namespace RainmeterStudio.Model.Events
|
||||
{
|
||||
public class DocumentOpenedEventArgs : EventArgs
|
||||
public abstract class DocumentEventArgsBase : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the newly created document editor
|
||||
/// </summary>
|
||||
public IDocumentEditor Editor { get; private set; }
|
||||
|
||||
public DocumentOpenedEventArgs(IDocumentEditor editor)
|
||||
/// <summary>
|
||||
/// Gets the opened document
|
||||
/// </summary>
|
||||
public IDocument Document { get { return Editor.AttachedDocument; } }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the DocumentOpenedEventArgs
|
||||
/// </summary>
|
||||
/// <param name="editor">The document editor</param>
|
||||
public DocumentEventArgsBase(IDocumentEditor editor)
|
||||
{
|
||||
Editor = editor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event arguments for the document opened event
|
||||
/// </summary>
|
||||
public class DocumentOpenedEventArgs : DocumentEventArgsBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the DocumentOpenedEventArgs
|
||||
/// </summary>
|
||||
/// <param name="editor">The document editor</param>
|
||||
public DocumentOpenedEventArgs(IDocumentEditor editor)
|
||||
: base(editor)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event arguments for the document closed event
|
||||
/// </summary>
|
||||
public class DocumentClosedEventArgs : DocumentEventArgsBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the DocumentClosedEventArgs
|
||||
/// </summary>
|
||||
/// <param name="editor">The document editor</param>
|
||||
public DocumentClosedEventArgs(IDocumentEditor editor)
|
||||
: base(editor)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterStudio.Model
|
||||
{
|
||||
public interface IDocument
|
||||
public interface IDocument : INotifyPropertyChanged
|
||||
{
|
||||
string Name { get; }
|
||||
string FilePath { get; }
|
||||
Reference Reference { get; }
|
||||
bool IsDirty { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,136 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace RainmeterStudio.Model
|
||||
{
|
||||
public abstract class IDocumentEditor : IDisposable
|
||||
{
|
||||
#region Dirty flag
|
||||
|
||||
private bool _dirty = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a flag indicating if the active document is dirty (modified and not saved)
|
||||
/// </summary>
|
||||
public virtual bool Dirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dirty;
|
||||
}
|
||||
protected set
|
||||
{
|
||||
_dirty = value;
|
||||
if (DirtyChanged != null)
|
||||
DirtyChanged(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the dirty flag changes
|
||||
/// </summary>
|
||||
public event EventHandler DirtyChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Document
|
||||
|
||||
/// <summary>
|
||||
/// Gets the opened document
|
||||
/// </summary>
|
||||
public abstract IDocument Document { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title to be displayed in the title bar
|
||||
/// </summary>
|
||||
public abstract string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the title changes
|
||||
/// </summary>
|
||||
public event EventHandler TitleChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region EditorUI
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor UI
|
||||
/// </summary>
|
||||
public abstract UIElement EditorUI { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Selection properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating if this editor uses the selection properties window
|
||||
/// </summary>
|
||||
public virtual bool UsesSelectionProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the selected object
|
||||
/// </summary>
|
||||
public virtual string SelectionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of properties for the currently selected object
|
||||
/// </summary>
|
||||
public virtual IEnumerable<string> SelectionProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the selected object changes (used to update properties)
|
||||
/// </summary>
|
||||
public event EventHandler SelectionChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Toolbox
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of items to populate the toolbox
|
||||
/// </summary>
|
||||
public virtual IEnumerable<string> ToolboxItems
|
||||
{
|
||||
get
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler ToolboxChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RainmeterStudio.Storage;
|
||||
|
||||
namespace RainmeterStudio.Model
|
||||
{
|
||||
public interface IDocumentEditorFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the editor
|
||||
/// </summary>
|
||||
string EditorName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Formats that will be used to populate the 'create document' dialog
|
||||
/// </summary>
|
||||
IEnumerable<DocumentTemplate> CreateDocumentFormats { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new editor object
|
||||
/// </summary>
|
||||
/// <param name="document">Document to be edited by the editor</param>
|
||||
/// <returns>A new document editor</returns>
|
||||
IDocumentEditor CreateEditor(IDocument document);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new document
|
||||
/// </summary>
|
||||
/// <returns>A new document</returns>
|
||||
IDocument CreateDocument(DocumentTemplate format, string path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the storage of this factory
|
||||
/// </summary>
|
||||
IDocumentStorage Storage { get; }
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
namespace RainmeterStudio.Model
|
||||
{
|
||||
public interface IDocumentStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads a document from file
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file</param>
|
||||
/// <returns>Read document</returns>
|
||||
IDocument Read(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a document to a file
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file</param>
|
||||
/// <param name="document">Document to write</param>
|
||||
void Write(string path, IDocument document);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the file can be read by this storage
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file</param>
|
||||
/// <returns>True if file can be read</returns>
|
||||
bool CanRead(string path);
|
||||
}
|
||||
}
|
@ -1,15 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterStudio.Model
|
||||
{
|
||||
public class Property
|
||||
public class Property : INotifyPropertyChanged
|
||||
{
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the property
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
private object _value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the property
|
||||
/// </summary>
|
||||
public object Value
|
||||
{
|
||||
get
|
||||
@ -20,11 +28,25 @@ namespace RainmeterStudio.Model
|
||||
{
|
||||
_value = value;
|
||||
|
||||
if (ValueChanged != null)
|
||||
ValueChanged(this, new EventArgs());
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("Value"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the value changes
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public event EventHandler ValueChanged;
|
||||
/// <summary>
|
||||
/// Initializes this property
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the property</param>
|
||||
/// <param name="value">Value of the property</param>
|
||||
public Property(string name, object value = null)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user