/// <summary> /// Clears and updates the contents. /// </summary> private void HighlightContents() { if (_richTextBox != null) { _richTextBox.Blocks.Clear(); if (!string.IsNullOrEmpty(Text)) { RichTextBoxFormatter rtbf = new RichTextBoxFormatter(_richTextBox); CodeColorizer cc; if (_colorizer != null && _colorizer.IsAlive) { cc = (CodeColorizer)_colorizer.Target; } else { cc = new CodeColorizer(); _colorizer = new WeakReference(cc); } ILanguage language = CreateLanguageInstance(SourceLanguage); cc.Colorize(Text, language, rtbf, new DefaultStyleSheet()); } } }