mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
Generalized plaintext-to-FlowDocument methods.
This commit is contained in:
parent
8cd51ae896
commit
cb870c592a
@ -40,7 +40,7 @@ namespace GARbro.GUI
|
||||
public AboutBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
LicenseTabText.Document = GetLicenseDoc();
|
||||
LicenseTabText.Document = GetResourceDoc ("GARbro.GUI.LICENSE");
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
@ -50,13 +50,22 @@ namespace GARbro.GUI
|
||||
|
||||
#region License text backend
|
||||
|
||||
static FlowDocument GetLicenseDoc ()
|
||||
static FlowDocument GetResourceDoc (string resource)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
using (var stream = assembly.GetManifestResourceStream ("GARbro.GUI.LICENSE"))
|
||||
using (var stream = assembly.GetManifestResourceStream (resource))
|
||||
{
|
||||
if (null == stream)
|
||||
return new FlowDocument();
|
||||
return ReadPlainText (stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read plain text from stream and return it as FlowDocument.
|
||||
/// </summary>
|
||||
static FlowDocument ReadPlainText (Stream stream)
|
||||
{
|
||||
using (var reader = new StreamReader (stream))
|
||||
{
|
||||
var doc = new FlowDocument();
|
||||
@ -85,7 +94,6 @@ namespace GARbro.GUI
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user