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按钮就可以添加类注释了。

  • 相关阅读:
    angular 路由请求js文件
    WeX5的简单介绍及UI的简单讲解
    JAVA 反射
    JAVA 线程
    JAVA 远程通讯机制
    用Java实现几种常见的排序算法
    自动完成
    Springmvc和poi3.9导出excel并弹出下载框
    Windows Server 搭建企业无线认证(NPS搭建)
    Windows Server 搭建企业无线认证(Radius认证方案)
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1990670.html
Copyright © 2011-2022 走看看