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:
14
RainmeterEditor/Model/DocumentFormat.cs
Normal file
14
RainmeterEditor/Model/DocumentFormat.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace RainmeterEditor.Model
|
||||
{
|
||||
public class DocumentFormat
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
17
RainmeterEditor/Model/Events/DocumentOpenedEventArgs.cs
Normal file
17
RainmeterEditor/Model/Events/DocumentOpenedEventArgs.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterEditor.Model.Events
|
||||
{
|
||||
public class DocumentOpenedEventArgs : EventArgs
|
||||
{
|
||||
public IDocumentEditor Editor { get; private set; }
|
||||
|
||||
public DocumentOpenedEventArgs(IDocumentEditor editor)
|
||||
{
|
||||
Editor = editor;
|
||||
}
|
||||
}
|
||||
}
|
13
RainmeterEditor/Model/IDocument.cs
Normal file
13
RainmeterEditor/Model/IDocument.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterEditor.Model
|
||||
{
|
||||
public interface IDocument
|
||||
{
|
||||
string Name { get; }
|
||||
string FilePath { get; }
|
||||
}
|
||||
}
|
136
RainmeterEditor/Model/IDocumentEditor.cs
Normal file
136
RainmeterEditor/Model/IDocumentEditor.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace RainmeterEditor.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
|
||||
}
|
||||
}
|
39
RainmeterEditor/Model/IDocumentEditorFactory.cs
Normal file
39
RainmeterEditor/Model/IDocumentEditorFactory.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RainmeterEditor.Storage;
|
||||
|
||||
namespace RainmeterEditor.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<DocumentFormat> 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(DocumentFormat format, string path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the storage of this factory
|
||||
/// </summary>
|
||||
IDocumentStorage Storage { get; }
|
||||
}
|
||||
}
|
26
RainmeterEditor/Model/IDocumentStorage.cs
Normal file
26
RainmeterEditor/Model/IDocumentStorage.cs
Normal file
@ -0,0 +1,26 @@
|
||||
namespace RainmeterEditor.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);
|
||||
}
|
||||
}
|
30
RainmeterEditor/Model/Property.cs
Normal file
30
RainmeterEditor/Model/Property.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterEditor.Model
|
||||
{
|
||||
public class Property
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
private object _value;
|
||||
public object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
|
||||
if (ValueChanged != null)
|
||||
ValueChanged(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler ValueChanged;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user