sharptooth
sharptooth

Reputation: 170549

How can "Save All" button press be handled in Visual Studio Extensibility?

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?

Upvotes: 0

Views: 459

Answers (1)

Sergey Vlasov
Sergey Vlasov

Reputation: 27940

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.

Upvotes: 1

Related Questions