최근에 스튜디오 2008에서 2010으로 변환 된 프로젝트가 있습니다. 이는 DSL을 많이 사용합니다. SDK와 함께 제공되는 DslProjectsMigrationTool을 사용했습니다. 많은 기능이 작동하는 동안 메뉴에 몇 가지 문제가 있습니다. 내 코드에는 세 개의 버튼이있는 사용자 정의 도구 모음이 있습니다. 그러나 이벤트 처리기가 작동하지 않는 것 같습니다. 나는 하나를 다시 가지고 2008 버전을 확인하고 이것은 문제없이 일하고 있었다.Visual Studio 확장 메뉴 버튼 이벤트가 발생하지 않습니다.
불행히도이 코드는 내 자신이 아니며 원래 작성한 사람이 옮겨서 도움을 얻을 수 없습니다.
내가 CommandSetOverride.cs에서 다음<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Commands package="guidPkg">
<Menus>
<Menu guid="guidCmdSet" id="blueprintToolbar" priority="0x0000" type="Toolbar">
<Parent guid="guidCmdSet" id="blueprintToolbar"/>
<CommandFlag>DefaultDocked</CommandFlag>
<CommandFlag>AlwaysCreate</CommandFlag>
<Strings>
<ButtonText>Blueprint Toolbar</ButtonText>
</Strings>
</Menu>
</Menus>
<Groups>
<Group guid="guidCmdSet" id="grpidTranslate" priority="0x0000">
<Parent guid="guidCmdSet" id="blueprintToolbar" />
</Group>
</Groups>
<Buttons>
<Button guid="guidCmdSet" id="cmdidReTranslateAllCmd" priority="0x0100" type="Button">
<Parent guid="guidCmdSet" id="grpidTranslate" />
<Icon guid="guidCmdSet" id="bmpPic1"/>
<CommandFlag>TextOnly</CommandFlag>
<Strings>
<ButtonText><Retranslate All></ButtonText>
</Strings>
</Button>
<Button guid="guidCmdSet" id="cmdidTranslateAllCmd" priority="0x0101" type="Button">
<Parent guid="guidCmdSet" id="grpidTranslate" />
<Icon guid="guidCmdSet" id="bmpPic1"/>
<CommandFlag>TextOnly</CommandFlag>
<Strings>
<ButtonText><Translate All></ButtonText>
</Strings>
</Button>
<Button guid="guidCmdSet" id="cmdidTranslateCurCmd" priority="0x0102" type="Button">
<Parent guid="guidCmdSet" id="grpidTranslate" />
<Icon guid="guidCmdSet" id="bmpPic1"/>
<CommandFlag>TextOnly</CommandFlag>
<Strings>
<ButtonText><Translate Current></ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
<Symbols>
<GuidSymbol name="guidCmdSet" value="Extern">
<!--Group IDs-->
<IDSymbol name="grpidTranslate" value="0x1050"/>
<!--Command IDs-->
<IDSymbol name="cmdidTranslateAllCmd" value="0x9100"/>
<IDSymbol name="cmdidTranslateCurCmd" value="0x9101"/>
<IDSymbol name="cmdidReTranslateAllCmd" value="0x9102"/>
<IDSymbol name="blueprintToolbar" value="0x1000"/>
<IDSymbol name="bmpPic1" value="1"/>
</GuidSymbol>
</Symbols>
</CommandTable>
이 Commands.vsct에서
내가 가진
/// <summary>
/// Constants relating to commands
/// </summary>
partial class Constants
{
public const string CLSID_StandardCommandSet97 = "5efc7975-14bc-11cf-9b2b-00aa00573819";
#region Command Codes
const int cmdidTranslateAllCmd = 0x9100;
const int cmdidTranslateCurrentCmd = 0x9101;
const int cmdidReTranslateAllCmd = 0x9102;
#endregion
#region CommandIDs
public static readonly CommandID TranslateAllCommandID =
new CommandID(new Guid(Constants.BlueprintCommandSetId), cmdidTranslateAllCmd);
public static readonly CommandID TranslateCurrentCommandID =
new CommandID(new Guid(Constants.BlueprintCommandSetId), cmdidTranslateCurrentCmd);
public static readonly CommandID ReTranslateAllCommandID =
new CommandID(new Guid(Constants.BlueprintCommandSetId), cmdidReTranslateAllCmd);
#endregion
}
/// <summary>
/// Additions to the blueprint command set for context menu items and extra commands.
/// </summary>
partial class BlueprintCommandSet
{
/// <summary>
/// Retrieves the available menu commands
/// </summary>
/// <returns>List of menu commands</returns>
protected override IList<MenuCommand> GetMenuCommands()
{
IList<MenuCommand> commands = base.GetMenuCommands();
OleMenuCommand oleMenuCommand;
// Translate
if (null != MenuService)
{
MenuCommand menuCommand = new MenuCommand(new EventHandler(OnTranslateAll), Constants.TranslateAllCommandID);
MenuService.AddCommand(menuCommand);
menuCommand = new MenuCommand(new EventHandler(OnTranslateCurrent), Constants.TranslateCurrentCommandID);
MenuService.AddCommand(menuCommand);
menuCommand = new MenuCommand(new EventHandler(OnReTranslateAll), Constants.ReTranslateAllCommandID);
MenuService.AddCommand(menuCommand);
}
return commands;
}
#region Translation
/// <summary>
/// Handles the "ReTranslate All" toolbar button command.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnReTranslateAll(object sender, EventArgs e)
{
ReTranslateAll();
}
/// <summary>
/// Handles the "Translate All" toolbar button command.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnTranslateAll(object sender, EventArgs e)
{
TranslateAll(false);
}
/// <summary>
/// Handles the "Translate Current" toolbar button command.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnTranslateCurrent(object sender, EventArgs e)
{
TranslateCurrent();
}
#endregion
}
버튼이 나타납니다 하이브에서 실행할 때 내가 코드 중 하나 설치된 버전을 실행하거나 도구 모음 아무 문제 그러나 그들을 클릭하지 마십시오 OntranslateAll 또는 이와 유사합니다. 어떤 도움이라도 매우 유용 할 것입니다.
CommandSetId Guid가 명시 적으로 두 곳에서 사용되고 두 번째 버전이 2010 버전으로 업데이트 된 것을 발견했습니다. 이벤트가 잘못된 장소로 전송되었습니다 다른 guids와 함께 – user2207853