Note: For Visual Studio 2008 support and other improvements, please see this update by nelveticus.
Overview
Josh Beach has written a nice little tool to manage the "Recent projects" list in Visual Studio. It allows to edit the "recent projects" list for the start page of Visual Studio. I added the following features:
- Select the Visual Studio version you work with (see the drop down list above)
- "Kill Zombies" - removes all entries that don't exist anymore on disk
- "Kill Zombies & Projects" - remove all files that don't exist on disk, and everything that doesn't end in ".sln"
- "Explore", browsing to the current selection in explorer
- Changed the save handling to work together with version switching
I wanted to submit this as an update to Josh's article, but unfortunately he doesn't seem to be active on this site anymore.
The Code
Don't look at it, the stuff I added is horrible. :)
This is a straightforward C# WinForms application, with all the logic in the Forms
class. The list of projects is read from the registry, you can change the position in the list and add and remove items, and write back to the registry (all Josh's code). The dropdown selects the registry from which the information is read and can easily be configured.
TaggedString
The only class that might be of slight interest on an otherwise boring Sunday afternoon is TaggedString
which provides the Text/Tag separation for ListBox
and ComboBox
items, too.
The good citizen rule for feeding UI controls is to keep representation separate from the data. WinForms offers in most places a Tag
member where the caller can attach a reference to the actual data.
Unlike most WinForms controls, the ListBox
and ComboBox
don't offer a separate Tag
for its items. Rather, it accepts a collection of objects, and displays the result of ToString()
as item text. (This looks like sloppiness to me, but who knows?)
TaggedString
associates a string
(to be displayed) with a Tag
(the object associated with the listbox
/ combobox
item) like so:
public class TaggedString<T>
{
string m_title;
T m_tag;
public TaggedString(string title, T tag)
{
m_title = title;
m_tag = tag;
}
public override string ToString() { return m_title; }
public T Tag { get { return m_tag; } }
}
The Project List Editor stores the registry path in the tag, so it's using a TaggedString<string>
like this:
cbDevStudioVersion.Items.Add(
new PH.Util.TaggedString<string>(
"2005",
@"Software\Microsoft\VisualStudio\8.0\ProjectMRUList"));
This is by far the shortest time I spent on an article - I hope you like it anyway.