Collapse Solution Explorer suggestion

Post DPack feature requests here.

Moderator: Sergey

Collapse Solution Explorer suggestion

Postby koger » November 12th, 2007, 5:19 am

I found this macro, that collapses every item in the solution explorer, perhaps you want to use that, here is the link:

that.http://geekswithblogs.net/scottkuhl/arc ... 11195.aspx

and the full source (including an optimization from the blog comment)

'Collapse all nodes in Solution Explorer
Sub CollapseAllSolution()
' Get the the Solution Explorer tree
Dim solutionExplorer As UIHierarchy
solutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()

' Check if there is any open solution
If (solutionExplorer.UIHierarchyItems.Count = 0) Then
Return
End If

' Get the top node (the name of the solution)
Dim rootNode As UIHierarchyItem = solutionExplorer.UIHierarchyItems.Item(1)
rootNode.DTE.SuppressUI = True

' Collapse each project node
Collapse(rootNode, solutionExplorer)

' Select the solution node, or else when you click
' on the solution window
' scrollbar, it will synchronize the open document
' with the tree and pop
' out the corresponding node which is probably not what you want.

rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
rootNode.DTE.SuppressUI = False
End Sub

Private Sub Collapse(ByVal item As UIHierarchyItem, ByRef solutionExplorer As UIHierarchy)
For Each innerItem As UIHierarchyItem In item.UIHierarchyItems
If innerItem.UIHierarchyItems.Count > 0 And innerItem.UIHierarchyItems.Expanded Then
' Re-cursive call
Collapse(innerItem, solutionExplorer)

' Collapse
If innerItem.UIHierarchyItems.Expanded Then
innerItem.UIHierarchyItems.Expanded = False
If innerItem.UIHierarchyItems.Expanded = True Then
' Bug in VS 2005
innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
solutionExplorer.DoDefaultAction()
End If
End If
End If
Next
End Sub


'Attach to IIS process for debugging
Sub DebugIIS()
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(3) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("T-SQL")
dbgeng(1) = trans.Engines.Item("T-SQL")
dbgeng(2) = trans.Engines.Item("Managed")
Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "").Item("aspnet_wp.exe")
proc2.Attach2(dbgeng)
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
koger
Junior Member
 
Posts: 5
Joined: November 6th, 2007, 6:34 am

Postby Sergey » November 13th, 2007, 10:54 am

Thanks for the URL.

BTW, did you know that DPack's 'Collapse All Projects' feature does roughly the same? You can find it on DPack's main menu or on Solution Explorer's context menu.
Sergey @ USysWare
User avatar
Sergey
Moderator
 
Posts: 590
Joined: May 27th, 2005, 3:56 pm
Location: Alexandria, VA

Postby hobbes_child » February 1st, 2008, 12:36 pm

I have tried your Collapse All Projects feature, and because my solution is rather large, it takes 30 seconds to collapse every single level.

It would be nice if the user could configure how many levels deep they want to collapse. 1 or 2 is usually sufficient.

Cheers!
User avatar
hobbes_child
Starting Member
 
Posts: 2
Joined: February 1st, 2008, 12:33 pm

Postby Sergey » February 1st, 2008, 1:26 pm

Odd. I have a solution with 32 projects and roughly 1000 code files, and it takes about 3 seconds to collapse it. This is on VS 2005. AFAIK, it should be even faster on VS 2008.

Nevertheless, one thing I can do is force it to collapse projects only if typical project size is set to anything other than Normal (Tools|DPack|Options, DPack|General screen). I can try squeezing that into next 2.8.2 release, scheduled to go out in a week time frame.

Thanks.
Sergey @ USysWare
User avatar
Sergey
Moderator
 
Posts: 590
Joined: May 27th, 2005, 3:56 pm
Location: Alexandria, VA

Postby Sergey » February 2nd, 2008, 1:04 am

hobbes_child wrote:It would be nice if the user could configure how many levels deep they want to collapse. 1 or 2 is usually sufficient.


Done. In the next version setting solution size to anything other than Regular (Tools|DPack|Options, DPack|General screen) will result in collapse stop at the project node. In other words it won't do a recursive collapse of project sub-nodes.

HTH.
Sergey @ USysWare
User avatar
Sergey
Moderator
 
Posts: 590
Joined: May 27th, 2005, 3:56 pm
Location: Alexandria, VA

Postby hobbes_child » February 4th, 2008, 6:58 am

Thank you Sergey.

FWIW my solution has 25 projects containing 2643 C# source files. It's a beast! I hasten to add it's a legacy system I do maintenance on, not something I wrote for fun. :)

I am running VS 2005.

The source is linked to a remote subversion server, so I guess the internet may be partly to blame for the delay.

Thanks again.
User avatar
hobbes_child
Starting Member
 
Posts: 2
Joined: February 1st, 2008, 12:33 pm

Postby Sergey » February 10th, 2008, 8:35 pm

Just wanted to let you know that new version is out. Thanks.
Sergey @ USysWare
User avatar
Sergey
Moderator
 
Posts: 590
Joined: May 27th, 2005, 3:56 pm
Location: Alexandria, VA


Return to DPack Wish List

Who is online

Users browsing this forum: No registered users and 1 guest

cron