büyük çaplı projelerde uğraşıyorsanız ve Solution Explorer sekmenizde her projede örneğin arattırma yaptığınız zaman yada bir cs yada aspx dosyasından diğerine baktığınız zaman o projelerin hepsinin açık kalmasından hazzetmiyorsanız yada hepsini açıp hepsini birden kapatmak istiyorsanız size iki tane macro veriyorum umarım işinize yarar.
Collapse:
Imports System
Imports EnvDTE
Imports System.Diagnostics
Public Module Collapse
Sub CollapseAll()
' Get the the Solution Explorer tree
Dim UIHSolutionExplorer As UIHierarchy
UIHSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
' Check if there is any open solution
If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
' MsgBox("Nothing to collapse. You must have an open solution.")
Return
End If
' Get the top node (the name of the solution)
Dim UIHSolutionRootNode As UIHierarchyItem
UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)
UIHSolutionRootNode.DTE.SuppressUI = True
' Collapse each project node
Dim UIHItem As UIHierarchyItem
For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
'UIHItem.UIHierarchyItems.Expanded = False
If UIHItem.UIHierarchyItems.Expanded Then
Collapse(UIHItem)
End If
Next
' 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.
UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
UIHSolutionRootNode.DTE.SuppressUI = False
End Sub
Private Sub Collapse(ByVal item As UIHierarchyItem)
For Each eitem As UIHierarchyItem In item.UIHierarchyItems
If eitem.UIHierarchyItems.Expanded AndAlso eitem.UIHierarchyItems.Count > 0 Then
Collapse(eitem)
End If
Next
item.UIHierarchyItems.Expanded = False
End Sub
End Module
Imports EnvDTE
Imports System.Diagnostics
Public Module Collapse
Sub CollapseAll()
' Get the the Solution Explorer tree
Dim UIHSolutionExplorer As UIHierarchy
UIHSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
' Check if there is any open solution
If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
' MsgBox("Nothing to collapse. You must have an open solution.")
Return
End If
' Get the top node (the name of the solution)
Dim UIHSolutionRootNode As UIHierarchyItem
UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)
UIHSolutionRootNode.DTE.SuppressUI = True
' Collapse each project node
Dim UIHItem As UIHierarchyItem
For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
'UIHItem.UIHierarchyItems.Expanded = False
If UIHItem.UIHierarchyItems.Expanded Then
Collapse(UIHItem)
End If
Next
' 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.
UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
UIHSolutionRootNode.DTE.SuppressUI = False
End Sub
Private Sub Collapse(ByVal item As UIHierarchyItem)
For Each eitem As UIHierarchyItem In item.UIHierarchyItems
If eitem.UIHierarchyItems.Expanded AndAlso eitem.UIHierarchyItems.Count > 0 Then
Collapse(eitem)
End If
Next
item.UIHierarchyItems.Expanded = False
End Sub
End Module
UNCOLLAPSE:
Imports System
Imports EnvDTE
Imports System.Diagnostics
Public Module UnCollapse
Sub UnCollapseAll()
' Get the the Solution Explorer tree
Dim UIHSolutionExplorer As UIHierarchy
UIHSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
' Check if there is any open solution
If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
' MsgBox("Nothing to collapse. You must have an open solution.")
Return
End If
' Get the top node (the name of the solution)
Dim UIHSolutionRootNode As UIHierarchyItem
UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)
UIHSolutionRootNode.DTE.SuppressUI = True
' Collapse each project node
Dim UIHItem As UIHierarchyItem
For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
UIHItem.UIHierarchyItems.Expanded = True
'If UIHItem.UIHierarchyItems.Expanded Then
' UnCollapse(UIHItem)
'End If
Next
' 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.
UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
UIHSolutionRootNode.DTE.SuppressUI = False
End Sub
Private Sub UnCollapse(ByVal item As UIHierarchyItem)
For Each eitem As UIHierarchyItem In item.UIHierarchyItems
If eitem.UIHierarchyItems.Expanded AndAlso eitem.UIHierarchyItems.Count > 0 Then
UnCollapse(eitem)
End If
Next
item.UIHierarchyItems.Expanded = True
End Sub
End Module
Imports EnvDTE
Imports System.Diagnostics
Public Module UnCollapse
Sub UnCollapseAll()
' Get the the Solution Explorer tree
Dim UIHSolutionExplorer As UIHierarchy
UIHSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
' Check if there is any open solution
If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
' MsgBox("Nothing to collapse. You must have an open solution.")
Return
End If
' Get the top node (the name of the solution)
Dim UIHSolutionRootNode As UIHierarchyItem
UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)
UIHSolutionRootNode.DTE.SuppressUI = True
' Collapse each project node
Dim UIHItem As UIHierarchyItem
For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
UIHItem.UIHierarchyItems.Expanded = True
'If UIHItem.UIHierarchyItems.Expanded Then
' UnCollapse(UIHItem)
'End If
Next
' 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.
UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
UIHSolutionRootNode.DTE.SuppressUI = False
End Sub
Private Sub UnCollapse(ByVal item As UIHierarchyItem)
For Each eitem As UIHierarchyItem In item.UIHierarchyItems
If eitem.UIHierarchyItems.Expanded AndAlso eitem.UIHierarchyItems.Count > 0 Then
UnCollapse(eitem)
End If
Next
item.UIHierarchyItems.Expanded = True
End Sub
End Module
Burada iki tane macro örneği var şimdi diyeceksiniz ben bunları ne yapıcam da senin dediklerini yapacağım aynen şöyle olacak;
Collapse kod örneğini kopyalayıp Visul Studio-Tools-Macros-Macro IDE yi tıklayıp açılan ayrı bir ekranda MyMacros un üzerine sağ tıklayıp Add module Deyip Module in adını Collapse koyup yeni bir module ekleyip kopyaladığınız collapse kod örneğini yapıştırıp kayıt ediyoruz aynı şekilde UnCollapse e aynı işlemleri yapıyoruz ekranları kapadıktan sonra;
Tools-Customize ı tıklayıp Toolbars sekmesine gelip New butonuna tıklayıp Mesela MyMacros diye yeni bir toolbar yaratıyoruz.Daha sonra yanındaki check işaretini işaretliyoruz close diyoruz visual studio ide sinde mymacros diye yarattığımız toolbar görünüyor daha sonra tekrar aynı yere yani tools-customize e gelip commands sekmesinden macrosdan eklemiş olduğumuz MyMacros.Collapse.CollapseAll ve MyMacros.UnCollapse.UnCollapseAll u eklemiş olduğumuz toolbara doğru sürüklüyoruz daha sonrada bol projeli olan bir solution dosyası açıp denememizi yapıyoruz.
hadi hayırlı olsun =)
Hiç yorum yok:
Yorum Gönder