mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed text editor not working.
This commit is contained in:
@ -16,9 +16,9 @@ namespace RainmeterStudio.TextEditorPlugin
|
||||
/// <summary>
|
||||
/// Gets or sets the text associated with this document
|
||||
/// </summary>
|
||||
public List<string> Lines
|
||||
public string Text
|
||||
{
|
||||
get; private set;
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -67,7 +67,7 @@ namespace RainmeterStudio.TextEditorPlugin
|
||||
/// </summary>
|
||||
public TextDocument()
|
||||
{
|
||||
Lines = new List<string>();
|
||||
Text = String.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<TextBox Name="text" AcceptsReturn="True"
|
||||
TextChanged="text_TextChanged"/>
|
||||
<TextBox Name="textBox" AcceptsReturn="True" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
@ -24,18 +24,17 @@ namespace RainmeterStudio.TextEditorPlugin
|
||||
public TextEditorControl(TextDocument document)
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
|
||||
_document = document;
|
||||
|
||||
StringBuilder txt = new StringBuilder();
|
||||
document.Lines.ForEach((line) => txt.AppendLine(line));
|
||||
|
||||
text.Text = txt.ToString();
|
||||
textBox.Text = _document.Text;
|
||||
textBox.TextChanged += text_TextChanged;
|
||||
}
|
||||
|
||||
private void text_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
_document.IsDirty = true;
|
||||
_document.Text = textBox.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace RainmeterStudio.TextEditorPlugin
|
||||
{
|
||||
TextDocument document = new TextDocument();
|
||||
document.Reference = new Reference(Path.GetFileName(path), path);
|
||||
document.Lines.AddRange(File.ReadAllLines(path));
|
||||
document.Text = File.ReadAllText(path);
|
||||
|
||||
return document;
|
||||
}
|
||||
@ -30,7 +30,7 @@ namespace RainmeterStudio.TextEditorPlugin
|
||||
if (textDocument == null)
|
||||
throw new ArgumentException("Provided document is not supported by this storage.");
|
||||
|
||||
File.WriteAllLines(path, textDocument.Lines);
|
||||
File.WriteAllText(path, textDocument.Text);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
Reference in New Issue
Block a user