本文整理汇总了C#中Microsoft.VisualStudio.Shell.OleMenuCommand类的典型用法代码示例。如果您正苦于以下问题:C# OleMenuCommand类的具体用法?C# OleMenuCommand怎么用?C# OleMenuCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OleMenuCommand类属于Microsoft.VisualStudio.Shell命名空间,在下文中一共展示了OleMenuCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupCommands
public void SetupCommands(OleMenuCommandService commandService)
{
if (Package.DocumentManager == null)
{
return;
}
var guid = typeof(RestoreTabsListCommandIds).GUID;
var commandId = new CommandID(guid, (int)RestoreTabsListCommandIds.RestoreTabsListPlaceholder);
var command = new OleMenuCommand(null, commandId);
command.BeforeQueryStatus += RestoreTabsListPlaceholderCommandOnBeforeQueryStatus;
commandService.AddCommand(command);
for (var i = (int)RestoreTabsListCommandIds.RestoreTabsListStart; i <= (int)RestoreTabsListCommandIds.RestoreTabsListEnd; i++)
{
commandId = new CommandID(guid, i);
command = new OleMenuCommand(ExecuteRestoreTabsCommand, commandId);
command.BeforeQueryStatus += RestoreTabsCommandOnBeforeQueryStatus;
commandService.AddCommand(command);
var index = GetGroupIndex(command);
Package.Environment.SetKeyBindings(command, $"Global::Ctrl+D,{index}", $"Text Editor::Ctrl+D,{index}");
}
}
示例2: SetupCommands
public void SetupCommands()
{
CommandID commandId = new CommandID(CommandGuids.guidDiffCmdSet, (int)CommandId.RunDiff);
OleMenuCommand menuCommand = new OleMenuCommand((s, e) => PerformDiff(), commandId);
menuCommand.BeforeQueryStatus += BeforeQueryStatus;
_mcs.AddCommand(menuCommand);
}
示例3: RegisterCommand
private void RegisterCommand(ToolbarCommand id, EventHandler callback)
{
var menuCommandID = new CommandID(PackageConstants.GuidTortoiseGitToolbarCmdSet, (int)id);
var menuItem = new OleMenuCommand(callback, menuCommandID);
menuItem.Visible = false;
_commandService.AddCommand(menuItem);
}
示例4: Initialize
/// <summary>
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initilaization code that rely on services provided by VisualStudio.
/// </summary>
protected override void Initialize()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
base.Initialize();
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (mcs != null)
{
// Create the command to generate the missing steps skeleton
CommandID menuCommandID = new CommandID(GuidList.guidSpecFlowGenerateOption,
(int)PkgCmdIDList.cmdidGenerate);
//Create a menu item corresponding to that command
IFileHandler fileHandler = new FileHandler();
StepFileGenerator stepFileGen = new StepFileGenerator(fileHandler);
OleMenuCommand menuItem = new OleMenuCommand(stepFileGen.GenerateStepFileMenuItemCallback, menuCommandID);
//Add an event handler to the menu item
menuItem.BeforeQueryStatus += stepFileGen.QueryStatusMenuCommandBeforeQueryStatus;
mcs.AddCommand(menuItem);
}
}
示例5: Register
public static void Register(DTE2 dte, MenuCommandService mcs)
{
_dte = dte;
CommandID nestAllId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdRunNesting);
OleMenuCommand menuNestAll = new OleMenuCommand(NestAll, nestAllId);
mcs.AddCommand(menuNestAll);
}
示例6: SetupCommands
public void SetupCommands()
{
CommandID cmd = new CommandID(CommandGuids.guidImageCmdSet, (int)CommandId.CompressImage);
OleMenuCommand menuCmd = new OleMenuCommand((s, e) => StartCompress(), cmd);
menuCmd.BeforeQueryStatus += BeforeQueryStatus;
_mcs.AddCommand(menuCmd);
}
示例7: Initialize
protected void Initialize(Guid menuGroup, int commandId)
{
var cmdId = new CommandID(menuGroup, commandId);
Command = new OleMenuCommand(this.OnInvoke, cmdId);
Command.BeforeQueryStatus += OnBeforeQueryStatus;
CommandService.AddCommand(Command);
}
示例8: InsertGuidCommand
private InsertGuidCommand()
{
// Instance initialization
_commandID = new CommandID(new Guid("3020eb2e-3b3d-4e0c-b165-5b8bd559a3cb"), 0x0100);
_menuCommand = new OleMenuCommand(Execute, null, BeforeQueryStatus, _commandID);
_visible = true;
}
示例9: CreateConfigCommand
void CreateConfigCommand()
{
var configureCommandId = new CommandID(cmdSet, 1);
configureCommand = new OleMenuCommand(delegate { configureMenuCallback.ConfigureCallback(); }, configureCommandId);
configureCommand.BeforeQueryStatus += delegate { menuStatusChecker.ConfigureCommandStatusCheck(configureCommand); };
menuCommandService.AddCommand(configureCommand);
}
示例10: Initialize
protected override void Initialize()
{
base.Initialize();
var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (null != mcs) {
var id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatDocumentCommand);
_formatDocMenuCommand = new OleMenuCommand(FormatDocumentCallback, id);
mcs.AddCommand(_formatDocMenuCommand);
_formatDocMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;
id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatSelectionCommand);
_formatSelMenuCommand = new OleMenuCommand(FormatSelectionCallback, id);
mcs.AddCommand(_formatSelMenuCommand);
_formatSelMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;
}
_dte = (DTE)GetService(typeof(DTE));
_documentEventListener = new DocumentEventListener(this);
_documentEventListener.BeforeSave += OnBeforeDocumentSave;
if (_dte.RegistryRoot.Contains("VisualStudio")) {
_isCSharpEnabled = true;
}
_props = _dte.Properties["AStyle Formatter", "General"];
_props.Item("IsCSarpEnabled").Value = _isCSharpEnabled;
}
示例11: QueryStatusInternal
protected override void QueryStatusInternal(OleMenuCommand command)
{
command.Enabled = false;
command.Visible = false;
if (this.propertyManager == null)
{
return;
}
IList<Project> projects = this.propertyManager
.GetSelectedProjects()
.ToList();
if (projects.Any() && projects.All(x => Language.ForProject(x).IsSupported))
{
IList<bool?> properties = projects.Select(x =>
this.propertyManager.GetBooleanProperty(x, PropertyName)).ToList();
command.Enabled = true;
command.Visible = true;
// Checked if all projects have the same value, and that value is
// the same as the value this instance is responsible for.
command.Checked = properties.AllEqual() && (properties.First() == this.commandPropertyValue);
}
}
开发者ID:SonarSource-VisualStudio,项目名称:sonarlint-visualstudio,代码行数:25,代码来源:ProjectTestPropertySetCommand.cs
示例12: NuGetSearchTask
public NuGetSearchTask(NuGetSearchProvider provider, uint cookie, IVsSearchQuery searchQuery, IVsSearchProviderCallback searchCallback, OleMenuCommand managePackageDialogCommand, OleMenuCommand managePackageForSolutionDialogCommand)
{
if (provider == null)
{
throw new ArgumentNullException("provider");
}
if (searchQuery == null)
{
throw new ArgumentNullException("searchQuery");
}
if (searchCallback == null)
{
throw new ArgumentNullException("searchCallback");
}
if (managePackageDialogCommand == null)
{
throw new ArgumentNullException("managePackageDialogCommand");
}
if (managePackageForSolutionDialogCommand == null)
{
throw new ArgumentNullException("managePackageForSolutionDialogCommand");
}
_provider = provider;
_searchCallback = searchCallback;
_managePackageDialogCommand = managePackageDialogCommand;
_managePackageForSolutionDialogCommand = managePackageForSolutionDialogCommand;
SearchQuery = searchQuery;
Id = cookie;
ErrorCode = 0;
SetStatus(VsSearchTaskStatus.Created);
}
示例13: Initialize
/// <summary>
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// </summary>
protected override void Initialize()
{
base.Initialize();
// Add our command handlers for menu (commands must exist in the .vsct file)
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (null != mcs)
{
// Create the command for the menu items.
CommandID pluginMenuCommandId1 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem1);
OleMenuCommand pluginMenuItem1 = new OleMenuCommand(MenuItem1Callback, pluginMenuCommandId1);
pluginMenuItem1.BeforeQueryStatus += menuItem1_BeforeQueryStatus;
mcs.AddCommand(pluginMenuItem1);
CommandID pluginMenuCommandId2 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem2);
OleMenuCommand pluginMenuItem2 = new OleMenuCommand(MenuItem2Callback, pluginMenuCommandId2);
pluginMenuItem2.BeforeQueryStatus += menuItem2_BeforeQueryStatus;
mcs.AddCommand(pluginMenuItem2);
CommandID pluginMenuCommandId3 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem3);
OleMenuCommand pluginMenuItem3 = new OleMenuCommand(MenuItem3Callback, pluginMenuCommandId3);
pluginMenuItem3.BeforeQueryStatus += menuItem3_BeforeQueryStatus;
mcs.AddCommand(pluginMenuItem3);
}
}
示例14: SetupCommands
public void SetupCommands()
{
CommandID commandId = new CommandID(GuidList.guidEditorExtensionsCmdSet, (int)PkgCmdIDList.ReferenceJs);
OleMenuCommand menuCommand = new OleMenuCommand((s, e) => Execute(), commandId);
menuCommand.BeforeQueryStatus += menuCommand_BeforeQueryStatus;
_mcs.AddCommand(menuCommand);
}
示例15: AddInheritDocCommand
private AddInheritDocCommand(Package package)
{
this.package = package;
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandId = new CommandID(CommandSet, CommandId);
var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId);
commandService.AddCommand(menuItem);
menuItem.BeforeQueryStatus += (sender, e) =>
{
bool visible = false;
var dte = (DTE)Package.GetGlobalService(typeof(SDTE));
var classElem = SearchService.FindClass(dte);
if (classElem != null)
{
List<CodeElement> codeElements = SearchService.FindCodeElements(dte);
if (classElem.ImplementedInterfaces.Count > 0)
{
visible = true;
}
else
{
visible = codeElements.Any(elem => elem.IsInherited() || elem.OverridesSomething());
}
}
((OleMenuCommand)sender).Visible = visible;
};
}
}