本文整理汇总了C#中Microsoft.VisualStudio.Shell.OleMenuCommandService.FindCommand方法的典型用法代码示例。如果您正苦于以下问题:C# OleMenuCommandService.FindCommand方法的具体用法?C# OleMenuCommandService.FindCommand怎么用?C# OleMenuCommandService.FindCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.Shell.OleMenuCommandService
的用法示例。
在下文中一共展示了OleMenuCommandService.FindCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAttachCommand
/// <summary>
/// Adds the attach command.
/// </summary>
/// <param name="mcs">The Menu Command Service.</param>
/// <param name="getDescriptor">The get descriptor.</param>
private void AddAttachCommand( OleMenuCommandService mcs, int commandId, Func<GeneralOptionsPage, AttachDescriptor> getDescriptor )
{
if ( mcs != null ) {
var commandIdentifier = new CommandID ( ATAGuids.guidAttachToAnyCmdGroup, commandId );
var existing = mcs.FindCommand(commandIdentifier);
var descriptor = getDescriptor ( OptionsPage );
if ( existing != null ) {
( (DescriptorMenuCommand)existing ).Descriptor = descriptor;
return;
}
var menuItem = new DescriptorMenuCommand (
( s, e ) => {
var menu = (DescriptorMenuCommand)s;
if ( OptionsPage.DTE != null ) {
var procList = new List<EnvDTE.Process> ( );
foreach ( EnvDTE.Process process in OptionsPage.DTE.Debugger.LocalProcesses ) {
if ( menu.Descriptor.ProcessNames.Any ( p => process.Name.EndsWith ( p ) ) ) {
procList.Add ( process );
}
}
if ( procList.Count == 0 ) {
return;
}
// Where there is only 1, or "best choice"
if ( procList.Count == 1 || !menu.Descriptor.ChooseProcess ) {
procList.First ( ).Attach ( );
return;
}
AttachToAnyPackage.ShowProcessManagerDialog ( procList );
}
}, commandId, descriptor );
mcs.AddCommand ( menuItem );
}
}
示例2: RefreshAppPoolMenu
private void RefreshAppPoolMenu(OleMenuCommandService mcs)
{
var appPools = LookupAppPools.GetAppPoolProcesses();
int j = 0;
foreach (var appPool in appPoolList)
{
var cmdID = new CommandID(GuidList.guidNielsV_AttachToAppPoolCmdSet, this.baseMRUID + j);
var menuCommand = mcs.FindCommand(cmdID) as OleMenuCommand;
if (j >= 0 && j < this.appPoolList.Count && j < appPools.Count)
{
menuCommand.Text = appPools.Values.ElementAt(j);
menuCommand.Visible = true;
}
else
{
menuCommand.Visible = false;
}
j++;
}
}