zoukankan      html  css  js  c++  java
  • 使用 vs 2008 宏制作自动注释工具

    1.         Tool中选择Macros,打开Macro IDE

    2.       MyMacros 删除默认文件 Module1.vb,添加文件CommentHelper.Vb代码内容

    Imports System

    Imports EnvDTE

    Imports EnvDTE80

    Imports EnvDTE90

    Imports System.Diagnostics

     

    '注释帮助模块

    Public Module CommentHelper

     

        Sub AddClassComment()

     

            '定义选择区域

            Dim DocSel As EnvDTE.TextSelection

     

            '初始化选择区域是当前文档的选择

            DocSel = DTE.ActiveDocument.Selection

     

            '选择区域移动到文档的开头

            DocSel.StartOfDocument()

            DocSel.Text = "/*******************************************************************"

            DocSel.NewLine()

            DocSel.Text = "* Copyright (C) abc Corporation"

            DocSel.NewLine()

            DocSel.Text = "* All rights reserved."

            DocSel.NewLine()

            DocSel.Text = "*"

            DocSel.NewLine()

            DocSel.Text = "Author:   HBB0b0 (hbb0b0@163.com)"

            DocSel.NewLine()

            DocSel.Text = "Create Date:" + DateTime.Now.ToString()

            DocSel.NewLine()

            DocSel.Text = "Description:" + DTE.ActiveDocument.Name

            DocSel.NewLine()

            DocSel.Text = "*"

            DocSel.NewLine()

            DocSel.Text = "* Date         Author               Description"

            DocSel.NewLine()

            DocSel.Text = "*******************************************************************/"

            DocSel.NewLine()

        End Sub

    End Module

     

    3.      在需要添加注释的项目中打开Macro 浏览器,如果看不到AddClassComment宏,则需要导入宏项目

    4.         打开需要注释文件,双击或运行AddClassComment,就会添加如下效果的注释。

    /*******************************************************************

     * * Copyright (C) abc Corporation

     * * All rights reserved.

     * *

     * Author:   HBB0b0 (hbb0b0@163.com)

     * Create Date:2011-3-21 19:51:03

     * Description:Program.cs

     * *

     * * Date         Author               Description

     * *******************************************************************/

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

     

    namespace MacroApplication

    {

        class Program

        {

            static void Main(string[] args)

            {

            }

        }

    }

    如果觉得这种方式不方便,可以把它做成ToolBar,下个项目使用的只需要运行ToolBar中的对应按钮就可以了。

    1.         Tools中选择自定义

    2.         新添ToolBar 名称为CommentHelper

    3.         在命令页签Macros选择AddClassComment

    4.         按住Macro.MyMacros.CommentHelper.AddClassComment,把它拖到CommentHelper容器上

    5.         拖放后的效果如下

    6.         在以后的使用时不用再次打开宏项目,直接单击CommentHelperAddClassComment按钮就可以添加类注释了。

  • 相关阅读:
    【Linux编程基础】构建Linux 库文件
    【Linux调试技术】查看数据
    【C++学习】复制构造函数和赋值运算符根本的不同
    【C++学习】显式构造函数
    【C++学习】函数对象和Lambda表达式
    【C++学习】类初始化列表的分析总结
    【Linux开发基础】Linux守护服务进程(Daemon service)编程
    【编程小结】C++和Java 的缺省初始化问题
    SQL查询金额去掉小数点后面的零
    SQL自定义函数split 将数组(分隔字符串)返回阵列(表)
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1990670.html
Copyright © 2011-2022 走看看