title: Add an Item to the visual studio folder right-click menu within AddIn
body: <p>I want to add a menuitem to the right-click=>Add menu in visual studio 2012 solution explorer. When click the custom item I can add a project with my template.
  I developed a Visual Studio Add-In to do it but I get into some trouble. I am able to add a menuitem to the right-click menu but I can't get it to meet my requirement.</p>
  
  <ol>
  <li><p>The menuitem should be the submenu of "Add". Not a root item.</p></li>
  <li><p>I also need the menuitem to show only when I right-click on a folder named "Areas". I don't want it to show when I right-click on other folders.</p></li>
  </ol>
  
  <p>Here is my <code>OnConnection</code> function code. How can I change it to meet my requirement.</p>
  
  <pre><code>public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
      {
          _applicationObject = (DTE2)application;
          _addInInstance = ((AddIn)addInInst);
          if (connectMode == ext_ConnectMode.ext_cm_UISetup)
          {
              object[] contextGUIDS = new object[] { };
              Commands2 commands = (Commands2)_applicationObject.Commands;
  
              //Place the command on the tools menu.
              //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
              var bars=((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars);
  
              Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = bars["MenuBar"];
  
              //Find the Tools command bar on the MenuBar command bar:
              //CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
              //CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;
              // get popUp command bars where commands will be registered.
              CommandBars cmdBars = (CommandBars)(_applicationObject.CommandBars);
              //CommandBar vsBarItem = cmdBars["Item"]; //the pop up for clicking a project Item
              CommandBar vsBarFolder = cmdBars["Web Project Folder"];
              CommandBar vsBarWebFolder = cmdBars["Web Folder"];
  
              //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
              //  just make sure you also update the QueryStatus/Exec method to include the new command names.
              try
              {
                  //Add a command to the Commands collection:
                  Command command = commands.AddNamedCommand2(_addInInstance, "ModuleAddin", "Add a Project", "Executes the command for ModuleAddin", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
                  //Add a control for the command to the tools menu:
                  if (command != null)
                  {
                      //command.AddControl(toolsPopup.CommandBar, 1);
                      command.AddControl(vsBarFolder);
                      //CommandBarButton button = (CommandBarButton)command.AddControl(vsBarFolder, 3);
                      //button.BeginGroup = true;
                  }
              }
              catch (System.ArgumentException argEx)
              {
                  System.Diagnostics.Debug.Write("Exception in HintPaths:" + argEx.ToString());
              }
          }
      }
  </code></pre>