Work on document manager

This commit is contained in:
2014-07-29 19:42:52 +03:00
parent 1c4c7ccfb0
commit 09224d9af7
29 changed files with 798 additions and 280 deletions

View File

@ -4,29 +4,67 @@ using System.IO;
using System.Linq;
using System.Text;
using RainmeterStudio.Model;
using System.ComponentModel;
namespace RainmeterStudio.Documents.Text
{
public class TextDocument : IDocument
{
public string Name
{
get
{
return Path.GetFileName(FilePath);
}
}
public string FilePath
{
get; set;
}
private Reference _reference;
private bool _isDirty;
/// <summary>
/// Gets or sets the text associated with this document
/// </summary>
public string Text
{
get; set;
}
/// <summary>
/// Gets or sets the reference of this document
/// </summary>
public Reference Reference
{
get
{
return _reference;
}
set
{
_reference = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Reference"));
}
}
/// <summary>
/// Gets a property indicating if this file was modified and not saved
/// </summary>
public bool IsDirty
{
get
{
return _isDirty;
}
set
{
_isDirty = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("IsDirty"));
}
}
/// <summary>
/// Triggered when the value of a property changes
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Initializes the text document
/// </summary>
public TextDocument()
{
Text = String.Empty;

View File

@ -7,7 +7,7 @@ using RainmeterStudio.Model;
namespace RainmeterStudio.Documents.Text
{
public class TextEditor : IDocumentEditor
/*public class TextEditor : IDocumentEditor
{
private TextDocument _document;
private TextEditorControl _control;
@ -23,5 +23,5 @@ namespace RainmeterStudio.Documents.Text
public override string Title { get { return _document.Name; } }
public override System.Windows.UIElement EditorUI { get { return _control; } }
}
}*/
}

View File

@ -8,7 +8,7 @@ using RainmeterStudio.Model;
namespace RainmeterStudio.Documents.Text
{
public class TextEditorFactory : IDocumentEditorFactory
/*public class TextEditorFactory : IDocumentEditorFactory
{
private TextStorage _storage = new TextStorage();
@ -35,7 +35,6 @@ namespace RainmeterStudio.Documents.Text
}
}
public IDocumentEditor CreateEditor(IDocument document)
{
TextDocument textDocument = document as TextDocument;
@ -55,5 +54,5 @@ namespace RainmeterStudio.Documents.Text
return document;
}
}
}*/
}

View File

@ -13,7 +13,8 @@ namespace RainmeterStudio.Documents.Text
IDocument IDocumentStorage.Read(string path)
{
TextDocument document = new TextDocument();
document.FilePath = path;
document.Reference.Path = path;
document.Reference.Name = Path.GetFileName(path);
document.Text = File.ReadAllText(path);
return document;
@ -60,5 +61,10 @@ namespace RainmeterStudio.Documents.Text
// Not found, probably text file
return true;
}
public bool CanWrite(Type documentType)
{
return documentType.Equals(typeof(TextDocument));
}
}
}