Visual Studio 扩展:如何禁用本机命令? [英] Visual Studio Extension: How to disable native command?

查看:22
本文介绍了Visual Studio 扩展:如何禁用本机命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了一个可以正确管理 Git 模块的扩展,为此,我在解决方案中有一个名为 SubModules 的文件夹.

I build an extension that manages correctly Git Modules and, to do so, I have a folder in the solution called SubModules.

我设法将上下文菜单添加到解决方案文件和项目文件中,但我想在右键单击我的 SubModules 文件夹(即删除、添加)时禁用一些本机命令.

I managed to add my context menu to the solution file and to the project files, but I would like to disable some native commands when right-clicking on my SubModules folder (i.e. Remove, Add).

有没有办法禁用这样的原生命令?

Is there a way to disable such native command?

我尝试探索 EnvDTE80.DTE2.Commands,但没有运气,搜索告诉我如何禁用我自己的命令(我已经知道如何).

I tried exploring EnvDTE80.DTE2.Commands, but no luck and searching tells me how to disable my own commands (which I already know how).

我的扩展是用 C# 开发的,但在 VB.Net 中的答案也可以.

My extension is developed in C#, but an answer in VB.Net is alright too.

推荐答案

您可以订阅 commandEvents.BeforeExecute,检查处理程序中的命令名称并设置 CancelDefault = true 以禁用命令.请参阅在运行 Build.RebuildSolution 和其他重建命令之前添加确认.

You can subscribe to commandEvents.BeforeExecute, check the command name in the handler and set CancelDefault = true to disable a command. See Add confirmation before running Build.RebuildSolution and other rebuild commands.

这篇关于Visual Studio 扩展:如何禁用本机命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆