0

I'm developing an addin for VS 2012. I added a button and command to the Project command bar.

Now I have button in right-click menu after clicking on Project.

All I want to do for now is list all *.cs files from the project on which that button was clicked and have access to edit them.

I need that info in "Exec" function that is "catching" my command.

How to do it?

Pieces of my code:

_CommandBars cmdBars = (_CommandBars)_applicationObject.CommandBars;

CommandBar vsBarProject = cmdBars["Project"];

CommandBarPopup pluginProjectFolderPopup = (CommandBarPopup)vsBarProject.Controls.Add(MsoControlType.msoControlPopup, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true);

pluginProjectFolderPopup.Caption = "Plugin";

try
{
    Command command = commands.AddNamedCommand2(_addInInstance, "TestRightClickProject", "Plugin test", "Testing right click command on code window", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton);
    if ((commands != null) && (pluginProjectFolderPopup != null))
    {
        command.AddControl(pluginProjectFolderPopup.CommandBar, 1);
    }
}
catch (System.ArgumentException)
{
}

UPDATE: I have no choise. I have to use addins

Hooch
  • 28,817
  • 29
  • 102
  • 161
  • (Tangential warning: The next version of Visual Studio (currently known as Visual Studio "14") doesn't support add-ins. You might want to consider writing an extension instead.) – RichieHindle Jul 07 '14 at 13:43
  • @RichieHindle I have no choise. I have to use addins – Hooch Jul 07 '14 at 13:47

1 Answers1

1

Look at the answer to this question:

Visual Studio 2010 Plug-in - Adding a context-menu to the Solution Explorer

Once you determine the project being selected (see

_applicationObject.SelectedItems.Item(1).Project

)

You can use ProjectKinds.vsProjectKindSolutionFolder to get the project folder (see How to get folders under projects? )

Then iterate through the desired folder and subfolders.

Community
  • 1
  • 1
Thalia
  • 13,637
  • 22
  • 96
  • 190