답변

4

.vsct 파일에 바로 가기를 추가 할 수 있습니다. 이 파일은 새 확장을 생성하고 메뉴 명령이 있다고 말할 때 마법사에서 자동으로 만들어집니다. 수동으로 추가하려면 다음

  • 프로젝트를 언로드 VSCTCompile하는
  • 설정 파일 속성 MyCommands.vsct 만들기, 마우스 오른쪽 버튼을 클릭하고 편집 할 프로젝트 :

:

<VSCTCompile Include="MyCommands.vsct"> 
    <ResourceName>Menus.ctmenu</ResourceName> 
    <SubType>Designer</SubType> 
</VSCTCompile> 
  • 프로젝트에 메뉴와 바로 가기가 있다고 선언하십시오.

: 당신의 Package.Initialize에서

<KeyBindings> 
    <KeyBinding guid="yourCmdSet" id="cmdAwesome" 
    editor="guidVSStd97" 
    key1="VK_F7" mod1="Control Alt" 
    key2="VK_F1"> 
    </KeyBinding> 
</KeyBindings> 
  • :

:

[ProvideMenuResource("Menus.ctmenu",1)] 
public sealed class MyPackage : Package 
  • 은 키 바인딩 섹션을 추가

:

// Add our command handlers for menu/shortcut (commands must exist in the .vsct file) 
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; 
if (null != mcs) 
{ 
    //// Create the command for the menu item. 
    var menuCommandID = new CommandID(GuidList.yourCmdSet,(int)PkgCmdIDList.cmdAwesome); 
    var menuItem = new MenuCommand((sender, evt) => 
    { 
     // Do stuff 
    } 
} 

추가 자료 :

+1

이 또한 확인은''섹션은''바로 다음에 있습니다. 파일에 무작위로 추가하고 xml 스키마 오류가 있습니다. – KernelMode

관련 문제