vs2008快捷键生成

本文介绍了一种使用Visual Studio的宏功能将所有可用的键盘快捷键导出为HTML文件的方法。通过遍历DTE对象模型中的命令集合并获取每个命令的绑定信息,此宏能够自动生成一个包含命令名称及其对应快捷键的表格。

 1:  Imports System
 2:  Imports EnvDTE
 3:  Imports EnvDTE80
 4:  Imports EnvDTE90
 5:  Imports System.Diagnostics
 6:  Imports System.IO
 7:   
 8:   
 9:  Public Module Module1
10:      Public Sub ListShortcutsInHTML()
11:          'Declare a StreamWriter
12:          Dim sw As System.IO.StreamWriter
13:          sw = New StreamWriter("d:\\Shortcuts.html")
14:   
15:          'Write the beginning HTML
16:          WriteHTMLStart(sw)
17:   
18:          ' Add a row for each keyboard shortcut
19:          For Each c As Command In DTE.Commands
20:              If c.Name <> "" Then
21:                  Dim bindings As System.Array
22:                  bindings = CType(c.Bindings, System.Array)
23:                  For i As Integer = 0 To bindings.Length - 1
24:                      sw.WriteLine("<tr>")
25:                      sw.WriteLine("<td>" + c.Name + "</td>")
26:                      sw.WriteLine("<td>" + bindings(i) + "</td>")
27:                      sw.WriteLine("</tr>")
28:                  Next
29:  
30:              End If
31:          Next
32:  
33:          'Write the end HTML
34:          WriteHTMLEnd(sw)
35:   
36:          'Flush and close the stream
37:          sw.Flush()
38:          sw.Close()
39:   
40:      End Sub
41:  
42:      'Declare a StreamWriter
43:  
44:      Public Sub WriteHTMLStart(ByVal sw As System.IO.StreamWriter)
45:          sw.WriteLine("<html>")
46:          sw.WriteLine("<head>")
47:          sw.WriteLine("<title>")
48:   
49:          sw.WriteLine("Visual Studio Keyboard Shortcuts")
50:          sw.WriteLine("</title>")
51:          sw.WriteLine("</head>")
52:   
53:          sw.WriteLine("<body>")
54:          sw.WriteLine("<h1>Visual Studio 2005 Keyboard Shortcuts</h1>")
55:          sw.WriteLine("<font size=""2"" face=""Verdana"">")
56:          sw.WriteLine("<table border=""1"">")
57:          sw.WriteLine("<tr BGCOLOR=""#018FFF""><td align=""center""><b>Command</b></td><tdalign=""center""><b>Shortcut</b></td></tr>")
58:   
59:   
60:      End Sub
61:  
62:      Public Sub WriteHTMLEnd(ByVal sw As System.IO.StreamWriter)
63:          sw.WriteLine("</table>")
64:          sw.WriteLine("</font>")
65:          sw.WriteLine("</body>")
66:          sw.WriteLine("</html>")
67:      End Sub
68:  
69:  End Module
70:  
71:  
Bookmark and Share

转载于:https://www.cnblogs.com/LifelongLearning/archive/2010/02/10/1667325.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值