[导入]a very useful macro for VS.Net


I stumbled it upon
http://radio.weblogs.com/0104813/stories/2002/06/19/vsnetGoogleMacro.htm
l.

Duplicated from its original site:

Imports EnvDTE

Imports System

Imports System.Windows.Forms

Public Sub SearchGoogleForSelectedText()

Dim ActiveDocument As Object = DTE.ActiveDocument

If Not ActiveDocument Is Nothing Then

Dim Selection As TextSelection = CType(ActiveDocument.Selection,
TextSelection)

Dim SelectedText As String = Selection.Text

If SelectedText.Length > 0 Then

Dim GoogleUriBuilder As UriBuilder = New UriBuilder()

GoogleUriBuilder.Scheme = Uri.UriSchemeHttp

GoogleUriBuilder.Host = "www.google.com"

GoogleUriBuilder.Path = "/search"

GoogleUriBuilder.Query = "q=" & SelectedText

DTE.ItemOperations.Navigate(GoogleUriBuilder.Uri.ToString())

Else

MessageBox.Show("No text selected.", "Google Search",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)

End If

Else

MessageBox.Show("No active document.", "Google Search",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)

End If

End Sub


文章来源:http://zouyu.blogspot.com/2006/02/very-useful-macro-for-vsnet.html

posted on 2006-02-13 14:55  Web Rules  阅读(132)  评论(0)    收藏  举报

导航