海鸥航迹

学习之笔记,好文之收集。

导航

Ankh菜单删除

今天下载了AnkhSVN 试用来一番。它是一个Visual Studio IDE的一个插件,感觉仍然不如VSS或者Visual SVN方便,Unintall后,居然发现VS2005菜单上,仍然有AnkhSVN的菜单项目。要删除它,Google这样一个文章:

http://www.therightstuff.de/2006/09/21/Removing+AnkhSVN+Commands+From+Visual+Studio.aspx

   1:  Imports System
   2:  Imports EnvDTE
   3:  Imports System.Diagnostics
   4:  ' Comment the following line if you're running the macro in Visual Studio .NET 2003.
   5:  Imports Microsoft.VisualStudio.CommandBars
   6:  Imports Microsoft.Office.Core
   7:   
   8:  Public Module RemoveAnkhMenus
   9:      Public Sub RemoveAnkhMenus()
  10:          DeleteAnkhCommandControls()
  11:          DeleteAnkhCommands()
  12:      End Sub
  13:   
  14:      Private Sub DeleteAnkhCommandControls()
  15:          For Each bar As CommandBar In CType(DTE.CommandBars, CommandBars)
  16:              ' Debug.WriteLine(String.Format("Processing : {0}", GetPath(bar)))
  17:   
  18:              RecurseCommandControls(bar.Controls)
  19:          Next
  20:      End Sub
  21:   
  22:      Private Sub RecurseCommandControls(ByVal controls As CommandBarControls)
  23:          For Each control As CommandBarControl In controls
  24:              ' Debug.WriteLine(String.Format("Processing : {0}", GetPath(control)))
  25:   
  26:              ' Recurse childs.
  27:              If control.accChildCount > 0 Then
  28:                  If control.Type = MsoControlType.msoControlPopup Then
  29:                      RecurseCommandControls(CType(control, CommandBarPopup).Controls)
  30:                  End If
  31:              End If
  32:   
  33:              ' Delete the control if it is related to AnkhSVN.
  34:              DeleteAnkhCommandControl(control)
  35:          Next
  36:      End Sub
  37:   
  38:      Private Sub DeleteAnkhCommandControl(ByVal control As CommandBarControl)
  39:          ' Delete control if it is related to AnkhSVN.
  40:          If control.Caption.StartsWith("Ankh") Then
  41:              Debug.WriteLine(String.Format("Deleting control: {0}", GetPath(control)))
  42:              control.Delete()
  43:          End If
  44:      End Sub
  45:   
  46:      Private Sub DeleteAnkhCommands()
  47:          ' Delete all commands related to AnkhSVN.
  48:          For Each command As Command In DTE.Commands
  49:              If command.Name <> Nothing Then
  50:                  If command.Name.StartsWith("Ankh") Then
  51:                      Debug.WriteLine(String.Format("Deleting command: {0}", command.Name))
  52:                      command.Delete()
  53:                  End If
  54:              End If
  55:          Next
  56:      End Sub
  57:   
  58:      Private Function GetPath(ByVal control As Object) As String
  59:          If TypeOf (control) Is CommandBarControl Then
  60:              Dim cbc As CommandBarControl
  61:              cbc = CType(control, CommandBarControl)
  62:   
  63:              Return GetPath(cbc.Parent) + "->" + cbc.Caption
  64:          End If
  65:   
  66:          If TypeOf (control) Is CommandBar Then
  67:              Dim cb As CommandBar
  68:              cb = CType(control, CommandBar)
  69:   
  70:              Return GetPath(cb.Parent) + "->" + cb.Name
  71:          End If
  72:   
  73:          Return "DTE"
  74:      End Function
  75:  End Module

这个宏文件必须在VS 的宏IDE中打开,直接保存为VBS项目运行必会报错的(谁试运行了不报错的可要留言)。

你可以把它添加到任意一个宏项目或新建一个宏项目,然后运行之即可。需要注意的是,这个宏会运行很久,在我的T42上估计用了大约10多分钟。

还一个解决办法就是导出VS IDE的设置,然后重置IDE。但这会丢失所有的自定义设置。如果自定义不多,完全可以使用这个方法。 只好再次回到Visual SVN了,唉...

源码控制,仍然推荐使用SVN。

posted on 2008-04-09 22:01  海天一鸥  阅读(2402)  评论(7编辑  收藏  举报