Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 8352 |  Welcome, Guest!   Register  Login
Home > Articles > Visual Studio 2010 > Feature Builder - Custom Visual Studio Menu Item

Feature Builder - Custom Visual Studio Menu Item

1 vote(s)
Rating: 5 out of 5
Article posted by Ambily.raj on 8/25/2010 | Views: 8407 | Category: Visual Studio 2010 | Level: Beginner | Points: 150 red flag


Visual Studio 2010 supports the extensibility of the IDE. We can develop our own extensions for VSTS 2010 and also a set of very useful extensions are available online. In this article, we will discuss about one of the extensions or Power Tools available as part of Visual Studio Gallery- Feature Builder.

Introduction

Visual Studio 2010 supports the extensibility of the IDE. We can develop our own extensions for VSTS 2010 and also a set of very useful extensions are available online. In this article, we will discuss about one of the extensions or Power Tools available as part of Visual Studio Gallery- Feature Builder.


Feature Builder can be used for various purposes.

  • Customize the Visual Studio IDE Menus
  • Add Custom Project Templates or Item Templates to Visual Studio
  • Dynamic Project or Item Template using T4 template
  • Create Various Custom Wizards
  • Customize the Menu behavior using Map
  • Enforce different rules in software development lifecycle
  • Etc.


In this article we will look into the first usage. How to create a custom Menu Item in Visual Studio IDE using Feature Builder?

Pre-requisites

Install the feature Builder power tool from  http://visualstudiogallery.msdn.microsoft.com/en-us/396c5990-6356-41c0-aa20-af4c3e58c7ae

You can install and uninstall the same from Extension Manager under Tools menu

Project Templates

When you install the Feature Builder, it adds a set of project templates for various purposes. The project templates are based on various scenarios.

Guidance Workflow Explorer

Once you create a feature extension project, it will display the Guidance Workflow Explorer and Guidance Browser. Guidance Workflow Explorer describes the usage of different scenarios and how we can extend the IDE in a tree-view. Once you select one node in Guidance Workflow Explorer, the description about the topic and associated sample code will be displayed on the Guidance Browser window.

Together Guidance Workflow Explorer and Guidance Browser display an online tutorial of Feature Builder Power Tool and different project templates associated with it.

Creating Menu Item

For creating a visual studio custom menu item, create a new project of type Feature Extension –Starter Pack +Tools Scenario.


The solution will have three projects; one main project, one library project and one Model library project. For generating the Custom Menu Item, we are going to use the following two projects

  1. CustomMenuItem – Main project
  2. CustomMenuItemLib – consists of the Commands, conditions, T4 Helper classes and Value Providers. This will act as the Utility project for our main project.

Custom Command

Right click on Commands Folder under CustomMenuItemLib project and add a Command Class



This will add the Command with default Implementation. Add the execution or our custom code under Execute Method.


 

public class HelloFromFeatureBuilder : FeatureCommand 
    {
        // Declared public properties will be exposed in the Command Bindings property
 
        /// <summary>
        /// Gets the Feature Extension instance for this invocation
        /// of the Condition
        /// </summary>
        [Import(AllowDefault = true)]
        public IFeatureExtension Feature { get; private set; }
 
        /// <summary>
        /// Called when any launch point bound to a command binding which refers to this command
        /// is invoked
        /// </summary>
        /// <param >            System.Windows.Forms.MessageBox.Show("Hello From Feature Builder");
        }
    }


Build the library project.

Feature.commands

Open the Feature.commands file under the Main project and remove the default items. You can see the new toolbox with Feature Commands. Drag one VS Launch Point item to the Feature.Commands designer surface.


Now, we need to select the Location where our Custom Menu Item should appear. Double click on the Location, this will open the Visual Studio Command Properties window.



Now, select the location where our custom menu Item should appear. In this sample, I selected the location as Menu|Edit and also specified the display text as HelpFromFX.



Now, we need to bind the new Menu Item with corresponding command. When you click on the new Menu item, we need to perform some custom operation. The custom operation is defined as Command. Drag a Command Binding Item from toolbox to the designer.

Command Binding

Select our Custom Command name as Command Type. Remember, if we are not building the library project before opening the Command Type, the new command name won’t appear here.


  

 

Connector

Using the Connector from Toolbox, bind or connect the VS Launch Point and Command Binding item. This indicate, when you click on the VS launch point, it should execute the specified command.



Now, our Feature Extension project is ready.  Right click on the designer and select Generate Commands Binding and Launch Point Code option from Context Menu.



 
This will generate the code under MainProject->GeneratedCode folder. Build the Feature Extension Solution and press Ctrl+F5. This will launch the “Experimental Instance” of Visual Studio.

Experimental Instance

In the experimental Instance of visual studio, go to File-> New Project -> Select the new project template with our solution name ie; CustomMenuItem


This will create a sample class library project. You can see our new MenuItem under the Edit Menu.



Select the MenuItem “HelloFromFX”, which shows our custom message.


 
We can write any custom code inside the Execute method of the Command class.

Conclusion

Feature Builder is a powerful extension tool available as part of the Visual studio gallery. We will discuss about the other usage of feature builder in next article.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Ambily KK

Experience:7 year(s)
Home page:http://ambilykk.wordpress.com/
Member since:Tuesday, May 18, 2010
Level:Silver
Status: [Member] [Microsoft_MVP] [MVP]
Biography:I have over 7 years of experience working on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Office Open XML, Azure, Visual Studio 2010. Technology adoption and learning is my key strength and technology sharing is my passion.
>> Write Response - Respond to this post and get points
Related Posts

This article explains the new tool in visual studio 2010 which most of the users use to see the comparison report of the 2 different database schemas.

There are lots of test automation frameworks to support the test automation of an application. Coded UI is the new testing model introduced in Visual Studio 2010. This will support the automation of Manual test steps etc. Coded UI is an automation framework which enables us to record a set of action, creates the code for the same and allows us to playback the recording for testing the application. It also gives the flexibility to write the custom code [hand-coded]. In this article we will discuss about how to create our first CodedUI test project.

Performance of an application is very important for a multi-user application. Performance is not only the speed of execution; it includes the load and concurrency aspects. Visual Studio is one of the tools used for Performance Test. Visual Studio Test edition or Visual Studio 2010 Ultimate provides the support for test automation.

In my last article on Coded UI Basic Walkthrough, we have seen the Record and Playback Mechanism of Coded UI. In this article I would like to discuss about the ‘Object Identification Mechanism of CodedUI’. How Coded UI identifies the objects present on the User Interface? Each object has some search properties associated with it. Along with this, if the object’s Technology is Web then it also has Filter properties associated with it. Coded UI uses these properties to identify the objects at runtime.

In my earlier post on “Interactive ToolTip using Visual Studio 2010 Productivity Power Tool”, I discussed about “Interactive ToolTip” feature which comes with the Visual Studio 2010 Productivity Power Tool. In this post, I will share information about the all new “Add Reference” dialog which is fully searchable for assembly reference.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 8:34:51 AM