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:
@ -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;
|
||||
|
@ -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; } }
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user