如何在 Visual Studio 2010 中为数值数组创建自定义图像装饰器加载项?

发布于 2024-10-01 06:59:44 字数 2293 浏览 0 评论 0 原文

我使用大量浮点图像,并且发现对数组进行基于图像的表示非常有用。我想创建一个 WPF UserControl,它将数据数组(如下所示)呈现为图像,而不是可滚动的文本值列表。

这可能吗?我查看了关于 VS 2010 扩展性的 MDSN 文档,位于 SO 的VS 2010 扩展列表,以及 这个主题关于创建自定义编辑器,但我有点不知道从哪里开始。

alt text

更新 1:

感谢 Brian 和 Basarat Ali 对 DebuggerVisualizer 的指导。看起来是正确的策略,但不幸的是,不允许使用任何类型数组的可视化工具

一种解决方法(实用性有限)是可视化包装对象。

根据 Brian 的建议,我在 CodePlex 上发布了一个解决方案:

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

该项目的源代码演示了一个工作包装可视化器和一个用于 1D double[] 数组的非功能性“原始”数据可视化器。这是测试控制台运行的屏幕截图:

alt text

如果有人对如何解决此问题有任何建议,请让我知道!

另外,欢迎任何有关 System.Array 无法可视化的原因的解释!

更新2:

我刚刚用“DebuggerVisualizer”一词重新搜索了SO,发现它是之前问过。看起来用户 Will Dean 建议实施 Mole 项目的解决方法 使用弱引用。不过,不知道这在 DebuggerVisualizer 中如何工作。

更新3:

Josh Smith of 鼹鼠项目 只是建议一个非常有用的解决方法(谢谢乔希!):

请注意,您可以使用 ArrayWrapper 方法,而无需修改源代码来打开可视化工具。您可以在 VS 的 Watch 窗口中输入以下内容:

新的 YourNamespace.ArrayWrapper(myArray);

按 Enter 键,然后您应该在“监视”窗口中该代码行旁边看到一个放大镜图标。单击它打开您的自定义可视化工具。

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.

alt text

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 and a non-functional "raw" data visualizer for a 1D double[] array. Here's a screenshot of the test console running:

alt text

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帥小哥 2024-10-08 06:59:44

您应该创建一个调试器可视化工具。这是一个演练: http://msdn.microsoft.com/en-us/library /ms164759.aspx 。我相信您想要的是能够在外部程序中查看所有结果。为此,您只需将导出选项添加到列表中即可导出为 csv 文件。但是,如果您仍然需要位图,可以使用 RenderTargetBitmap 将列表转换为图像: http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx

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

意犹 2024-10-08 06:59:44

由于这是调试器中的运行时信息,因此您可能会考虑使用 DebuggerVisualizer而不是编辑器扩展。有一些权衡,我不清楚哪种最适合。

(无论如何,我认为这是可能的,而且它看起来确实很有用,我希望周末有闲暇的人能够破解一个并发布源代码。)

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文