Using custom plugins in Visual Studio.NET Maxing Your Productive Forces (1) Custom Add-insid You Maximize The Producture of Visu

zhaozj2021-02-16  46

Use custom plugins to maximize your productivity in Visual Studio.net

Original connection: http://msdn.microsoft.com/msdnmag/issues/02/02/vside/print.asp

Author: Leo A. Notenboom

Translation: Zhang Xiang Kilxy@hotmail.com

This article assumes that you are already familiar with C #, Visual Basic .NET and CLR

Difficulty 1 2 3

Summary

For developers, no matter how powerful integrated development environment (IDE) requires a function of having custom plugins. Based on this reason, Visual Studio. Net IDE provides an expandable, added convenient and has no number of custom plug-in features. This custom plugin can be written in Visual Basic, C, C # or other language used by other .NET. This article explains how to add an example of a custom plugin in Visual Studio. NET. This example will demonstrate how to complete a custom text editing feature through a custom plugin, which implements two functions, one is simple inserted into the current date in the text, and the other is more complex functionality to achieve a restriction text. Finally, you will learn how to add a page in the Options dialog box.

If you start using Microsoft Visual Studio .NET you should know that he is full of new features and techniques. Although, you can think that the integrated development environment (IDE) is a simple text editor written code, it is very powerful. It provides the framework to support the insertion of the development tool and is a single seamless development. Of course, IDE does not meet all people, you or if I want it may not be here. Fortunately, IDE has provided scalable features, which allows you to expand anything you need.

begin

Plugins and macro are two ways to extend IDE. Macros can be recorded and executed immediately. Therefore, this is a powerful method for exploring the object model. Macro uses a .vsmacros file to be distributed in the form of a .vsmacros file, load it into the macro editor by double-clicking this file. After the macro is available, the macro can be modified very easy by the user.

On the other hand, the plugin is compiled and cannot be modified after the distribution. This protects your knowledge property. Through the plugin, you can create a tool window These operations are just like operating local features for Visual Studio.net. The plugin can dynamically change the menu, the status of the toolbar event, and add information in the Help dialog. The plugin is deployed by Microsoft's installation file (.msi), which can be easily installed and uninstalled by the Add / Remove Program dialog box in the control panel.

Steps to create a plug-in have hidden in the online help of Visual Studio.Net, and also hidden in Visual Studio.net Automation Examples Web Site. I don't want to introduce each particular process here, but I can review the process I have selected by the plugin.

Creating a plugin first To create a project, under the New Projects dialog box Other Projects (Other Projects), you will find the Extensibility Projects. Select Visual Studio.NET Add-IN. Figure 1 shows the new project dialog box at a point. Click the OK button to start the wizard.

Figure 1 Create a new project

For my plug-in, the first three steps in the wizard are easier. The first step, I chose the C # language as the development language of the plugin. In the second step, I chose Microsoft Visual Studio.NET as the host (Host) of the plugin. In your plugin you can of course include vsmacros IDE. In the third step, the plugin is named "Text Editing Utilites" and gives the appropriate description. figure 2

In the fourth step in the wizard, as shown in Figure 2, some operations are required.

l Select "Yes, create tool menu items".

l Determine "My external program is not available ..." is not selected. I am not ready to provide a mode user interface in this example, but if you really want more to extend your plugin feature, you can choose this.

l Determine "I hope that my external program is loaded when the host program starts" is not selected. This makes it easy to debug. The plug-in user can change this option in the operation of future plug-in management.

l I chose "My external program is not just ..." option. I am a real user in my computer, and I confirm that this example is also for more developers. This option is only the user who has changed the plugin has been registered.

Step 5, you can contain some help information. Select the check box and enter any contact information below. Now you can complete the wizard and start our plugin.

The method of the Connect object is listed below. These methods are incomplete and can be found in the connection.cs file. Part of these new projects.

l Connect :: Connect. This is a constructor, here you can do simple initialization.

l Connect :: onConnection. This method is called when IDE really loads your plugin. Here you can initialize your plugin, and must provide command information for IDE, make keyboard bindings, and more.

l Connect :: querystatus. This method is called when the IDE determines when the IDE is appropriate when the IDE is appropriate.

l Connect :: EXEC. This method is that the true execution command of the IDE is called.

Now, all the basic contents are here, let us start developing a simple plug-in example.

转载请注明原文地址:https://www.9cbs.com/read-28325.html

New Post(0)