Since I do a lot of debugging with Rich Text manipulations, I decided to write a simple "RTF Debugger Visualizer" which looks like this
#region Namespaces
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualStudio.DebuggerVisualizers;
using RtfVisualizer;
#endregion
[assembly: DebuggerVisualizer(
typeof (RTFDebuggerVisualizer),
typeof (VisualizerObjectSource),
Target = typeof (String),
Description = "RTF Visualizer")]
namespace RtfVisualizer
{
public class RTFDebuggerVisualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService,
IVisualizerObjectProvider objectProvider)
{
string rtf = (String) objectProvider.GetObject();
Form form = new Form();
form.Text = "RTF Visualizer";
form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
form.Size = new Size(600, 400);
RichTextBox richTextBox = new RichTextBox();
richTextBox.Rtf = rtf;
richTextBox.Dock = DockStyle.Fill;
richTextBox.Parent = form;
windowService.ShowDialog(form);
}
}
}
But the Visualizer shows the Rtf without formatting as if it's loading the plain text.
For example:
Something like this -
Looks like this -
Test RTF:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}
\viewkind4\uc1\pard\cf1\b\f0\fs36 Hell\cf0\b0\fs24 \i Oh \i0 ! \cf2\b World\b0 \cf0\f1\fs17\par
}
I did debug the visualizer - it is receiving the the correct(valid) Rich Text.
What am I missing ? Why does Rich Text look like plain text inside the visualizer ?
Thanks in advance! :)