Playing Chicken With Common Sense

The Visual Studio Solution Explorer can become difficult to navigate when a solution becomes quite large.  I have used a tool for some time now called SonicFileFinder.  It has become one of my favorite utilities.

SonicFileFinder is a free add-in for Visual Studio that allows a fast and convenient search for any file within every Project of the loaded Solution by entering the complete filename or just a part of it. The found file(s) can either be edited with a single keystroke or a Windows Explorer / CommandLine prompt can be opened at the file's location.



UPDATE: 07-09-2008

Resharper has this feature as well.  Just hit ctrl-N and type away.


Collapse Macro

The Solution Explorer is still useful for seeing the hierarchy of files but when you have opened 20 files in different projects then that's a different story.  It looks like pea soup - DISGUSTING! :)

Here is a macro that I find to be very handy for this situation.  It will collapse the solution explorer tree down to the projects or root nodes.

These instructions come via Google search and

   1: Imports System
   2: Imports EnvDTE
   3: Imports System.Diagnostics
   5: Public Module Collapse
   6:     Sub CollapseAll()
   7:         ' Get the the Solution Explorer tree
   8:         Dim UIHSolutionExplorer As UIHierarchy
   9:         UIHSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
  10:         ' Check if there is any open solution
  11:         If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
  12:             ' MsgBox("Nothing to collapse. You must have an open solution.")
  13:             Return
  14:         End If
  15:         ' Get the top node (the name of the solution)
  16:         Dim UIHSolutionRootNode As UIHierarchyItem
  17:         UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)
  18:         UIHSolutionRootNode.DTE.SuppressUI = True
  19:         ' Collapse each project node
  20:         Dim UIHItem As UIHierarchyItem
  21:         For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
  22:             'UIHItem.UIHierarchyItems.Expanded = False
  23:             If UIHItem.UIHierarchyItems.Expanded Then
  24:                 Collapse(UIHItem)
  25:             End If
  26:         Next
  27:         ' Select the solution node, or else when you click 
  28:         ' on the solution window
  29:         ' scrollbar, it will synchronize the open document 
  30:         ' with the tree and pop
  31:         ' out the corresponding node which is probably not what you want.
  32:         UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
  33:         UIHSolutionRootNode.DTE.SuppressUI = False
  34:     End Sub
  36:     Private Sub Collapse(ByVal item As UIHierarchyItem)
  37:         For Each eitem As UIHierarchyItem In item.UIHierarchyItems
  38:             If eitem.UIHierarchyItems.Expanded AndAlso eitem.UIHierarchyItems.Count > 0 Then
  39:                 Collapse(eitem)
  40:             End If
  41:         Next
  42:         item.UIHierarchyItems.Expanded = False
  43:     End Sub
  44: End Module

Setting up the macro:

  1. Open the macro explorer in Visual Studio
  2. Right-Click "MyMacros" and choose "New Module"
  3. Name it Collapse and click "Open"
  4. Double-Click the new "Collapse" Module
    ("Microsoft Visual Studio Macros [design] - Collapse" window will appear)
  5. Delete ALL of the text in the window.
  6. Copy/Paste the contents of the CollapseMacro.txt file into the window
  7. Click the Save Icon and close the window.

Adding a shortcut button:

  1. Right-click anywhere on the toolbar and choose "Customize"
    (The Customize Dialog will appear)
  2. Click the "Toolbars" tab.
  3. Click the "New" button.
    (The "New Toolbar" dialog will appear)
  4. Name it anything you want I named mine "My Toolbar"
  5. Click OK.
    (A new toolbar will appear floating near the "Customize" dialog.)
  6. Click the "Commands" tab.
  7. In the "Categories:" list box, choose "Macros".
  8. In the "Commands:" list box, choose "MyMacros.Collapse.CollapseAll" and DRAG it to your new toolbar.
    (Your "My Toolbar" toolbar should now look like this)
  9. Right-Click the command, click on the "Name" menu item, then type "Collapse Solution Explorer".
  10. Close the "Customize" dialog box.
  11. Drag the new toolbar into your toolstrip at the top of the screen, just above your solution explorer.
  12. Go back to your solution explorer, open a solution, and try clicking the button
  • E-mail
  • Kick it!
  • Shout it
  • Bookmark and Share


Control panel


Comment RSS