简体   繁体   English

创建 Visual Studio 扩展添加菜单和表单

[英]Creating visual studio extension adding a menu and a form

I am trying to add a menu item into my custom extension for visual studio but when I attempt to compile it says the guidTopLevelMenuPackageCmdSet does not exist even though I have create a command object.我正在尝试将一个菜单项添加到我的 Visual Studio 自定义扩展中,但是当我尝试编译它时说 guidTopLevelMenuPackageCmdSet 不存在,即使我已经创建了一个命令 object。

<Menus>
  <Menu guid="CommandSet" id="TopLevelMenu" priority="0x700" type="Menu">
  <Parent guid="guidSHLMainMenu"
          id="IDG_VS_MM_TOOLSADDINS" />
      <Strings>
          <ButtonText>TestMenu</ButtonText>
          <CommandName>TestMenu</CommandName>
      </Strings>
  </Menu>
</Menus>
 
  <!-- In this section you can define new menu groups. A menu group is a container for
     other menus or buttons (commands); from a visual point of view you can see the
     group as the part of a menu contained between two lines. The parent of a group
     must be a menu. -->
  <Groups>
      <Group guid="CommandSet" id="MyMenuGroup" priority="0x0600">
          <Parent guid="CommandSet" id="TopLevelMenu"/>
      </Group>
  </Groups>

Now I want my extension to be able to launch a form how do I achieve this correctly I tried the tutorial here but it wasn't clear where you get the guide from.现在我希望我的扩展程序能够启动一个表单我如何正确地实现这一点我在这里尝试了教程,但不清楚你从哪里获得指南。 https://www.c-sharpcorner.com/article/creating-visual-studio-2019-extension/ https://www.c-sharpcorner.com/article/creating-visual-studio-2019-extension/

I started with the basic template but it didnt add the menu correctly when I was debugging is their something im missing.我从基本模板开始,但是当我调试时它没有正确添加菜单是他们缺少的东西。

<!-- In this section you can define new menu groups. A menu group is a container for
         other menus or buttons (commands); from a visual point of view you can see the
         group as the part of a menu contained between two lines. The parent of a group
         must be a menu. -->
      <Menus>
          <Menu guid="CommandSet" id="TopLevelMenu" priority="0x700" type="Menu">
              <Parent guid="guidSHLMainMenu"
                      id="IDG_VS_MM_TOOLSADDINS" />
              <Strings>
                  <ButtonText>TestMenu</ButtonText>
                  <CommandName>TestMenu</CommandName>
              </Strings>
          </Menu>
      </Menus>
     
      <!-- In this section you can define new menu groups. A menu group is a container for
         other menus or buttons (commands); from a visual point of view you can see the
         group as the part of a menu contained between two lines. The parent of a group
         must be a menu. -->
      <Groups>
          <Group guid="CommandSet" id="MyMenuGroup" priority="0x0600">
              <Parent guid="CommandSet" id="TopLevelMenu"/>
          </Group>
      </Groups>

For anyone else if you look in the vscx file you will see at the bottom the following.对于其他任何人,如果您查看 vscx 文件,您将在底部看到以下内容。 Here you will see guidEfCoreCrudBootStrapPackageCmdSet which matches the guid command set value in the ICommand interface you created in the tutorial.在这里,您将看到 guidEfCoreCrudBootStrapPackageCmdSet 与您在教程中创建的 ICommand 界面中的 guid 命令集值匹配。

<GuidSymbol name="guidEfCoreCrudBootStrapPackageCmdSet" value="{5017a255-b672-4113-b19a-422a35b0af64}">
  <IDSymbol name="MyMenuGroup" value="0x1020" />
  <IDSymbol name="EfCoreCrudBootStrapCommandId" value="0x0100" />
    <IDSymbol name="MyMenuGroup" value="0x1020" />
    <IDSymbol name="SampleCommandId" value="0x0100" />
    <IDSymbol name="SampleMenu" value="0x1021"/>
</GuidSymbol>

<GuidSymbol name="guidImages" value="{14c1b0d2-fd1c-41b4-88f0-9545d5ecdf31}" >
  <IDSymbol name="bmpPic1" value="1" />
  <IDSymbol name="bmpPic2" value="2" />
  <IDSymbol name="bmpPicSearch" value="3" />
  <IDSymbol name="bmpPicX" value="4" />
  <IDSymbol name="bmpPicArrows" value="5" />
  <IDSymbol name="bmpPicStrikethrough" value="6" />
 
</GuidSymbol>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM