备份插件创建菜单的代码
2015-11-13 16:53:47 访问(1628) 赞(0) 踩(0)
/// <summary>
///
/// </summary>
/// <param name="_applicationObject"></param>
/// <param name="_addInInstance"></param>
public void CreateDocumentMenu4bak
(
DTE2 _applicationObject,
AddIn _addInInstance
)
{
try
{
// Get "Easy MDI Document Window" command bar
CommandBar mdiDocCommandBar
=
GetCommandBarByName
(
_applicationObject,
_addInInstance,
"Easy MDI Document Window",
false
);
if (mdiDocCommandBar == null)
{
MessageBox.Show("发生异常:没有找到Easy MDI Document Window");
return;
}
string closeAllButThisCmdName = "Close All But This";
SlowXAddin.Enums.LanguageName.EmLanguageName
emLN = EmLanguageNameGet(_applicationObject, _addInInstance);
closeAllButThisCmdName = SlowXAddin.Enums.VsSlowXCmd.VsSlowXCmdNameGet
(
emLN,
SlowXAddin.Enums.VsSlowXCmd.EmVsSlowXCmd.除此之外全部关闭
);
// Place the command below "Close All But This" menu item
CommandBarControl closeAllButThisCmd
=
mdiDocCommandBar.Controls[closeAllButThisCmdName];
//if (closeAllButThisCmd == null)
//{
// MessageBox.Show("发生异常:没有找到Close All But This");
// return;
//}
int closeAllCmdIndex
=
(closeAllButThisCmd == null) ? 0 : closeAllButThisCmd.Index;
int theIdx = 1;
List<CmdInfo> cmdList = SlowXAddin.Enums.Cmd.CmdInfoList(emLN);
bool bResult = false;
foreach (CmdInfo info in cmdList)
{
// Add a new command
bResult = AddNamedCommand2
(
_applicationObject,
_addInInstance,
mdiDocCommandBar,
mdiDocCommandBar.Controls,
info.GetKEY(),
info.buttonText,
info.ToolTipGet(),
info.useMsoButton,
info.iconIndex,
closeAllCmdIndex + theIdx,
false
);
if (bResult)
++theIdx;
}
}
catch (Exception err)
{
System.Diagnostics.Debug.WriteLine(err.Message);
}
}
标签:
备份插件创建菜单的代码 


上一条:
下一条:
相关评论
发表评论