Display a Progress Bar inside a Toolwindow in Visual Studio.
- Technologies: Visual Studio 2015 SDK
- Topics: Visual Studio Shell, VSX
Description
This Visual Studio Package provides a new tool window called "Build Progress". The window displays a WPF ProgressBar that indicates percentage completion of the current solution build.
Requirements
Get all samples
Clone the repo (How to):
git clone https://github.com/Microsoft/VSSDK-Extensibility-Samples.git
Run the sample
- To build and execute the sample, open the .sln file, press F5 after the sample is loaded
- Once loaded, choose the View > Other Windows > Build Progress menu command.
- A new tool window called "Build Progress" will open, displaying a WPF ProgressBar control. You can move, resize, or dock this tool window however you like.
- Open an existing buildable solution or create a new one using the File > New > Project menu command.
- Once the solution has loaded, build the solution by running the Build > Build Solution menu command.
- You should see the progress bar's value and text change as each project in the solution is built. The file is displayed in the editor with colored text
Source Code Overview
The source code in this sample demonstrates several techniques you can use to write your own packages:
- How to add a menu command to the View > Other Windows menu group.
- How to display WPF content on a tool window
- How to monitor solution load/unload events
- How to monitor solution build events
- How to check and monitor the value of a Visual Studio Shell property (VisualEffectsAllowed)
Our Visual Studio Package implements the interfaces IVsShellPropertyEvents, IVsSolutionEvents, and IVsUpdateSolutionEvents2 so that it can receive notification of shell property changes, solution load/unload events, and solution build events. In order to receive calls to these interface methods, it must advise the appropriate service providers that we want to be notified, as demonstrated in ProgressBarPackage's Initialize method.
We monitor the value of the VisualEffectsAllowed shell property in order to modify how the progress bar is displayed. We also monitor solution load/unload events to keep track of how many projects are currently loaded in the solution. Lastly, we monitor solution build events in order to update the value and text of the progress bar.
Project Files
- BuildProgressBar.vsct
Defines layout and type of commands in the package, namely the Build Progress menu command
- BuildProgressToolWindow.cs
Implements the tool window functionality, and owns an instance of the ProgressBarControl
- ProgressBarControl.xaml
Defines the XAML for the ProgressBarControl, which is the content hosted on the tool window
- ProgressBarControl.xaml.cs
Defines the code-behind for the ProgressBarControl. This gives us greater control over the behavior of the ProgressBarControl
- ProgressBarPackage.cs
Implements the Visual Studio Package, where we monitor events
**Related topics **