VisualStudio custom debugging tools (GIS)

Without further ado,    

    Occasionally, share technology, yes, this is occasionally a few years time (technical inferiority). Last weekend was even more reminder, if the shock is favored .... The future will be more active on a regular basis, possibly.

 

Foreword   

    Visual Studio Debugger comes with a lot of debugging tools, the cursor on the breakpoint type, you will find magnifying glass icon, you can see the type of visualization when debugging. Common are text visualization tools, HTML visualization tools, XML visualization tools and data sets visualization tools. Sometimes you need to debug when viewing a particular type, you need to customize debugging tools. For example, to view debugging Image, to view a custom table data, view geometry when GIS development and debugging

 

    The key dot

    1.Microsoft.VisualStudio.DebuggerVisualizers.dll library. Can be found in the Extension Manager references

    When converting between 2.IGeometry and String (Why would we turn? IGeometry does not support serialization, when the host debugging tools to debug VS process, can not be passed to IGeometry object serialization debugging tools, it is forced to turn into a string, commissioning two more lines of code turn into a string in order to mobilize debugging tool, but also a bit tedious, bigwigs have any suggestions, drop me a message)

    3.GDI draw IGeometry (Map Why not directly undertake graphic display? Tried to know, ActiveX controls do not initialize the unit in a non-single-threaded, so forget, or drawn with the most basic GDI)

 

    End of the text with a reference and a link to download domo

 

    And all plug-in development processes as: Authoring Plug - Commissioning Plug - Plug - use

 

First, the production plug-in

    1. Create a new Class Library project, introduce the necessary Microsoft.VisualStudio.DebuggerVisualizers.dll library

    2. Create a new visual class. Inherited from DialogDebuggerVisualizer. Rewrite the Show method. You can also choose the debugging tools in the template more convenient

public class ESRIGeometryVisualizer : DialogDebuggerVisualizer
{
     override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            byte[] wkb = Convert.FromBase64String(objectProvider.GetObject().ToString());
            FormShowCustom frm = new FormShowCustom();
            frm.OriginWkb = wkb;
            windowService.ShowDialog(frm);
        }
​
        public static void TestESRIGeometryVisualizer(object objectToVisualize)
        {
            VisualizerDevelopmentHost visualizerHost = new VisualizerDevelopmentHost(objectToVisualize, typeof(ESRIGeometryVisualizer));
            visualizerHost.ShowVisualizer();
        }
    }

  

    3. Name the space above it to identify when you need to add feature code for debugging

[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(GeometryVisualizer.ESRIGeometryVisualizer),
typeof(VisualizerObjectSource),
Target = typeof(string),
Description = "ESRIGeometry可视化工具")]

 

 

    4. Create a form for display IGeometry. (Demo can be seen in the specific algorithm, using the drawing IGeometry GDI)

 

Second, debugging plug

    demo to create a simple console application for debugging. If you are VS2012, ArcGIS10.2 environment can be run directly

 

Third, install the plug

        编译成dll后。直接丢到以下两个路径 

    VisualStudioInstallPath\Common7\Packages\Debugger\Visualizers

    My Documents\VisualStudioVersion\Visualizers

 

四、使用插件

    重新启动调试,在IGeometry类型处,将其转换为string后。光标在类型上会发现放大镜中已经增加了ESRIGeometry可视化工具选项。

 

 

最后显示结果就是下面这样

 

 

最令人不舒服的就是调试时,需要多加两行代码转成string。相信开源的世界应该会更好点。

IGeometryFactory3 factory = new GeometryEnvironment() as IGeometryFactory3;byte[] b = factory.CreateWkbVariantFromGeometry(pGeo) as byte[];string str = Convert.ToBase64String(b);

 

碎语

    仅提供一个调试可视化工具的开发流程,实际可以根据不同的待可视化类型进行定制。比如有基础平台框架的,底层通用类,且有很多开发人员使用,可以针对需要可视化调试的类进行定制。XML自定义可视化显示、图像显示、流程显示、一些图形算法过程等

 

参考链接

https://www.cnblogs.com/cyq1162/p/4551652.html

https://docs.microsoft.com/en-us/visualstudio/debugger

demo源码下载  提取码 buti

失效请联系,微信关注了解更多

Guess you like

Origin www.cnblogs.com/xibei/p/10983865.html