vb.net - EnvironmentEvent macro doesn't complete -


I am working in Visual Studio 2008 and I would like to compress> outlining> definitions for editing whenever I open One line It would be nice, after that, all areas were expanded. I tried the code which offered in a comment on Kyralessa, and it works very well as a macro that will run me manually by placing the following code in the EnvironmentEvents module in this macro macro IDE tried to extend to act as an event:

  public sub documentEvents_DocumentOpened (ByVal document EnvDTE.Document as) handles DocumentEvents.DocumentOpened documentDTE Excite Commands ("Edit. Callpoto Definition") DTE Shooter UI = True Dim Option. TextSeclectation = Dte as selection Active Documents Selection obz selection. Startoff document (obz) selection Fund Test ("#selected", "Windifed Option:. VSFI and Opports Match Inhaled Text") Loop Oz Selection StartOfDocument () DTE.SuppressUI = False End Sub  

However, when I VS I open a file with my solution, so nothing like that. To test that was getting macro runs, I have a MsgBox () that statement in the subroutine and the first Document.DTE.ExecuteCommand ( "Edit.CollapsetoDefinitions") that code The view was going well, but after that line there was not a hit when I debug inside SubBrawin and set a breakpoint, then I continued to beat the F10 to continue the next line and as the control The same went to the ExecuteCommand line, the above will be skipped . Despite this, this line is not doing anything, i.e. this framework does not collapse.

I also have DTE.ExecuteCommand ("Edit.CollapsetoDefinitions") suburban but no luck.

This question tries to achieve the same end result, but I am asking what is going wrong in my EventMenagra macro.

The problem is that the document is not actually active when the event is active, after a solution, DocumentOpened event was "once the fire" timer to execute a slight delay in the code to use:

  dim DocumentOpenedTimer timer Private sub DocumentEvents_DocumentOpened (ByVal document as EnvDTE.Document) In Handle DocumentEvents.DocumentOpened DocumentOpenedTimer = New Timer (AddressOf ExpandRegionsCallBack, nothing, 200, Timeout.Infinite) End Sub Personal Sub Exp AndRegionsCallBack (ByVal State Object) ExpandRegions () DocumentOpenedTimer.Dispose () End Sub Public Sub ExpandRegions () Dim Documents as EnvDTE Document = DTE.ActiveDocument are (Document.FullName.EndsWith ( ". Vb") OrElse Document.FullName.EndsWith ( ". CS")) not above DTE.ActiveWindow.Caption.ToUpperInvariant.Contains ( "design" .ToUpperInvariant ) Then the document. DTE.SuppressUI = True Document.DTE.ExecuteCommand ("Edit.CollapsetoDefinitions") Select the dual option as TextSelection = Document. Select the objSelection.StartOfDocum ENT () while objSelection.FindText ( "# Region", vsFindOptions.vsFindOptionsMatchInHiddenText) loop objSelection.StartOfDocument () Document.DTE.SuppressUI = False End If End If End Sub  

I have not tested Haven on a large scale, so there may be some bugs ... Besides this, I added a check to verify that the active document is a C # or VB source code (though Not tested with VB) and not in design mode Is not. Anyway, hopefully this works for you ...


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -