Use custom Plug-ins in Visual Studio.NET to maximize your productivity (i)

Source: Internet
Author: User
Tags connect new features object model requires visual studio
Visual| maximize This article assumes that you are already familiar with C #, Visual Basic. NET and CLR

Degree of difficulty 1 2 3

Summary

For developers, no matter how powerful the integrated development environment (IDE) requires the ability to have custom plug-ins. For this reason, Visual Studio. NET IDE provides an extensible, easily accessible, and not limited number of custom plug-in features. This custom plug-in can be used in visual Basic, C, C #, or whatever. NET in the language used to write. This article explains how to do this in visual Studio. The example of adding a custom plug-in in net. This example demonstrates how to complete a custom text-editing function with a custom plug-in that implements two features, one that simply inserts the current date in the text, and the more complex feature that implements reformatting a text. Finally, you'll learn how to add a page to 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 of the integrated development environment (IDE) as a simple text editor for coding, it's already very powerful. It provides a framework to support the insertion of development tools and is single and seamless to develop. Of course, the IDE doesn't meet all the people you have or I want the features may not be here. Fortunately, the IDE has provided scalable functionality that allows you to expand anything you need.

Begin

Plug-ins and macros are two ways to extend the IDE. Macros can be logged and executed immediately. Therefore, this is a powerful way to explore the object model. Macros are distributed in the form of a. vsmacros file and are loaded into the macro editor by double-clicking the file. Once the macros are loaded, macros can be easily modified by the user.

On the other hand, Plug-ins are compiled and cannot be modified after they are distributed. This protects your intellectual property. With Plug-ins, you can create tool windows that operate on Visual Studio.NET like local functionality. Plug-ins can dynamically change the status of menus, toolbar events, and add information to the Help dialog box. Plug-in is through Microsoft's installation files (. MSI) for deployment, which can be easily installed and uninstalled through the Add/Remove Programs dialog box in Control Panel.

The steps to create a plug-in have been hidden in the Visual Studio.NET online Help, and are also hidden in the Visual Studio.NET Automation examples Web site. I do not want to introduce each of the specific processes here, but I can review the process I have chosen to create a plugin.

Create a plug-in first you create a project, and under the new Project (New Projects) dialog box Other items (other Projects), you will find extensibility projects (extensibility Projects). Select the Visual Studio.NET add-in (Visual Studio.NET add-in). Figure one shows the new Project dialog box at one point. Click the OK button to start the wizard.




Figure 1 Creating 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 a plug-in development language. In the second step, I chose Microsoft Visual Studio.NET as the host for the plug-in (host). Of course you can include the VSMacros IDE in your plugin. In the third step, the plugin is named "Text Editing utilites" and gives an appropriate description.




Figure 2

The fourth step in the wizard, as shown in Figure 2, requires some action.

L Select "Yes, create tool menu items".

L determine that "my add-in does not provide ..." is not selected. In this example I am not prepared to provide a modal user interface, but if you really want to expand your plugin functionality, you can choose this one.

L OK "I want my add-in to load when the host program starts" is not selected. This allows debugging to be easier. The user of the plug-in can change this option in subsequent plug-in management operations.

L chose "My add-in is not just ..." option. I'm a real user on my computer, and I'm sure this example is for more developers. This option is only to change the plugin has been registered users.

Fifth step, you can include some help information. Select the check box to enter any contact information below. Now, you can complete the wizard and start our plugin.

The method for the Connect object is listed below. These methods are incomplete and you can find the class in the Connect.cs file. These are part of your new project.

L Connect::connect. This is the constructor, where you can do a simple initialization.

L Connect::onconnection. This method is invoked when the IDE actually loads your plug-in. Here you can initialize your plugin, and you must provide command information for the IDE, make keyboard bindings, and so on.

L Connect::querystatus. This method is invoked when the IDE determines the current state at the appropriate time.

L Connect::exec. This method is that the IDE's true command of execution is invoked.

Now that all the basics are here, let's start by developing a simple plugin example.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.