Welcome to EMC Consulting Blogs Sign in | Join | Help

Jomit's Blog

Technical Enthusiast

Editable Custom Visualizer

We all know that Visualizers are a great feature of Visual Studio 2005 debugger UI. It gives us a really nice meaningful way to look at the data.


 

Visualizer Sample


 

Visual Studio also enables us to create Custom Visualizers using DialogDebuggerVisualizer class. A long time back Howard van Rooijen had created a great tool using visualizers.


There are 4 in-build visualizers available with VS 2005 among which only the dataset visualizer is editable and rest all are read-only visualizers. This gave a thought to

how can I make a custom visualizer editable ?  


The answer is : Simply using the ReplaceObject method


 

public class NewTextVisualizer : DialogDebuggerVisualizer

    {

        override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)

        {

            String sourceString = objectProvider.GetObject().ToString();

            Form1 form = new Form1();

            form.txtData.Text = sourceString;

            windowService.ShowDialog(form);

            sourceString = form.txtData.Text;

            //Replaces the debugee object with the debugger object.

            if (objectProvider.IsObjectReplaceable)

            {

                objectProvider.ReplaceObject(sourceString);

            }       

}

    }

Above is the normal code for creating a custom visualizer which uses the ReplaceObject method. This method replaces the object provided with the edited object, which makes this an editable visualizer.

 

(Added end result preview) :

 Result

 

I have attached a sample solution with a custom Text Visualizer just to make sure that this works. For more details on creating and deploying visualizers Click here.

-Jomit

Published 06 March 2007 14:13 by Jomit.Vaghela
Filed under: , ,

Attachment(s): EditableVisualizer.zip

Comments

No Comments
Anonymous comments are disabled
Powered by Community Server (Personal Edition), by Telligent Systems