Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Public Module myproject
Sub FileGuard()
'DESCRIPTION: File Guard
Dim GuardName As String
Dim DocSel As EnvDTE.TextSelection
DocSel = DTE.ActiveDocument.Selection
GuardName = DTE.ActiveDocument.Name
GuardName = GuardName.Replace(".", "_")
GuardName = "__" + GuardName + "__"
GuardName = GuardName.ToUpper()
DocSel.StartOfDocument()
DocSel.Text = "#ifndef " + GuardName
DocSel.NewLine()
DocSel.Text = "#define " + GuardName
DocSel.NewLine()
DocSel.NewLine()
DocSel.EndOfDocument()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endif // " + GuardName
End Sub
Sub DescFile()
'DESCRIPTION: File description
Dim DocName As String
Dim Timestamp As String
Dim DocSel As EnvDTE.TextSelection
DocSel = DTE.ActiveDocument.Selection
DocName = DTE.ActiveDocument.Name
Timestamp = System.DateTime.Now.ToString()
Timestamp = Timestamp.Replace("-", "/")
DocSel.StartOfDocument()
DocSel.Text = "//============================================================================="
DocSel.NewLine()
DocSel.Text = "/**"
DocSel.NewLine()
DocSel.Text = " * @file " + DocName
DocSel.NewLine()
DocSel.Text = "*"
DocSel.NewLine()
DocSel.Text = "* " + DocName + " v 1.0 " + TimeString + " zhoubo created"
DocSel.NewLine()
DocSel.Text = "*"
DocSel.NewLine()
DocSel.Text = "* @author zhoubo <lovebzhou@gmail.com>"
DocSel.NewLine()
DocSel.Text = "*/"
DocSel.NewLine()
DocSel.StartOfLine()
DocSel.Text = "//============================================================================="
DocSel.NewLine()
DocSel.NewLine()
End Sub
Sub DescFileSimple()
'DESCRIPTION: Simple File Description
Dim DocName As String
Dim Timestamp As String
Dim DocSel As EnvDTE.TextSelection
DocSel = DTE.ActiveDocument.Selection
DocName = DTE.ActiveDocument.Name
Timestamp = System.DateTime.Now.ToString()
Timestamp = Timestamp.Replace("-", "/")
DocSel.StartOfDocument()
DocSel.Text = "// " + DocName + " " + Timestamp
DocSel.NewLine()
DocSel.Text = "// zhoubo <lovebzhou@gmail.com>"
DocSel.NewLine()
DocSel.NewLine()
End Sub
Sub DescFileAndGuard()
FileGuard()
DescFileSimple()
End Sub
Sub DescClass()
Dim DocSel As EnvDTE.TextSelection
Dim ClassName As String
DocSel = DTE.ActiveDocument.Selection
ClassName = Trim(DocSel.Text)
ClassName = ClassName.Substring(6)
DocSel.LineUp()
DocSel.NewLine()
DocSel.Text = "/**"
DocSel.NewLine()
DocSel.Text = " * @class " + ClassName
DocSel.Text = "*"
DocSel.NewLine()
DocSel.Text = "* @brief "
DocSel.NewLine()
DocSel.Text = "*/"
End Sub
Sub DescFunction()
Dim DocSel As EnvDTE.TextSelection
DocSel = DTE.ActiveDocument.Selection
DocSel.LineUp()
DocSel.NewLine()
DocSel.Text = "/**"
DocSel.NewLine()
DocSel.Text = " * @param "
DocSel.NewLine()
DocSel.Text = "*"
DocSel.NewLine()
DocSel.Text = "* @return "
DocSel.NewLine()
DocSel.Text = "*/"
End Sub
End Module
VC6
'------------------------------------------------------------------------------
'FILE DESCRIPTION: New Macro File
'------------------------------------------------------------------------------
Sub FileDescription()
'DESCRIPTION: File description
TimeString = CStr(Now)
TimeString = Replace(TimeString, "-", "/")
Descr = "//=============================================================================" + vbLF + _
"/**" + vbLF + _
"* @file " + ActiveDocument.Name + vbLF + _
"*" + vbLF + _
"* " + ActiveDocument.Name + ", v 1.0 " + TimeString + " zhoubo created" + vbLF + _
"*" + vbLF + _
"* @author zhoubo <lovebzhou@gmail.com>" + vbLF + _
"*/" + vbLF + _
"//=============================================================================" + vbLF + vbLF
ActiveDocument.Selection = Descr
End Sub
Sub SimpleFileDescription()
'DESCRIPTION: Simple File Description
TimeString = CStr(Now)
TimeString = Replace(TimeString, "-", "/")
Descr = "// " + ActiveDocument.Name + ", " + TimeString + vbLF + _
"// zhoubo <lovebzhou@gmail.com>" + vbLF + vbLF
ActiveDocument.Selection = Descr
End Sub
Sub ClassDescription
Descr = "/**" + vbLF + _
" * @class " + vbLF + _
" *" + vbLF + _
" * @brief " + vbLF + _
" */"
ActiveDocument.Selection = Descr
End Sub
Sub FunctionDescription
Descr = "/**" + vbLF + _
" * @param " + vbLF + _
" * @return " + vbLF + _
" */"
ActiveDocument.Selection = Descr
End Sub
Sub FileGuard()
'DESCRIPTION: File Guard
gMacro = UCase("__" + Replace(ActiveDocument.Name, ".", "_") + "__")
Descr = "#ifndef " + gMacro + vbLF + _
"#define " + gMacro + vbLF + vbLF + vbLF + _
"#endif // " + gMacro
ActiveDocument.Selection = Descr
End Sub