Navigation Window - Visual Studio SDK Sample

Navigation Window — Visual Studio SDK Sample

November 2005

Summary:

Navigation Window is a tool integrated on Visual Studio 2005 RTM that was written using Visual Studio SDK . It is a real use case that shows several features of the Visual Studio SDK.

 

Introduction to the Navigation Window Sample

 

How is the way to integrate power tools, languages, debuggers, editors , etc in Visual Studio 2005?

As you probably know there are many ways depend on what you need to integrate, you can integrate things using macros, writing addins (using automation model), and finally you can integrate things writing a “package” for Visual Studio using the Visual Studio SDK.

If you browsed the web probably you read that you should write a package if you want advanced features (like introduce a new language, a new editor, etc)Why? Because writing a package is harder than write an addin. This was true in the past, now with the last SDK release writing a package is as simple as write an addin. Why?

·          You can write your package in managed code even a project system.

·          You have the Managed Package Framework (MPF) now so you have base classes that encapsulate a lot of hard work.

·          You don’t need a unmanaged package for your resources anymore.

·          Documentation is really good now.

A toolwindow can be created writing an addin but writing a package is simple too and you have more power.

I was thinking in a sample that shows the use of some interfaces and classes of the MPF. I had another objective that was that the final sample could be used as a power tool.

Use Case: Navigation Window

 

Sometimes when we work with a lot of projects in VS it is difficult to find items in the Solution Explorer, so we have to use the open file dialog to find the item in the file system and open it. This is because the Solution Explorer is a categorized view of our project and sometimes we need a flat view of it.

Additionally some actions over a set of items are difficult to achieve, for example:

“For each xml file in the solution associate a custom tool”, why this is difficult? Because we have to traverse the tree finding the xml files in order to select them and after that set the property Custom Tool, even more difficult if we have many projects.

So the “Navigation Window” comes to solve these issues, it could be a complement to the Solution Explorer.

Implementation

 

Navigation Window is a Managed Package written in C# using Visual Studio SDK.

Essentially is a split with a filter panel and the list view panel.

In the list view panel items are showed grouped by project.

By default selection is synchronized with the Solution Explorer, when you select an item in the list view, the item is selected in the solution explorer (you can disabled this feature using the Synchronized Selection check box).

The icon associated to each item is the same that in the solution explorer, the process to get the icon on an item is the following:

·          Ask the hierarchy owner for the item icon

·          Ask the hierarchy owner for the image list and image index

·          Ask the file system by item extension

In the filter panel, items can be filtered by name (implemented using regular expressions) or by project. Hidden items can be listed. Virtual Items too (virtual items are items without file associated like the references folder)

Additionally in the filter panel there is a status and actions pane. The status panel indicates how many items and projects are showed in the list view. Actions are “Open Selection” (open the documents for the selected items) and “Open Container Folder” (open the container folder for the first item in the selection).

The list view of the Navigation Window is a selection container so when items are selected in the list view, items properties are showed in the property view.

Visual Studio context menu is enabled on the list view.

The Navigation Window is listening solution events so when a solution is opened it traverses the items  in the solution to get the projects and items info. So Navigation Window is a good sample of how to traverse the solution explorer using IVsHierarchy.

Navigation Window also shows how to use EnvDTE inside a VsPackage, the EnvDTE is used to show feedback in the status bar while a solution is opening.

 

If you install the sample the source code will be installed too so that you can take a look of it there are a lot of comments in it. In future posts I will explain some of the basics of the code of this sample. 

 

Interfaces and classes that I use in this sample

·          Package (Managed Package Framework)

·          ToolWindowPane (Managed Package Framework)

·          SelectionContainer (Managed Package Framework)

·          ITrackSelection

·          IMenuCommandService (for menus and context menu)

·          IVsHierarchy

·          IVsUIHierarchy

·          IVsUIHierarchyWindow

·          IVsSolution

·          IVsProject

·          IVsUIShell

·          IVsShell

·          IVsWindowFrame

·          IVsSolutionEvents

·          EnvDTE, StatusBar

 

Download

·                     Navigation Window Sample with source Code

Community

·                     VSIP

 

 

You can find the navigation window after the installation on View/Other Windows/Navigation Window

2 Comments

  • Primero le digo que llegué a su weblog por una conferéncia que dió Nicolás Jodal en el XV



    Encuentro Internacional Genexus.

    Me pareció muy interesante el Navigation Window,pero quisiera saber si para programar Paquetes



    para VS.NET es necesario tener VS.NET 2005 o si con la versión 2003 es posible.

    abjml@adinet.com.uy

    Gracias.

  • Can't download it anymore. Can you put it back.

Comments have been disabled for this content.