阅读文章

Ankh菜单删除

[日期:2008-04-11] 来源:  作者: [字体: ]

    
  今天下载了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。
  
  
    


阅读:
录入:blue1000

评论 】 【 推荐 】 【 打印
上一篇:LINQ To DataSet
下一篇:基於IIS的WCF的分布式多層架構開發實現
相关文章      
本文评论
发表评论


点评: 字数
姓名:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款