开发者

How can I create a custom image adorner add-in for numerical arrays in Visual Studio 2010?

I work with a lot of floating-point images, and would find it extremely useful to have an image-based representation of my arrays. I'd like to create a WPF UserControl that renders the data array (as shown below) as an image, instead of a scrollable list of text values.

Is this possible? I have looked at the MDSN documentation on VS 2010 extensibility, at SO's list of VS 2010 extensions, and at this topic on creating a custom editor, but I'm a bit lost on where to start.

How can I create a custom image adorner add-in for numerical arrays in Visual Studio 2010?

Update 1:

Thanks to Brian and Basarat Ali for the leads on DebuggerVisualizer. Looks like the correct strategy, EXCEPT that unfortunately a visualizer for any type of arrays is disallowed.

A work-around (of limited utility) is to visualize a wrapper object.

At Brian's suggestion, I have posted a solution on CodePlex:

VS2010 Debugger Visualizers Contrib (http://debuggervisualizers.codeplex.com/).

The project's source code demonstrates a working wrapper visualizer a开发者_如何学JAVAnd a non-functional "raw" data visualizer for a 1D double[] array. Here's a screenshot of the test console running:

How can I create a custom image adorner add-in for numerical arrays in Visual Studio 2010?

If anyone has any suggestions on how to work-around this problem, please let me know!

Also, any explanation of why System.Array cannot be visualized is welcome!

Update 2:

I just re-searched SO with the word DebuggerVisualizer, and find this to be previously asked. Looks like user Will Dean suggests implementing Project Mole's work-around using a WeakReference. Don't see how this would work in a DebuggerVisualizer, though.

Update 3:

Josh Smith of Project Mole just suggested a very helpful work around (thanks Josh!):

Note, you can use your ArrayWrapper approach without needing to modify your source code to open a visualizer. You can type this into the Watch window in VS:

new YourNamespace.ArrayWrapper(myArray);

Hit the Enter key, then you should see a magnifying glass icon in the Watch window next to that line of code. Click it to open your custom visualizer.


You should create a debugger visualizer. Here's a walkthrough : http://msdn.microsoft.com/en-us/library/ms164759.aspx . I believe that what you want is to be able to view all the results in an external program. For this you can just add an export option to you list to export as a csv file. However if you still feel you want a bitmap you can convert the list to an image using RenderTargetBitmap : http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx


Since this is for runtime information in the debugger, you might consider a DebuggerVisualizer rather than an editor extension. There are some trade-offs, I am unclear which would be best for this.

(In any case, I think it is possible, and it does look useful, and I hope someone with a spare weekend hacks one out and posts the source code.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜