2008-09-17 42 views

回答

7

对于VS2005,我一直在使用CoolCommands 4.0older 3.0 version的功能描述更加完整。 版本3有一个.msi安装程序。版本4是.zip file(这对我的环境来说更容易)。

我最喜欢的功能(完整列表的子集):

  • 从Solution Explorer:
    • 收起所有项目
    • 打开包含文件夹(项目/文件只平)
  • 从编辑器上方的文件名选项卡
    • 定位在Solution Explorer
  • 从上下文菜单编辑器
    • Demo字体
+0

CoolCommands是开源的,所以你可以添加更多的功能:-)。 – AlePani 2008-10-13 03:45:53

+0

托管的开源版本在哪里? – tjrobinson 2009-06-12 09:31:50

3

这里的特点为CoolCommands 4.0一个更好的列表。

要为VS 2005安装它,请执行include setup.bat。

regpkg CoolCommands.dll /root:Software\Microsoft\VisualStudio\9.0 /codebase 
9

我使用下面的宏这在Visual Studio 2005和Visual Studio 2008的工作原理:

要安装它的VS 2008,从

regpkg CoolCommands.dll /codebase 

修改以下行

  1. 查看>其他窗口>宏浏览器(Alt + F8)
  2. 右键单击宏浏览器中的MyMacros节点
  3. 新模块...
  4. 将它命名为CollapseAll(或任何你喜欢)
  5. 替换下面
  6. 文件显示的代码默认代码>保存CollapseAll(按Ctrl + S)
  7. 关闭宏编辑器

要建立一个快捷键:

  1. 工具>自定义...>命令
  2. Keyboar d ...含
  3. 显示命令:Macros.MyMacros.CollapseAll.CollapseAll
  4. 指定一个快捷键(我使用Alt + C)

代码

Imports System 
Imports EnvDTE 
Imports EnvDTE80 
Imports System.Diagnostics 

Public Module CollapseAll 
    Sub CollapseAll() 

     ' 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 

    Sub CollapseSelected() 

     ' 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 selected As Array = solutionExplorer.SelectedItems 

     If (selected.Length = 0) Then Return 

     Dim rootNode As UIHierarchyItem = selected(0) 
     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 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 

End Module 

我没有编写这段代码,我不确定这段代码来自哪里,但它的在线版本有所不同。

相关问题