

- Visual studio extensions context menu constants full#
- Visual studio extensions context menu constants code#
- Visual studio extensions context menu constants series#
Search for: Follow me on Twitter My Tweets My Lastest Book: C# 8 and.

Visual studio extensions context menu constants code#
The code for this project can be found here. The next step is to get it to actually add a file, but we’ll come to that in the next post. We’re not far off now – there’s a few little issues, but the main thing that’s left is that we’re not actually adding anything – just displaying a message. Show a message box to prove we were here UIHierarchy uih = (UIHierarchy)(įoreach (UIHierarchyItem selectedItem in selectedItems) Var dte = await package.GetServiceAsync(typeof(DTE)).ConfigureAwait(false) as DTE2 Private async void Execute(object sender, EventArgs e)Īwait (package.DisposalToken)
Visual studio extensions context menu constants full#
Here’s the full code of the Execute method, to display the selected project: You can then find out what’s selected by accessing the selected hierarchy: UIHierarchy uih = (UIHierarchy)(Į).Object Īrray selectedItems = (Array)uih.SelectedItems NET IDE and Visual Studio Add-in : Creating Context Menus which are somewhat old and needed cleaning up, but they worked fine. I combined code from various resources like Adding Menu Items to context menus inside the Visual Studio. Now that we’ve moved the menu to the context menu, we’ll need to find which project we’re in by accessing the DTE Service – this is retrieved by calling the command: var dte = await package.GetServiceAsync(typeof(DTE)).ConfigureAwait(false) as DTE2 Instead I went with a Visual Studio add-in which was much easier. These control visual aspects of the thumbnail and its borders. Getting the Context of the Current Project A tutorial on using owner-drawn menus in a context menu shell extensions, and on making a. If you decide to change the name of MyMenuGroup, you will need to do so in all three places above. Which adds the menu to the top level Tools menu change it to: This is where you can change the command text (as I have above). Notice that, in the code shell that Visual Basic creates for the. If you have a look in that file, you’ll see something called MyMenuGroup which is referenced in three places. For instance, we need the menu constants MFBYPOSITION, MFSTRING, and MFSEPARATOR. Both of those things are changed in the file AdrPackage.vsct (if your project is called Aardvark, this will be named AardvarkPackage.vsct). There are two things that we need to change about this command: the text (we don’t want it to read “Invoke AddAdrCommand”), and the location (we want it to be available from the right-click context menu of a project). This will create you a menu item that will appear under the Tools menu by default, and will display a message box when selected: The first step is to add the command fortunately, this is a pre-made template, so just select to add a new item (ironically), and pick Command: Right click on Windows folder and open with Visual Studio Code. Having completed the screen that will show existing ADRs, we now want to allow the user to right-click on a project or solution and select to add a new ADR: In this post, we’ll cover the process of adding a command to the solution and project context menu.
Visual studio extensions context menu constants series#
In my previous post I continued with my little series on writing an extension for Visual Studio by completing the functionality to view existing ADRs within the solution.
