本文整理汇总了C#中Microsoft.VisualStudio.Shell.OleMenuCommand类的典型用法代码示例。如果您正苦于以下问题:C# OleMenuCommand类的具体用法?C# OleMenuCommand怎么用?C# OleMenuCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OleMenuCommand类属于Microsoft.VisualStudio.Shell命名空间,在下文中一共展示了OleMenuCommand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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}");
}
}
开发者ID:k4gdw,项目名称:SaveAllTheTabs,代码行数:25,代码来源:RestoreTabsListCommands.cs
示例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);
}
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:7,代码来源:Diff.cs
示例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);
}
开发者ID:duncansmart,项目名称:TortoiseGitToolbar,代码行数:7,代码来源:TortoiseGitToolbarPackage.cs
示例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);
}
}
开发者ID:pmchugh,项目名称:SpecFlow,代码行数:29,代码来源:SpecFlowPackage.cs
示例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);
}
开发者ID:vandro,项目名称:FileNesting,代码行数:7,代码来源:RunAutoNestingButton.cs
示例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);
}
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:7,代码来源:CompressImage.cs
示例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);
}
开发者ID:bayulabster,项目名称:viasfora,代码行数:7,代码来源:VsCommand.cs
示例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;
}
开发者ID:fschneidereit,项目名称:VSEssentials,代码行数:7,代码来源:InsertGuidCommand.cs
示例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);
}
开发者ID:paulcbetts,项目名称:Fody,代码行数:7,代码来源:MenuConfigure.cs
示例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;
}
开发者ID:nelabidi,项目名称:astyle-extension,代码行数:29,代码来源:AStyleExtensionPackage.cs
示例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);
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:33,代码来源:NugetSearchTask.cs
示例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);
}
}
开发者ID:kwechsler,项目名称:CRMDeveloperExtensions,代码行数:29,代码来源:TemplateMenuCommandsPackage.cs
示例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);
}
开发者ID:Russe11,项目名称:WebEssentials2013,代码行数:7,代码来源:ReferenceJs.cs
示例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;
};
}
}
开发者ID:mmahulea,项目名称:FactonExtensionPackage,代码行数:32,代码来源:AddInheritDocCommand.cs
示例16: Initialize
protected override void Initialize()
{
base.Initialize();
_dte = GetService(typeof(DTE)) as DTE2;
_activityLogger = new ActivityLogger(GetService(typeof(SVsActivityLog)) as IVsActivityLog);
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (null != mcs)
{
CommandID cmdId = new CommandID(GuidList.guidTemplatePackCmdSet, (int)PkgCmdIDList.cmdidMyCommand);
OleMenuCommand button = new OleMenuCommand(ButtonClicked, cmdId);
button.BeforeQueryStatus += button_BeforeQueryStatus;
mcs.AddCommand(button);
CommandID menuCommandID = new CommandID(GuidList.guidMenuOptionsCmdSet, (int)PkgCmdIDList.SWMenuGroup);
OleMenuCommand menuItem = new OleMenuCommand(OpenSettings, menuCommandID);
mcs.AddCommand(menuItem);
}
System.Threading.Tasks.Task.Run(async () => {
await System.Threading.Tasks.Task.Delay(100);
try {
new DynamicTemplateBuilder(_dte, _activityLogger).ProcessTemplates();
}
catch (Exception ex) {
_activityLogger.Error(ex.ToString());
_dte.StatusBar.Text = @"An error occured while updating templates, check the activity log";
// Leave this for now until we are sure activity logger above works well
System.Windows.MessageBox.Show(ex.ToString());
}
});
}
开发者ID:FullStackPro,项目名称:side-waffle,代码行数:34,代码来源:TemplatePackPackage.cs
示例17: CompilerOutputCmds
private CompilerOutputCmds(DevUtilsPackage package)
{
this.package = package;
// Add our command handlers for menu (commands must exist in the .vsct file)
OleMenuCommandService mcs = serviceProvider.GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
if (null != mcs)
{
// Create the command for the menu item.
CommandID menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowAssembly);
var cmd = new OleMenuCommand((s, e) => showCppOutput(1), changeHandler, beforeQueryStatus, menuCommandID);
cmd.Properties["lang"] = "C/C++";
mcs.AddCommand(cmd);
menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowPreprocessed);
cmd = new OleMenuCommand((s, e) => showCppOutput(2), changeHandler, beforeQueryStatus, menuCommandID);
cmd.Properties["lang"] = "C/C++";
mcs.AddCommand(cmd);
menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowDecompiledCSharp);
cmd = new OleMenuCommand((s, e) => showDecompiledCSharp(), changeHandler, beforeQueryStatus, menuCommandID);
cmd.Properties["lang"] = "CSharp";
mcs.AddCommand(cmd);
}
}
开发者ID:Trass3r,项目名称:DevUtils,代码行数:25,代码来源:CompilerOutputCmds.cs
示例18: TestStatus
private void TestStatus(OleMenuCommand cmd) {
_lp.IsFeedbackPermitted.Returns(false);
cmd.Should().BeInvisibleAndDisabled();
_lp.IsFeedbackPermitted.Returns(true);
cmd.Should().BeEnabled();
}
开发者ID:Microsoft,项目名称:RTVS,代码行数:7,代码来源:FeedbackCommandTest.cs
示例19: Initialize
protected override void Initialize()
{
base.Initialize();
_dte = GetService(typeof(DTE)) as DTE2;
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
CommandID cmdCustom = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCommandLine);
OleMenuCommand customItem = new OleMenuCommand(OpenCustom, cmdCustom);
customItem.BeforeQueryStatus += BeforeQueryStatus;
mcs.AddCommand(customItem);
CommandID cmdCmd = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCmd);
MenuCommand cmdItem = new MenuCommand(OpenCmd, cmdCmd);
mcs.AddCommand(cmdItem);
CommandID cmdPowershell = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenPowershell);
MenuCommand powershellItem = new MenuCommand(OpenPowershell, cmdPowershell);
mcs.AddCommand(powershellItem);
CommandID cmdOptions = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenOptions);
MenuCommand optionsItem = new MenuCommand((s, e) => { ShowOptionPage(typeof(Options)); }, cmdOptions);
mcs.AddCommand(optionsItem);
CommandID cmdExe = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdExecuteCmd);
OleMenuCommand exeItem = new OleMenuCommand(ExecuteFile, cmdExe);
exeItem.BeforeQueryStatus += BeforeExeQuery;
mcs.AddCommand(exeItem);
}
开发者ID:IDisposable,项目名称:OpenCommandLine,代码行数:30,代码来源:OpenCommandLinePackage.cs
示例20: Initialize
protected override void Initialize()
{
base.Initialize();
_logger = new Logger();
_dte = GetGlobalService(typeof(DTE)) as DTE;
if (_dte == null)
return;
// Add our command handlers for menu (commands must exist in the .vsct file)
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (mcs != null)
{
// Create the command for the tool window
CommandID windowCommandId = new CommandID(GuidList.GuidReportDeployerCmdSet, (int)PkgCmdIdList.CmdidReportDeployerWindow);
OleMenuCommand windowItem = new OleMenuCommand(ShowToolWindow, windowCommandId);
mcs.AddCommand(windowItem);
// Create the command for the menu item.
CommandID publishCommandId = new CommandID(GuidList.GuidItemMenuCommandsCmdSet, (int)PkgCmdIdList.CmdidReportDeployerPublish);
OleMenuCommand publishMenuItem = new OleMenuCommand(PublishItemCallback, publishCommandId);
publishMenuItem.BeforeQueryStatus += PublishItem_BeforeQueryStatus;
publishMenuItem.Visible = false;
mcs.AddCommand(publishMenuItem);
}
}
开发者ID:LeszekSzejka,项目名称:CRMDeveloperExtensions,代码行数:27,代码来源:ReportDeployerPackage.cs
注:本文中的Microsoft.VisualStudio.Shell.OleMenuCommand类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论