Created
June 19, 2014 04:48
-
-
Save kawanaka2141/208029b42390fd26dbb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System | |
Imports EnvDTE | |
Imports EnvDTE80 | |
Imports EnvDTE90 | |
Imports EnvDTE90a | |
Imports EnvDTE100 | |
Imports System.Diagnostics | |
Public Module CopyJumpTagFromCurrentLocation | |
Public Sub CopyJumpTagFromCurrentLocation() | |
If DTE.ActiveDocument Is Nothing Then | |
Exit Sub | |
End If | |
Dim activePoint As TextPoint = CType(DTE.ActiveDocument.Selection, TextSelection).ActivePoint | |
Dim codeElem As CodeElement = _ | |
DTE.ActiveDocument.ProjectItem.FileCodeModel.CodeElementFromPoint(activePoint, vsCMElement.vsCMElementClass) | |
If codeElem Is Nothing Then | |
codeElem = DTE.ActiveDocument.ProjectItem.FileCodeModel.CodeElementFromPoint(activePoint, vsCMElement.vsCMElementInterface) | |
End If | |
Dim textDoc As TextDocument = DTE.ActiveDocument.Object("") | |
Dim editPoint As EditPoint = textDoc.CreateEditPoint() | |
Dim activeP As VirtualPoint = DTE.ActiveDocument.Selection.ActivePoint | |
Dim line As String = editPoint.GetLines(activeP.Line, DTE.ActiveDocument.Selection.ActivePoint.Line + 1) | |
Dim s As String | |
s = s & DTE.ActiveDocument.Path & DTE.ActiveDocument.Name | |
s = String.Format("{0}{1}({2}):{3}" & vbCrLf, _ | |
DTE.ActiveDocument.Path, _ | |
DTE.ActiveDocument.Name, _ | |
activePoint.Line.ToString(), _ | |
line) | |
Dim ClipBoardThread As System.Threading.Thread = New System.Threading.Thread(AddressOf SetClipboard) | |
With ClipBoardThread | |
.ApartmentState = System.Threading.ApartmentState.STA | |
.IsBackground = True | |
' .Start(codeElem.FullName) | |
.Start(s) | |
.Join() | |
End With | |
ClipBoardThread = Nothing | |
End Sub | |
Private Sub SetClipboard(ByVal x As Object) | |
System.Windows.Forms.Clipboard.SetText(CStr(x), System.Windows.Forms.TextDataFormat.Text) | |
End Sub | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment