TechnoTone Posted February 4, 2004 Posted February 4, 2004 I have written a macro that will auto-collapse code windows on opening. I don't know whether anyone else would find this a useful as I do but I'm posting it anyway. Dim myWindows As New Collection Dim myThread As System.Threading.Thread Private Sub WindowEvents_WindowCreated(ByVal Window As EnvDTE.Window) Handles WindowEvents.WindowCreated Try myWindows.Add(Window) If myThread Is Nothing Then myThread = New System.Threading.Thread(AddressOf CollapseToDefinition) End If If myThread.ThreadState = System.Threading.ThreadState.Unstarted Then myThread.Start() Catch ex As System.Exception MsgBox(ex.Message) End Try End Sub Public Sub CollapseToDefinition() Dim myCount As Integer Do myCount = myWindows.Count myThread.Sleep(100) Loop Until myCount = myWindows.Count Dim myWindow As Window While myWindows.Count > 0 Try myWindow = myWindows.Item(1) myWindows.Remove(1) myWindow.Activate() DTE.ExecuteCommand("Edit.CollapsetoDefinitions") Catch End Try End While myThread = Nothing End Sub To install it, open the Macros IDE, open MyMacros-EnvironmentEvents, and copy-paste this code into the EnvironmentEvents module. *It was written for VS.NET 2003. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
samsmithnz Posted February 4, 2004 Posted February 4, 2004 what exactly do you mean by 'auto-collapse code windows'??? Quote Thanks Sam http://www.samsmith.co.nz
TechnoTone Posted February 4, 2004 Author Posted February 4, 2004 I'm referring to outlining. If you still don't know what I mean, open a code window (one with lots of code will work best), right-click and select Outlining - Collapse to Definitions (or press CTRL+MO). ;) Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
Procaine Posted February 4, 2004 Posted February 4, 2004 As in #regions? Very cool, I'll use this. Thanks. Quote
TechnoTone Posted February 10, 2004 Author Posted February 10, 2004 Has no one else found this of any use? I'm surprised as I found the inability of the IDE to remember the outlined/collapsed state of a file to be one of the most annoying omissions. It really bothered me that every time I opened a code window I would have to manually collapse the code myself. p.s. Moderators - is this a worthy entry for the Code Library? Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
TechnoTone Posted February 10, 2004 Author Posted February 10, 2004 I've found it very useful. Nice. I'm glad that someone (other than me) thought it worthwhile. :) Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
rifter1818 Posted February 11, 2004 Posted February 11, 2004 Thanks for the post I never actually knew that you could write macros for the enviornment im sure ill have fun with them,.. however ive often thought that this was something that was missing, im programming a rpg and scanning through 40 or 50 objects is annoying every time..... Quote
mocella Posted February 12, 2004 Posted February 12, 2004 Good stuff - I already have the "Collapse-All" macro running from CodeProject, which collapses all your projects in the solution explorer. If you're on a project with multiple projects in the solution, this thing is a god-send. If you're interested in that goodie: http://www.codeproject.com/macro/collapseall.asp Quote
mocella Posted February 12, 2004 Posted February 12, 2004 A little more digging and I came up with this listing of the short-cut keys for the IDE: http://dotnetjunkies.com/WebLog/peter%20marshall/articles/1990.aspx Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.