Visual Studio Hacks [Electronic resources]

Andrew Lockhart

نسخه متنی -صفحه : 172/ 53
نمايش فراداده

Hack 26. Create Custom Window Layouts

Visual Studio's windows are a dashboard view of your project. You can create different window layouts and even switch between them on the fly.

In [Hack #16], I discussed how to modify your window environment in the Visual Studio IDE. You can rearrange your windows in a number of different ways, including the ability to dock, float, hide, and auto hide windows. Back in that hack, I also mentioned that there are a number of default windows layouts. For instance, there is a layout for design mode and a layout for debug mode. Modifications to those window layouts are done independently from each other. Changes to the window layout while in debug mode don't affect the window layout of design mode.

By default, Visual Studio includes a number of different window layouts but does not include a way to create your own custom layouts or switch between layouts. Thankfully, the Visual Studio team has released a power toy called VSWindowManager which will allow you to do this.

You can download the VSWindowManager power toy from http://workspaces.gotdotnet.com/vswindowmanager. Be sure to close all instances of Visual Studio before installing the power toy. After you have installed the power toy, it will add two new items to the Window menu in Visual Studio, as shown in Figures Figure 4-10 and Figure 4-11.

Figure 4-10. VSWindowManager Save Window Layout As... menu

Figure 4-11. VSWindowManager Apply Window Layout menu

These new menu items allow you to create your own custom window layouts and switch between these layouts at any time. To try out this new feature, first customize your window layout for when you design forms, whether Windows Forms or ASP.NETfor example, you might customize it so as to keep the toolbox or the Solution Explorer open, and so on. Once you have configured the window layout the way you like it for design, click on the Save Window Layout As... menu item and select My Design Layout. This will save the current window layout as your design layout.

Next, configure the window layout for when you are writing code. The toolbox is probably hidden; perhaps the task list is now visible. Once you have the windows laid out the way you want, click on Save Window Layout As... again, and this time choose My Coding Layout.

Now that you have two different layouts saved, you can quickly switch between the two layouts using the Apply Windows Layout menu item. You simply need to click that menu item, then select the window layout that you want to switch to. Visual Studio will then relatively quickly switch to the other window layout.

The VSWindowManager power toy is a great tool that allows you to save custom window layouts and then quickly switch between those window layouts. Creating and using different window layouts is a great way to get the most out of the IDE and save time when moving between different coding modes. It is nice to always have Visual Studio configured the way that you like it without the hassle of hiding and showing windows each time you switch tasks.

4.4.1. Hacking the Hack

After creating these custom window layouts, it is nice to be able to move them to another machine. This can be done by copying a single file from your profile to your new system. The file is called devenv.xml and is located in the following directory:

\Documents and Settings\<username>\Application Data\Microsoft\VisualStudio\<7.1>\

This file can be copied from this directory to the same directory on your new system, and all of your window layouts should be available on your new system.