如何“全部保存”按钮按钮在Visual Studio可扩展性中处理? [英] How can "Save All" button press be handled in Visual Studio Extensibility?

查看:320
本文介绍了如何“全部保存”按钮按钮在Visual Studio可扩展性中处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当按下全部保存按钮时,我需要执行一些操作。如果我订阅了 DocumentSaved 事件,该事件对于每个未保存的文档被调用一次,这是一个问题,因为我宁愿为文档集合调用操作,而不是对于每个文档分开。

I need to have some action performed when "Save All" button is pressed. If I subscribe to DocumentSaved event that event is invoked once for each unsaved document and this is kind of a problem because I'd rather have the action invoked for the documents collection instead of for each document separately.

是否可以处理全部保存作为单个操作,而不是处理多个 DocumentSaved 事件?

Is it possible to handle "Save All" as a single action instead of handling multiple DocumentSaved events?

推荐答案

您可以使用以下代码订阅命令执行事件:

You can subscribe to the command execution events with the following code:

events = dte.Events;
commandEvents = events.get_CommandEvents(null, 0);
commandEvents.AfterExecute += OnAfterExecute;

在OnAfterExecute处理程序中,您可以检查它是否是File.SaveAll命令: VSConstants.VSStd97CmdID.SaveSolution

In your OnAfterExecute handler you can check if it is the File.SaveAll command: VSConstants.VSStd97CmdID.SaveSolution.

这篇关于如何“全部保存”按钮按钮在Visual Studio可扩展性中处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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