2010-11-22 40 views
4

我們爲VS添加了一個當前從工具菜單啓動的插件,該插件由一個UI提供用戶幾個選項按鈕組成,我現在想要轉換爲可提供相同功能的頂級菜單。在Visual Studio中創建一個新的頂級菜單

我讀過this教程,它幫助我添加了一個新的頂級菜單,但無法真正理解所有步驟背後的邏輯。本指南並未真正清楚每個步驟產生的內容,或者如何更改輸出。
這些步驟創建的是一個新的頂層菜單,其下有單個項目。我試圖在我的菜單中創建一些層次結構(即頂層 - >子類別 - >命令),但因所有組/菜單/ ID結構而丟失。 這些文件的結構是否有任何明確的解釋?文檔或教程?如果任何人有這方面的經驗,並可以幫助清除事情,我將不勝感激...

回答

1

我還沒有嘗試做分層菜單項,但我有與Visual SDK .vcst文件類似的問題。這是一個痛苦。你可以做幾件事。

  1. 安裝VS包編輯器到Visual Studio博客條目它:http://blogs.msdn.com/b/visualstudio/archive/2010/09/08/introducing-the-vspackage-builder.aspx
  2. 下載源代碼(開源的,所以你可以看到他們是如何做到這一點),一個外接,做類似的事情。示例是AnkhSVN,它是Visual Studio的Subversion存儲庫加載項。這裏是源代碼:http://ankhsvn.open.collab.net/source/browse/ankhsvn/
-1

代碼示例

<?xml version="1.0" encoding="utf-8"?> 
<CommandTable xmlns="..."> 
    <!-- Extern section unchanged --> 
    <Commands package="guidHowToPackagePkg"> 
    <Menus> 
     <!-- New menu added --> 
     <Menu guid="guidBasicVSCTSampleCmdSet" id="SubMenu" priority="0x200" 
     type="Menu"> 
     <Parent guid="guidBasicVSCTSampleCmdSet" id="TopLevelMenuGroup" /> 
     <Strings> 
      <ButtonText>Other Commands</ButtonText> 
      <CommandName>Other Commands</CommandName> 
     </Strings> 
     </Menu> 
    </Menus> 
    <Groups> 
     <!-- Group changed to SubMenuGroup and attached to SubMenu --> 
     <Group guid="guidBasicVSCTSampleCmdSet" id="SubMenuGroup" 
     priority="0x0600"> 
     <Parent guid="guidBasicVSCTSampleCmdSet" id="SubMenu"/> 
     </Group> 
    </Groups> 

    <Buttons> 
     <!-- We attached these two buttons to SubMenuGroup --> 
     <Button guid="guidBasicVSCTSampleCmdSet" id="ThirdCommand" priority="0x0100" 
     type="Button"> 
     <Parent guid="guidBasicVSCTSampleCmdSet" id="SubMenuGroup" /> 
     <Icon guid="guidImages" id="bmpPicX" /> 
     <Strings> 
      <CommandName>ThirdCommand</CommandName> 
      <ButtonText>Third Command</ButtonText> 
     </Strings> 
     </Button> 
     <Button guid="guidBasicVSCTSampleCmdSet" id="FourthCommand" 
     priority="0x0101" type="Button"> 
     <Parent guid="guidBasicVSCTSampleCmdSet" id="SubMenuGroup" /> 
     <Icon guid="guidImages" id="bmpPicArrows" /> 
     <Strings> 
      <CommandName>FourthCommand</CommandName> 
      <ButtonText>Fourth Command</ButtonText> 
     </Strings> 
     </Button> 
    </Buttons> 

    </Commands> 

    <Symbols> 
    <!-- We add a SubMenu and changed SubMenuGroup --> 
    <GuidSymbol name="guidBasicVSCTSampleCmdSet" value="..."> 
     <IDSymbol name="SubMenu" value="0x0101" /> 
     <IDSymbol name="SubMenuGroup" value="0x0201" /> 
    </GuidSymbol> 
    </Symbols> 
</CommandTable> 

這爲您提供了以下頂級菜單:

enter image description here

下面是在一個完整的章節話題。這幾乎可以解釋(分層)菜單上的所有知識。

http://dotneteers.net/blogs/divedeeper/archive/2010/05/23/vs-2010-package-development-chapter-2-commands-menus-and-toolbars.aspx

相關問題