From 5c633fef8bcf8d065f84dbb37422fb777ebc576d Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 21 Apr 2009 12:55:43 +0000 Subject: [PATCH] * ExampleBrowser.cs: Worked around RichTextBox crash with empty text on Mono 2.0. --- Source/Examples/ExampleBrowser.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/Examples/ExampleBrowser.cs b/Source/Examples/ExampleBrowser.cs index b94739d2..dab1015a 100644 --- a/Source/Examples/ExampleBrowser.cs +++ b/Source/Examples/ExampleBrowser.cs @@ -60,16 +60,28 @@ namespace Examples private void treeViewSamples_AfterSelect(object sender, TreeViewEventArgs e) { + const string no_docs = "Documentation has not been entered."; + const string no_source = "Source code has not been entered."; + if (e.Node.Tag != null && !String.IsNullOrEmpty(((ExampleInfo)e.Node.Tag).Attribute.Documentation)) { - richTextBoxDescription.Rtf = (string)Resources.ResourceManager.GetObject(((ExampleInfo)e.Node.Tag).Attribute.Documentation + "Doc"); - richTextBoxSource.Text = (string)Resources.ResourceManager.GetObject(((ExampleInfo)e.Node.Tag).Attribute.Documentation); + string docs = (string)Resources.ResourceManager.GetObject(((ExampleInfo)e.Node.Tag).Attribute.Documentation + "Doc"); + string source = (string)Resources.ResourceManager.GetObject(((ExampleInfo)e.Node.Tag).Attribute.Documentation); + + if (String.IsNullOrEmpty(docs)) + richTextBoxDescription.Text = no_docs; + else + richTextBoxDescription.Rtf = docs; + + if (String.IsNullOrEmpty(source)) + richTextBoxSource.Text = no_source; + else + richTextBoxSource.Text = source; } else { - richTextBoxDescription.Rtf = String.Empty; - richTextBoxDescription.Text = "Documentation has not been entered."; - richTextBoxSource.Rtf = String.Empty; + richTextBoxDescription.Text = no_docs; + richTextBoxSource.Text = no_source; } }