++++ 코드 보기 |
Public Sub toggleHeaderSource() Dim currentDocumentPath As String = DTE.ActiveDocument.FullName currentDocumentPath = currentDocumentPath.ToLower() Dim currentDocumentPathWithoutExtension As String = currentDocumentPath.Remove(currentDocumentPath.LastIndexOf(".")) Dim correspondingDocumentPath As String Dim correspondingDocumentPath2 As String If (currentDocumentPath.EndsWith(".c") Or currentDocumentPath.EndsWith(".cpp")) Then correspondingDocumentPath = currentDocumentPathWithoutExtension + ".hpp" correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".h" ElseIf (currentDocumentPath.EndsWith(".h") Or currentDocumentPath.EndsWith(".hpp")) Then correspondingDocumentPath = currentDocumentPathWithoutExtension + ".cpp" correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".c" End If If (System.IO.File.Exists(correspondingDocumentPath) = True) Then DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath) ElseIf (System.IO.File.Exists(correspondingDocumentPath2) = True) Then DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath2) End If End Sub
++++
VS2010에는 플러그인 개발이 오픈소스화 되어 좋은 것들을 쉽게 구할 수 있게 되었다.
뭔가 불편하면, 플러그인을 찾으면 된다.
이 스크립트는 낡았다. 그냥 추억으로 나둠.
++++ Old Script |
Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports EnvDTE90a Imports EnvDTE100 Imports System.Diagnostics Public Module MyMacroModule Public Sub toggleHeaderSource() Dim currentDocumentPath As String = DTE.ActiveDocument.FullName currentDocumentPath = currentDocumentPath.ToLower() Dim currentDocumentPathWithoutExtension As String = currentDocumentPath.Remove(currentDocumentPath.LastIndexOf(".")) Dim correspondingDocumentPath As String Dim correspondingDocumentPath2 As String If (currentDocumentPath.EndsWith(".c") Or currentDocumentPath.EndsWith(".cpp")) Then correspondingDocumentPath = currentDocumentPathWithoutExtension + ".hpp" correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".h" ElseIf (currentDocumentPath.EndsWith(".h") Or currentDocumentPath.EndsWith(".hpp")) Then correspondingDocumentPath = currentDocumentPathWithoutExtension + ".cpp" correspondingDocumentPath2 = currentDocumentPathWithoutExtension + ".c" End If If (System.IO.File.Exists(correspondingDocumentPath) = True) Then DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath) ElseIf (System.IO.File.Exists(correspondingDocumentPath2) = True) Then DTE.ExecuteCommand("File.OpenFile", correspondingDocumentPath2) End If End Sub Sub InsertTMacro() Dim selection As EnvDTE.TextSelection Dim startPoint As EnvDTE.EditPoint Dim endPoint As TextPoint Dim commentStart As String selection = DTE.ActiveDocument.Selection() startPoint = selection.TopPoint.CreateEditPoint() endPoint = selection.BottomPoint.CreateEditPoint() DTE.UndoContext.Open("InsertTMacro") Try startPoint.Insert("_T(") endPoint.Insert(")") Finally DTE.UndoContext.Close() End Try End Sub End Module
++++