简体   繁体   English

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

[英]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. 我想创建一个WPF UserControl,它将数据数组(如下所示)呈现为图像,而不是可滚动的文本值列表。

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. 我已经查看了关于VS 2010可扩展性的MDSN文档 ,在SO的VS 2010扩展列表中 ,以及关于创建自定义编辑器的这个主题 ,但我有点迷失在哪里开始。

替代文字

Update 1: 更新1:

Thanks to Brian and Basarat Ali for the leads on DebuggerVisualizer. 感谢Brian和Basarat Ali在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: 在Brian的建议下,我在CodePlex上发布了一个解决方案:

VS2010 Debugger Visualizers Contrib ( http://debuggervisualizers.codeplex.com/ ). VS2010 Debugger Visualizers Contribhttp://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. 该项目的源代码演示了一个工作包装器可视化器和一个用于1D double []阵列的非功能性“原始”数据可视化器。 Here's a screenshot of the test console running: 这是测试控制台运行的屏幕截图:

替代文字

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! 此外,欢迎任何解释为什么System.Array无法可视化!

Update 2: 更新2:

I just re-searched SO with the word DebuggerVisualizer, and find this to be previously asked . 我只是用DebuggerVisualizer这个词重新搜索了SO,并发现这是先前要求的 Looks like user Will Dean suggests implementing Project Mole's work-around using a WeakReference . 看起来用户Will Dean建议使用WeakReference实现Project Mole的解决方案。 Don't see how this would work in a DebuggerVisualizer, though. 但是,不要看看这在DebuggerVisualizer中是如何工作的。

Update 3: 更新3:

Josh Smith of Project Mole just suggested a very helpful work around (thanks Josh!): Project Mole的 Josh Smith刚刚提出了一个非常有用的工作(感谢Josh!):

Note, you can use your ArrayWrapper approach without needing to modify your source code to open a visualizer. 注意,您可以使用ArrayWrapper方法,而无需修改源代码以打开可视化工具。 You can type this into the Watch window in VS: 您可以在VS中的Watch窗口中输入:

new YourNamespace.ArrayWrapper(myArray); 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. 按Enter键,然后您应该在该行代码旁边的Watch窗口中看到一个放大镜图标。 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 . 这是一个演练: 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. 为此,您只需向列表中添加导出选项即可导出为csv文件。 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 但是,如果您仍然觉得需要位图,可以使用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. 由于这是针对调试器中的运行时信息,因此您可能会考虑使用DebuggerVisualizer而不是编辑器扩展。 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.) (在任何情况下,我认为这是可能的,它确实看起来很有用,我希望有一个周末的人可以解决一个并发布源代码。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使Visual Studio 2010的“添加用户控件”创建WPF控件? - How can I make Visual Studio 2010's “Add User Control” create a WPF control? 如何在visual studio express 2010中创建安装程序(msi)? - How can I create an installer (msi) in visual studio express 2010? 无法更改Visual Studio adorner z命令 - Can't change Visual Studio adorner z order Visual Studio 2010加载项处理快捷方式代替我的WPF APP - Visual Studio 2010 Add-in Handling shortcut instead my WPF APP 如何通过单击删除装饰物? - How can I remove an adorner by clicking it? 我可以在数据模板之外向DataTemplate项目添加装饰器吗? - Can I add an adorner to a DataTemplate item, outside the data template? 如何在Visual Studio 2010中将现有数据模型添加为数据源? - How to add an existing data model as a Data Source in Visual Studio 2010? 如何加快Visual Studio 2010文本编辑器的渲染速度? - How can I speed up Visual Studio 2010 text editor render speed? 我可以在我的应用程序中托管Visual Studio 2010编辑器吗? - Can I host the Visual Studio 2010 editor in my application? 如何在 Visual Studio 2019 中添加对 PresentationCore 的引用? - How can I add a reference to PresentationCore in Visual Studio 2019?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM