How can “Save All” button press be handled in Visu

2019-03-03 12:13发布

问题:

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.

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

回答1:

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

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

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