[译]Visual Studio .NET 2003中时尚的插图文档
By robot-v1.0
本文链接 https://www.kyfws.com/applications/stylish-illustrated-documents-in-visual-studio-net-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 32 分钟阅读 - 15857 个词 阅读量 0[译]Visual Studio .NET 2003中时尚的插图文档
原文地址:https://www.codeproject.com/Articles/9289/Stylish-illustrated-documents-in-Visual-Studio-NET
原文作者:kenearle
译文由本站 robot-v1.0 翻译
前言
Tools to use HTML instead of plain text for supporting documents in Visual Studio.
在Visual Studio中使用HTML而非纯文本支持文档的工具.
- 下载InvisiPerl项目-17.2 Kb(Download InvisiPerl project - 17.2 Kb)
- 下载时尚文档所需的一切-38.1 Kb(Download everything you need for stylish documents - 38.1 Kb)
内容(Contents)
抽象(Abstract)
在Visual Studio .NET 2003中使用HTML设计视图获取本应以纯文本结尾的文档.使用一些提供的外部工具可以使您非常轻松.(Use the HTML Design View within Visual Studio .NET 2003 for documentation that would otherwise end up as plain text. Made fairly painless with a few provided external tools.)
要求(Requirements)
- Visual Studio .NET 2003(其他未经测试的.NET版本).(Visual Studio .NET 2003 (other .NET versions untested).)
- 操作系统:Windows 98,Windows NT 4.0 Service Pack 3或更高版本.(OS: Windows 98, Windows NT 4.0 Service Pack 3, or better.)
- Perl(下面的安装说明,无需了解Perl).(Perl (installation instructions below, no need to know Perl).)
介绍(Introduction)
这是在支持的文档中使用Visual Studio .NET 2003中的HTML设计视图的方法,包括开发日志,帮助文件的草稿,快速的专业外观报告,插图代码示例,基本上可以使用图片或样式的任何内容当您不想离开Visual Studio时.(Here’s a way to use the HTML Design View in Visual Studio .NET 2003 for your supporting documentation, including development logs, drafts of Help files, quick professional-looking reports, illustrated code samples, basically anything that could use pictures or a touch of style when you don’t want to bother leaving Visual Studio.)
如果您喜欢屏幕截图,请按照以下步骤操作:(If you liked the screenshot, here’s the path ahead:)
-
安装Perl和一些辅助Perl软件包.(Install Perl and a few helper Perl packages.)
-
下载本文顶部的" stylishdocs" ZIP文件,其中包含文档模板(日志,报告,帮助草案)和一些Perl程序.(Download the “stylishdocs” ZIP file at the top of this article, which contains document templates (log, report, help draft) and some Perl programs.)
-
在Visual Studio中设置一些外部命令和快捷键.(Set up some external commands and shortcut keys in Visual Studio.)
-
使用文档模板之一作为起点,并使用Visual Studio中的"设计视图"编辑文档.(Use one of the document templates as a starting point, and edit your document using the Design View in Visual Studio.) 这是您将获得的:(And here’s what you’ll get:)
-
换行和段落缩进将使您可以自动重新格式化段落格式,而不必使用空白段落作为分隔符(包括日志文件).(Line wrapping and paragraph indenting will give you automatically reformatted paragraphs without having to use blank paragraphs as separators (log files included).)
-
VS内置命令可让您使用样式标题,创建编号列表(具有自动重新编号)和项目符号列表,使用粗体,斜体和颜色,创建表格等.(VS built-in commands will let you use styled headings, create numbered lists (with automatic renumbering) and bulleted lists, use bold, italic and colors, create tables etc.)
-
新的外部工具可以简单地插入图像,跟踪链接,粘贴代码示例以及一个"不错的东西":从纯文本文档中获取一张表格并将其作为真实表格粘贴到您的文档中,例如,上面的图片.(New external tools to insert images simply, follow links, paste in code samples, and one “nice to have”: take a table from a plain text document and paste it into your document as a true table, for example, the table in the picture above.) 接下来是安装详细信息,然后是一个小用户指南.(Installation details are next, then a small user’s guide to finish up.)
安装(Installation)
安装Perl(Installing Perl)
如果您已经安装了ActiveState的ActivePerl,请跳到下面的(三个额外的程序包)部分.(If you already have ActiveState’s ActivePerl installed, skip ahead a bit to the (three extra packages) part below.)
否则,请启动您的Web浏览器并转到:(Otherwise, fire up your web browser and head to:)
这是安装ActiveState版本的Perl的要求页面.如果运行的是WinNT/2000,则可能要在安装Perl之前先安装MSI,但这不是必需的.要下载并安装MSI,请在" Windows Installer要求"部分下的要求页上单击" for WinNT/2000"链接.如果您使用的是XP,则已经满足要求. Perl大约需要70 Meg的安装空间,这几天每千兆字节的磁盘空间将花费您7美分.(This is the requirements page for installing ActiveState’s version of Perl. If you’re running WinNT/2000, you might want to install MSI before installing Perl, but it’s not required. To download and install MSI, click on the “for WinNT/2000” link on the requirements page under the “Windows Installer requirements” section. If you’re using XP, you already meet the requirements. Perl needs about 70 Meg for installation, which at a dollar a Gigabyte for disk space these days will set you back seven cents.)
单击需求页面右上方的"下载"链接,开始下载Perl.在可选地填写了一些注册信息之后,单击下载页面上的" MSI"链接(如果未安装MSI,则单击" AS软件包"链接),位于" Windows"中" ActivePerl 5.8"标题的左上方" 部分.您的Perl下载将需要一分钟.(Click on the “DOWNLOAD” link at top-right of the requirements page to start off your Perl download. After optionally filling in some registration info, click on the “MSI” link on the download page (or the “AS package” link if you didn’t install MSI), at top left under the “ActivePerl 5.8” heading in the “Windows” section. Your Perl download will take a minute….)
双击您下载的Perl安装程序以运行它.您尤其应该接受Perl的默认位置,(Double-click the Perl installer you downloaded, to run it. You should especially accept the default location for Perl,)C:\ Perl(C:\Perl),否则,访问和更新Perl可能会很繁琐.您还应该允许将Perl添加到您的环境Path变量中.其他选项不是那么重要.(, otherwise, accessing and updating Perl can be rather tedious. You should also allow Perl to be added to your environment Path variable. The other options aren’t so important.)
要验证Perl是否已正确安装:打开命令提示符窗口,然后键入" perl -v":您将看到简短的版本消息.(To verify that Perl was installed correctly: open a command prompt window, and type “perl -v”: you will see a brief version message.)
(三个额外的软件包):在命令提示符窗口中再次键入" ppm",这将启动程序员的软件包管理器,该实用程序可让您安装Perl加载项或软件包.然后键入(不带引号)" install Win32-API";完成后,键入" install Win32-GUI";并完成后,键入" install Win32-FileOp".尘埃沉降后,键入" q"以退出PPM.如果PPM说这些项目已经安装,那么您无需执行其他任何操作,您的Perl就可以使用了.((Three extra packages): In your command prompt window again, type “ppm”, which starts up the Programmer’s Package Manager, a utility that lets you install Perl add-ins or packages. Then type (without the quotes) “install Win32-API”; when it finishes, type “install Win32-GUI”; and when that’s done, type “install Win32-FileOp”. Type “q” to quit PPM after the dust settles. If PPM says that these items are already installed, then you don’t need to do anything else, your Perl is ready to go.)
如果您是Perl的新手,可能会喜欢看开始>程序> ActiveState ActivePerl 5.8>文档,但是不需要时尚的文档.(If you’re new to Perl, you might enjoy looking at Start>Programs>ActiveState ActivePerl 5.8>Documentation, but you won’t need to for stylish docs.)
Fashiondocs.zip(Stylishdocs.zip)
下载并展开(Download and expand)**fashiondocs.zip(stylishdocs.zip)从上方的"下载时尚文档所需的所有内容"链接中.所结果的(from the “Download everything you need for stylish documents” link up above. The resulting)\ stylishdocs(\stylishdocs)文件夹包含用于启动新日志,报告和帮助文档的HTML/CSS模板,以及其中的一些Perl程序.(folder contains HTM/CSS templates for starting new log, report and help documents, and a few Perl programs in the)\ vsprogs(\vsprogs)**子文件夹以及一个小型助手应用程序,(subfolder together with a small helper application,)的InvisiPerl(InvisiPerl.exe).(.)
移动整个(Move the entire)**\ vsprogs(\vsprogs)来自的子文件夹(subfolder from)\ stylishdocs(\stylishdocs)**进入你的新(into your new)**C:\ perl(C:\perl)**文件夹,结尾为(folder, ending up with)C:\ Perl \ vsprogs(C:\Perl\vsprogs).(.)
Visual Studio外部命令(Visual Studio external commands)
接下来,我们将设置外部命令来调用Perl程序.之后,它们将在Visual Studio的"工具"菜单下可用,在最后的安装步骤中,我们将为其分配快捷键.(Next, we’ll set up external commands to call the Perl programs. Afterwards, they will be available under Visual Studio’s Tools menu, and in the last installation step, we’ll assign shortcut keys to them.)
有四个外部命令可以设置,每个命令都以相同的方式完成.在Visual Studio中,选择"工具>外部工具…",然后在出现的"外部工具"对话框中添加以下四个命令:(There are four external commands to set up, each done the same way. In Visual Studio, select “Tools>External Tools…”, then add the four commands as follows in the resulting “External Tools” dialog:)
单击每个按钮.(Click the Add button for each.)
然后,对于每个工具,复制并粘贴以下内容(将"初始目录"字段保留为空白,并删除对话框底部三个复选框"使用输出窗口"中的所有复选框):(Then for each tool, copy and paste in the following (leave the “Initial directory” field blank, and remove any checks in the three checkboxes “Use Output window” etc. at the bottom of the dialog):)
工具1:(Tool 1:)
-
标题:粘贴代码(Title: Paste Code)
-
命令:C:\ Perl \ vsprogs \ InvisiPerl.exe(Command: C:\Perl\vsprogs\InvisiPerl.exe)
-
参数:C:\ Perl \ vsprogs \ cpp2htm.pl 4 H> C:\ Perl \ vsperlerror.txt 2>&1(Arguments: C:\Perl\vsprogs\cpp2htm.pl 4 H > C:\Perl\vsperlerror.txt 2>&1) 工具2:“粘贴图像"的参数有一个潜在的变化.您制作的所有样式文档都会有一个关联的”(Tool 2: There’s one potential change to make to the arguments for Paste Image. Any styled document you make will have an associated “)**图片(images)**在同一级别的目录,其中存储了所有图像,并且您的(” directory at the same level, where all of its images are stored, and your)
img src
属性都将包含到该位置的相对路径.但是您也可以使用"(attributes will all contain relative paths to that location. But you can also have a “)常见图片(common images)“可以用作任何样式文档中图像的源的目录,也许是放置所有屏幕截图的目录:您可以使用任何您喜欢的目录,只需更改”(” directory that can serve as a source for images in any styled document, perhaps a directory where you put all screenshots: you can use any directory you like, just change the “)C:\ CommonImages(C:\CommonImages)“下的"“添加到首选目录.下面的"使用样式化文档"下的"粘贴图像"部分详细说明了如何使用此公共目录.如果您不想使用公共图像目录,或者喜欢按原样命名,您可以保留如下所示的参数:(” argument below to your preferred directory. The “Pasting in an image” section under “Working with styled documents” below explains how this common directory is used, in more detail. If you don’t want a common images directory, or like the name as-is, you can leave the arguments as shown below:) -
标题:粘贴图片(Title: Paste Image)
-
命令:C:\ Perl \ vsprogs \ InvisiPerl.exe(Command: C:\Perl\vsprogs\InvisiPerl.exe)
-
参数:C:\ Perl \ vsprogs \ imglink.pl H $ {ItemPath)图像” C:\ CommonImages”> C:\ Perl \ vsperlerror.txt 2>&1(Arguments: C:\Perl\vsprogs\imglink.pl H $(ItemPath) images “C:\CommonImages” > C:\Perl\vsperlerror.txt 2>&1) 工具3:(Tool 3:)
-
标题:文本粘贴表(Title: Paste Table from text)
-
命令:C:\ Perl \ vsprogs \ InvisiPerl.exe(Command: C:\Perl\vsprogs\InvisiPerl.exe)
-
参数:C:\ Perl \ vsprogs \ tableize.pl H是> C:\ Perl \ vsperlerror.txt 2>&1(Arguments: C:\Perl\vsprogs\tableize.pl H yes > C:\Perl\vsperlerror.txt 2>&1) 工具4:(Tool 4:)
-
标题:从完整路径打开文件(Title: Open File from full path)
-
命令:C:\ Perl \ vsprogs \ InvisiPerl.exe(Command: C:\Perl\vsprogs\InvisiPerl.exe)
-
参数:C:\ Perl \ vsprogs \ openlink.pl> C:\ Perl \ vsperlerror.txt 2>&1(Arguments: C:\Perl\vsprogs\openlink.pl > C:\Perl\vsperlerror.txt 2>&1)
Visual Studio快捷键(Visual Studio shortcut keys)
除了刚刚创建的这四个外部命令的快捷键之外,我们还将添加"粘贴为HTML"的快捷方式,该快捷方式由Perl程序使用,也可以直接由您使用.(In addition to shortcut keys for those four external commands just created, we’ll add a shortcut for “Paste as HTML”, which is used by the Perl programs but can also be used by you directly.)
创建快捷方式时,Visual Studio可能会中断并要求您接受复制"键盘映射方案".这是保留旧键盘快捷键的一种方法,新方案将被赋予一个新名称,例如" Visual C ++ 6的副本".(While you’re creating shortcuts, Visual Studio might interrupt and ask you to accept making a copy of your “Keyboard mapping scheme”. This is a way of preserving your old keyboard shortcuts, and your new scheme will be given a new name such as “Copy of Visual C++ 6”.)
首先,“粘贴为HTML"快捷方式:(First, the “Paste as HTML” shortcut:)
- 选择"工具>选项…",然后在"环境"标题下,单击"键盘”.(Select “Tools>Options…”, and then under the “Environment” heading, click on “Keyboard”.)
- 在"显示包含的命令"字段中,键入" HTML".(In the “Show commands containing” field, type “HTML”.)
- 在结果列表中选择" Edit.PasteasHTML"命令.(Select the “Edit.PasteasHTML” command in the resulting list.)
- 在对话框的下方,在"使用新的快捷方式"菜单下,选择" HTML编辑器设计视图".(Down lower in the dialog, under the “Use new shortcut in” menu, select “HTML Editor Design View”.)
- 然后,单击菜单右侧的"按快捷键"字段.(Then click in the “Press shortcut key(s)” field to the right of the menu.)
- 按住Shift和Ctrl键,然后点击" H"键输入快捷方式.(Hold the Shift and Ctrl keys down, and tap the “H” key to enter your shortcut.)
- 单击右侧的"分配"按钮,然后单击"确定".(Click the “Assign” button just to the right, then click OK.) 现在,您可以在HTML设计视图中通过按CTRL-SHIFT-H来使用"粘贴为HTML"命令.这会粘贴您的选择,而不会转义任何特殊的HTML字符,例如" <";换句话说,它允许您粘贴从文本文件复制的HTML作为功能HTML,而不是通过使用" <“代替” <“等将HTML转换为文本.(Now you can use the “Paste as HTML” command while in HTML Design View, by pressing CTRL-SHIFT-H. This pastes in your selection without escaping any special HTML characters such as “<"; in other words, it allows you to paste in HTML copied from a text file as functional HTML rather than having the HTML converted to text by using “<” in place of “<” etc.)
我们上面设置的三个外部工具命令也使用"大写为HTML"的大写字母H:如果您查看工具1\2和3的参数,则会看到大写字母H.您决定不使用大写字母H作为"粘贴为HTML"的快捷键,重新访问"工具>外部工具…“对话框,并将参数列表中的大写字母H更改为所需的键.例如,如果您希望将小写j用作快捷方式,则将三个工具的H更改为j:“粘贴代码"的参数将为” C:\ Perl \ vsprogs \ cpp2htm.pl 4 j”. ,以及"粘贴图片"和"粘贴表格…“的类似更改.(That capital H for “Paste as HTML” is also used by three of the external tool commands we set up just above: if you take a look at the arguments for tools 1, 2 and 3, you’ll see a capital H. If you decide that you’d rather not use capital H as the shortcut key for “Paste as HTML”, revisit the “Tools>External Tools…” dialog and change the capital H in the arguments lists to the key you prefer. For example, if you’d rather use a lowercase j for the shortcut, change the H to j for the three tools: the arguments for “Paste Code” would then be “C:\Perl\vsprogs\cpp2htm.pl 4 j”, and similar changes for “Paste Image” and “Paste Table…”.)
最后,这四个新的外部命令的快捷键.它们的设置方式与我们上面设置"粘贴为HTML"快捷方式的方式相同,但是我们在此处突破了Visual Studio灵活性的限制,因此,当我们转到"工具>选项…>环境"时, >“键盘”,我们将不会查找所设置工具的名称(“粘贴代码"等);相反,我们将寻找” Tools.ExternalCommandN”,其中N是1到24之间的数字,例如:” Tools.ExternalCommand14”.(And finally, shortcut keys for those four new external commands. They’re set up in the same way that we set up the “Paste as HTML” shortcut just above, but we’re pushing the limits of Visual Studio’s flexibility here, so when we go to “Tools>Options…>Environment>Keyboard”, we won’t be looking for the names of the tools we set up (“Paste Code” etc.); instead, we’ll be looking for “Tools.ExternalCommandN” where N is a number between 1 and 24, e.g.: “Tools.ExternalCommand14”.)
在"工具"菜单下查看,您将看到"工具"菜单的小节中列出的四个新的外部命令"粘贴代码"等,位于两条分隔线之间:该命令在此小节中的位置为要记住的外部命令号;因此,例如,如果"粘贴代码"是分隔线下方的第一项,则为其设置快捷方式的命令称为" Tools.ExternalCommand1".如果您按上述相同的顺序添加了命令,则"粘贴代码"下面的下一个菜单项将是"粘贴图像",与本例中的" Tools.ExternalCommand2"相对应.记下用于四个命令的数字,然后可以为它们添加快捷键.(Take a look under your “Tools” menu and you’ll see the four new external commands, “Paste Code” etc., listed in a subsection of the Tools menu, between two separator lines: the position of the command within this subsection is the external command number to remember; so for example, if “Paste Code” is the first item below the divider line, then the command to set up the shortcut for it is called “Tools.ExternalCommand1”. If you’ve added the commands in the same order as described above, then the next menu item below “Paste Code” will be “Paste Image”, corresponding to “Tools.ExternalCommand2” in our example. Take a note of the numbers to use for the four commands, and then you can add the shortcut keys for them.)
选择"工具>选项…",然后在"环境"标题下,单击"键盘".在"显示包含的命令"字段中,键入"外部",这将减少" Tools.ExternalCommandN"项的命令列表.(Select “Tools>Options…”, and then under the “Environment” heading, click on “Keyboard”. In the “Show commands containing” field, type “external”, which will reduce the list of commands to the “Tools.ExternalCommandN” items.)
为四个要添加的快捷方式中的每一个:(For each of the four shortcuts to add:)
-
选择一个与您要为其添加快捷方式的命令相对应的数字,例如:" Tools.ExternalCommand14".(Pick the one with the number corresponding to the command you’re adding a shortcut for, e.g.: “Tools.ExternalCommand14”.)
-
在对话框的下方,在"使用新的快捷方式"菜单下,选择" HTML编辑器设计视图".(Down lower in the dialog, under the “Use new shortcut in” menu, select “HTML Editor Design View”.)
-
单击菜单右侧的"按快捷键"字段.(Click in the “Press shortcut key(s)” field to the right of the menu.)
-
输入快捷方式,然后在每次操作时单击"分配"按钮.此列表只是一个建议,您可以改用任何您喜欢的快捷键.(Enter your shortcut, and click the “Assign” button for each as you go. This list is just a suggestion, and you can use any shortcut keys you prefer instead.)
-
“粘贴代码”:CTRL-P(按住Ctrl键,然后按" P"键,对此或以下任何一项均不更改)(“Paste Code”: CTRL-P (hold down the Ctrl key and then press the “P” key, no shift for this or any of the following))
-
“粘贴图像”:CTRL-I(“Paste Image”: CTRL-I)
-
“从文本粘贴表”:CTRL-T(“Paste Table from text”: CTRL-T)
-
“从完整路径打开文件”:CTRL-U(“Open File from full path”: CTRL-U) 单击确定按钮,然后在"工具"菜单下查看以查看命令名称旁边的新快捷方式.(Click the OK button and then take a look under your Tools menu to see your new shortcuts beside the command names.)
做完了!我们将以简要的指南结束本指南,主要是关于使用刚刚添加的这四个新工具.(Done! We’ll finish this up with a brief guide, mainly about using those four new tools you just added.)
处理样式文档(Working with styled documents)
创建一个新样式的文档(Creating a new styled document)
要开始新的开发日志,请复制"(To start a new development log, copy “)log.htm(log.htm)“和”(” and “)log.css(log.css)” 来自(" from the)**\ stylishdocs(\stylishdocs)**您检索到要保留新日志的位置的文件夹.改名 “(folder that you retrieved to the place where you want to keep your new log. Rename “)log.htm(log.htm)“适合您的目的.您复制的原因”(” to suit your purpose. The reason you’re copying “)log.htm(log.htm)“是因为它包含指向”(” is that it contains a link to the “)**log.css(log.css)**样式表.如果您希望在文档中放入任何图像,请创建一个”(” stylesheet. If you expect to put any images in your document, create an “)**图片(images)**目录与您的文档和CSS文件位于同一级别.现在,您可以在Visual Studio中打开文档并在"设计视图"中对其进行编辑.(” directory at the same level as your document and CSS files. Now you can open your document in Visual Studio and edit it in Design View.)
如果您要制作报告或帮助文件草稿,则可以在(If you’re doing a report or help file draft, you’ll find report and help templates in the)**\ stylishdocs(\stylishdocs)**可以将其用作起点的文件夹,尽管您可能需要稍微调整一下CSS. [我会为您完成的,但是我似乎放错了您的公司风格指南:)](folder that you can use instead as a starting point, though you might want to tune up the CSS a bit. [I would have done that for you, but I seem to have misplaced your corporate style guide:)])
默认情况下,您的文档及其关联的CSS文件和(By default, your document and its associated CSS file and)**图片(images)**子目录都在同一位置.这样,如果您要移动或复制文档,就知道在哪里可以找到CSS文件和随附的图像.(subdirectory are all in the same place. This way, if you want to move or copy your document, you know where to find the CSS file and images that go with it.)
标准编辑(Standard editing)
“格式"工具栏包含样式按钮和菜单,使您可以使用标题,创建编号列表,使用粗体和斜体等.(The “Formatting” toolbar contains styling buttons and menus allowing you to use headings, create numbered lists, use bold and italic etc.)
对于纯文本,请使用"常规"样式.在日志中使用(For plain text, use the “Normal” style. In a log using)log.css(log.css),正常的段落将从左开始对齐,各段落之间没有多余的间距,外观与纯文本相同-但段落的第二行和后续行将稍有缩进.(, normal paragraphs will start flush left, and there will be no extra spacing between paragraphs, giving the same look as plain text - but second and subsequent lines in a paragraph will be indented slightly.)
如您所愿,编号列表将在您编辑它们时自动重新编号.项目符号列表也可以使用.对于表格,有一个完整的"表格"主菜单(请参见下面的"在表格中粘贴”).对于日志,(Numbered lists will be automatically renumbered as you edit them, as promised. Bulleted lists are also usable. For tables, there’s an entire main “Table” menu (and see “Pasting in a table” below). For logs, the)**log.css(log.css)**表单元格的条目((entry for table cells () TD
)只需将字体设置为Courier New,否则表不提供样式替代.想要大胆的表格标题吗?拖过标题行,然后单击" B"按钮.() just sets the font to Courier New, otherwise no style overrides are supplied for tables. Want bold table headings? Drag across the heading row and click the “B” button.)
粘贴代码(Pasting in code)
复制您的代码,切换到您的文档,然后选择"粘贴代码"命令.几乎任何语言的代码都应该粘贴好.如果复制完整的行,结果看起来最好.外观部分受制于(Copy your code, switch to your document, and select the “Paste Code” command. Code in just about any language should paste fine. Results look best if you copy complete lines. The appearance is partly governed by the) <PRE>
元素输入到CSS文件中,但是制表符在粘贴之前会转换为空格,因为制表符中的制表符的宽度(element entry in your CSS file, but tabs are converted to spaces before pasting because the width of a tab in a) <PRE>
元素是8个空格.如果每个选项卡不使用4个空格,请编辑提供给粘贴代码命令的参数" C:\ Perl \ vsprogs \ cpp2htm.pl 4 H"等.将" 4"更改为" 5"将得到在将代码粘贴到日志中时,每个选项卡有5个空格,并向您的同事证明您不承认同伴的压力.(element is 8 spaces. If you don’t use 4 spaces per tab, edit the arguments supplied to the Paste Code command, “C:\Perl\vsprogs\cpp2htm.pl 4 H” etc. Changing the “4” to a “5” there will give you 5 spaces per tab when you paste code into your log, and also prove to your associates that you don’t acknowledge peer pressure.)
要从HTML返回源文件,请在粘贴代码后执行"编辑">“高级”>“格式选择”.可以设置一些工具(例如Visual Assist)来为您执行此操作.(To go back to a source file from HTML, do an Edit>Advanced>Format Selection after pasting the code. Some tools, such as Visual Assist, can be set up to do this for you.)
粘贴图像(Pasting in an image)
粘贴图像的工作方式有两种,具体取决于图像的起始位置.让我们拍一张名为"(Paste Image works in two ways, depending on where your image is to begin with. Let’s take an image called “)**logo.gif(logo.gif)**例如.您可以:(” as an example. You can:)
- 首先,复制(First, copy the)**logo.gif(logo.gif)**图片到您文档的本地"(image to your document’s local “)图片(images)“文件夹或您的”(” folder, or your “)常见图片(common images)“文件夹,即(” folder, which is “)C:\ CommonImages(C:\CommonImages)“默认情况下.要放置图片元素,只需复制图片名称”(” by default. To place your image element, copy just the name of the image “)logo.gif(logo.gif)";例如,将其键入到"设计视图和剪切"中,然后单击所需图像,然后选择"粘贴图像”.(” from somewhere; for example, type it into your Design View and Cut, then click where you want the image, and select Paste Image. If the image is in your)**常见图片(common images)**文件夹,它将被复制到您文档的本地(folder, it will be copied to your document’s local)**图片(images)**文件夹(如果尚未存在).(folder if it isn’t there already.)
- 或复制图像的完整路径或URL,例如"(Or copy a full path or URL for the image, such as “)C:\ snapshots \ logo.gif(C:\snapshots\logo.gif)” 要么 “(” or “)http://www.somewhere.com/images/logo.gif(http://www.somewhere.com/images/logo.gif)",然后单击并选择"粘贴图像”.在这种情况下,图像将被复制到本地"(", then click and select Paste Image. In this case, the image will be copied to your local “)图片(images)“文件夹,替换以前的任何版本.(” folder, replacing any previous version. For a second paste of)logo.gif(logo.gif),您只需要复制图像名称.(, you would just need to copy the image name.)
在这两种情况下,都会有一份(In both cases, there will be a copy of the)**logo.gif(logo.gif)**您的文档本地图像(image in your document’s local)**图片(images)**文件夹末尾,并且image元素将具有该文件夹的相对路径,例如(folder at the end, and the image element will have a relative path to that folder such as)
<img src="images/logo.gif">
.(.)
你的(Your)**常见图片(common images)**文件夹可以是您喜欢的任何文件夹.要进行更改,请替换”(folder can be any folder you like. To change it, replace the “)C:\ CommonImages(C:\CommonImages)",然后将其放在您的首选文件夹中.(” argument to Paste Image with your preferred folder. You can then make an image available to all your styled documents by placing it in your)**常见图片(common images)**目录.(directory.)
将所有图像的本地副本保存在文档的(Having local copies of all images in your document’s)**图片(images)**具有相对路径的文件夹使复制文档或脱机工作更加容易.缺点之一是,使用"粘贴图像"完成的图像都是静态副本,因此您应考虑手动插入指向文档本地之外的图像的链接(folder with relative paths makes copying your document or working offline easier. One disadvantage is that your images done with Paste Image are all static copies, so you should consider inserting links by hand to images outside of your document’s local)**图片(images)**可能会更改的文件夹.(folder that are likely to change.)
顺便说一句,无论打开了哪个VS项目或解决方案,您都可以将图像正确粘贴到任何样式的文档中,而不必是"拥有"该文档的对象.(By the way, you can paste images correctly into any styled document no matter what VS project or solution is open, it doesn’t have to be the one that “owns” the document.)
要更改图像的显示大小,最好从"设计"视图切换到" HTML"视图并直接编辑HTML.如果在"设计视图"中右键单击图像,则有一个菜单项可让您向图像添加默认的宽度/高度属性,从而节省了键入的时间.(To change the displayed size of the image, it’s best to switch from “Design” view to “HTML” view and edit the HTML directly. If you right-click on an image in Design View, there’s a menu item that lets you add default width/height attributes to your image, saves a bit of typing.)
从纯文本粘贴到表格中(Pasting in a table from plain text)
在纯文本文档中选择表格,切换到样式文档,然后使用"从文本粘贴表格"命令.纯文本表中的字段应由"一个或多个连续的选项卡,选项卡组的两侧带有可选空格"或"一个或多个空格"分隔.如果一行包含任何选项卡,则前一个规则将用于将字段拆分为表格单元格;否则,任何空格都将视为字段拆分器.因此,例如,您可以使一行标题由制表符分隔,然后使数字行仅由空格分隔.如果列标题用—-或====下划线,则粘贴到表中时将跳过该行.(Select the table in a plain text document, switch to your styled document, and use the “Paste Table from text” command. The fields in your plain text tables should be separated by either “one or more consecutive tabs, with optional spaces on either side of the group of tabs”, or by just “one or more spaces”. If a row contains any tabs, the former rule will be used to split your fields up into table cells: otherwise, any run of spaces will count as a field splitter. So you can have a row of column titles separated by tabs, and then rows of numbers separated by just spaces, for example. If your column titles are underlined with —- or ==== characters, that row will be skipped when pasting in your table.)
从完整路径打开文件(Opening a file from a full path)
在文档的"设计视图"中,单击包含文件或URL完整路径的行中的任意位置,选择"从完整路径打开文件"命令,相应的文件将在新窗口中打开.(In the Design View for your document, click anywhere in a line that contains a full path to a file or a URL, select the “Open File from full path” command, and the corresponding file will open in a new window.)
如果文件具有公认的适用于Visual Studio的扩展名,则将在Visual Studio中打开该文件.如果扩展名未被识别,或者路径实际上是URL,则将使用文件扩展名的默认应用程序打开文件.要在Visual Studio中添加或删除由"从完整路径打开文件"命令关联的扩展名,请在"(If the file has an extension that is recognized as appropriate for Visual Studio, then the file will be opened in Visual Studio. If the extension is not recognized, or the path is actually a URL, then the file will be opened using the default application for the file’s extension. To add or remove extensions associated by the “Open File from full path” command with Visual Studio, edit the list of extensions at the bottom of “)C:\ Perl \ vsprogs \ openlink.pl(C:\Perl\vsprogs\openlink.pl)”.(".)
示例(具有默认扩展名设置):(Examples (with default extension settings):)
- C:\ Program Files \ Microsoft Visual Studio \ MyProjects \ Nowcaster \ Docs \ indexes.txt(C:\Program Files\Microsoft Visual Studio\MyProjects\Nowcaster\Docs\indexes.txt)-在Visual Studio中打开.(- opens in Visual Studio.)
- C:\ Program Files \ Microsoft Visual Studio \ MyProjects \ Nowcaster \ Docs \ Images \ aquascope.gif(C:\Program Files\Microsoft Visual Studio\MyProjects\Nowcaster\Docs\Images\aquascope.gif)-在默认的" GIF"编辑器(而不是VS)中打开.(- opens in the default “GIF” editor, not VS.)
- http://www.somewhere.com/tocBrowseCL_E.asp?lang=zh-CN&selLetter=A#A(http://www.somewhere.com/tocBrowseCL_E.asp?lang=en&selLetter=A#A)-在默认的Web浏览器(而不是VS)中打开.(- opens in the default web browser, not VS.)
- www.somewhere.com(www.somewhere.com)-也会在默认的网络浏览器中打开.(- also opens in the default web browser.) 如果换行中断了您的完整路径或跨多行的链接,请单击任意行.注意:此命令不够复杂,无法在一行上处理两条或更多条路径,通常会打开最左边的一条.(If line wrapping breaks your full path or link across multiple lines, click in any of the lines. Note: this command isn’t sophisticated enough to deal with two or more paths on one line, and will typically open the leftmost one.)
复制中(Copying)
在同一个文件夹中有多个样式文件,它们的所有图像都将以相同的"(With several styled documents in the same folder, all of their images will end up in the same “)**图片(images)**子文件夹.适合您,但是如果您想将文档发送给其他人,又不想让其他文档中的图像随身携带怎么办?(” subfolder. Fine for you, but what if you want to send the document to someone else, and don’t want images from other documents to go along for the ride?)
如果您最初在自己的文件夹中创建样式化文档,则它将具有自己的样式(If you originally created the styled document in its own folder, then it will have its own)**图片(images)**子文件夹,则可以只复制包含样式文档的整个文件夹.(subfolder, and you can just copy the entire folder containing the styled document.)
否则,这是一种复制单个样式文档的便捷方法(我们称其为"(Otherwise, a good portable way to copy a single styled document (let’s call it “)docname.htm(docname.htm)")是在Internet Explorer中打开它,然后使用"另存为…“将其另存为"完整的网页”.这会将您文档的CSS文件和所有关联的图片放入”(") is to open it in Internet Explorer and use “Save As…” to save it as a “Web Page, complete”. This puts your document’s CSS file and any associated images into a “)**docname_files(docname_files)**文件夹与您的副本位于同一级别,并且仅复制文档中实际使用的图像.(” folder at the same level as your copy, and copies only the images that are actually used in your document.)
客制化(Customizing)
随意调整CSS. “(Feel free to tune up the CSS. The “)**log.css(log.css)**例如,““文件包含段落,有序列表和表格元素等的条目,这些条目可调整字体和边距设置.基本上,您使用的Courier New具有最小的边距.(” file, for example, contains entries for paragraphs, ordered lists, and table elements etc. which adjust font and margin settings. Basically, you have Courier New with minimal margins.)
标准图像文件夹的名称仅在一个位置使用,即"粘贴图像"工具的参数中,即C:\ Perl \ vsprogs \ imglink.pl H $(ItemPath)图像” C:\ CommonImages"等.您希望为该文件夹使用其他名称,请将参数列表中的"图像"更改为您的首选名称.如上所述,"(The name of your standard images folder is used in just one place, in the arguments for the “Paste Image” tool, C:\Perl\vsprogs\imglink.pl H $(ItemPath) images “C:\CommonImages” etc. If you prefer a different name for the folder, change “images” in the argument list to your preferred name. As mentioned above, the “)C:\ CommonImages(C:\CommonImages)“参数是用于所有样式文档通用图像的目录名称,您可以将其替换为所需的任何位置.仅当目录路径中有空格时才需要使用引号.(” argument is the name of a directory to use for images common to all your styled documents, and you can replace this with any location you like. The quotes are only needed if there’s a space in the path to the directory.)
可以说服"从文本粘贴表"对粘贴的表应用一些样式,例如上面的屏幕快照中的表.要应用样式,请调出"从文本粘贴表"命令的参数列表,并将最后一个参数从"否"更改为"是”.要更改表格样式的详细信息,请在表格顶部附近查找” $ tableStart”(“Paste Table from text” can be persuaded to apply a bit of styling to your pasted-in tables, an example being the table in the screenshot up above. To apply the styling, bring up the arguments list for the “Paste Table from text” command and change the last argument from “no” to “yes”. To change the table styling details, look for “$tableStart” near the top of)C:\ Perl \ vsprogs \ tableize.pl(C:\Perl\vsprogs\tableize.pl).(.)
滋扰(Nuisances)
- 当您将普通粘贴粘贴到HTML Design视图中时,粘贴的内容将保持选中状态.轻击向右箭头键可将您向前移动.(When you do a normal paste into your HTML Design view, what you paste will remain selected. Tapping the right arrow key moves you onwards.)
- 在极少数情况下,粘贴到"设计视图"中的结果可能只有几个字符:我所知道的唯一解决方法是撤消,在要粘贴的位置非常用力地单击,然后再次粘贴.(On rare occasions, a paste into a Design View might end up off by a few characters: the only fix I know of is to undo, click very firmly at the spot where you really want the paste, and paste again.)
- 光标维护有时会在"设计"视图中入睡-经常挥动鼠标将其唤醒.诅咒没有帮助:)(Cursor maintenance sometimes falls asleep in the Design view - waving the mouse around often wakes it up. Cursing doesn’t help:))
- 如果您添加了其他工具,那么,如果在此处添加的新工具之前插入了新工具,则外部命令的编号将发生变化;在这种情况下,您需要在"工具"菜单中确定四个命令的新位置后,重新分配它们的快捷方式.(If you add additional Tools, the numbering of your external commands will change if the new tools are inserted before the ones you added here; in that case, you’ll need to reassign the shortcuts for the four commands after determining their new positions in the Tools menu.)
工具讯息(Tool messages)
如果您添加的基于Perl的工具之一出现问题,则会在其中显示一条消息.(If one of the Perl-based tools that you added runs into trouble, it puts a message in)C:\ Perl \ vsperlerror.txt(C:\Perl\vsperlerror.txt).至少对我来说,最常见的错误是尝试将链接粘贴到不存在的图像((. Commonest error for me at least, is trying to paste in a link to an image that doesn’t exist ()pushpinn.gif(pushpinn.gif)).().)
InvisiPerl(InvisiPerl)
如果直接将Perl程序作为VS外部工具运行,您将遇到"您在我身上使用了那些浮华的东西吗?“作为命令提示符窗口的体验会短暂出现.(If you run a Perl program directly as a VS external tool, you’ll have a “did you use that flashy thingy on me?” experience as a command prompt window briefly appears.)**的InvisPerl(InvisPerl.exe)**运行Perl程序,但隐藏命令提示符窗口.本文顶部有一个InvisiPerl项目的下载链接,但请注意:对于时尚的日志,您不需要该项目. InvisiPerl只是针对(runs the Perl program but suppresses the command prompt window. There’s a download link for the InvisiPerl project at the top of this article, but note: you don’t need the project for stylish logs. InvisiPerl is just a wrapper for the) RunSilent
代码项目文章中的函数(function in the Code Project article) 静默运行控制台应用程序(Running console applications silently) 史蒂文`塞泽莱(Steven Szelei)撰写-感谢史蒂文!(by Steven Szelei - thanks Steven!)
兴趣点(Points of interest)
我简要地探讨了添加命令的自动化(OLE),但是找不到在HTML设计视图中访问选择内容的方法.因此,Perl程序通过"模拟类型"来操纵Visual Studio-(I briefly explored automation (OLE) for the added commands, but couldn’t find a way to access the selection in an HTML Design View. So the Perl programs manipulate Visual Studio by means of “simulated typing” - the)openlink.pl(openlink.pl)“从完整路径打开文件"后面的程序通常只执行您要执行的操作,它选择完整路径,将其复制,调用"打开"对话框,粘贴在路径中,然后按Enter.(program behind “Open file from full path” mostly just does what you would do, it selects the full path, copies it, calls up the Open dialog, pastes in the path, and presses Enter.)
我之所以使用Perl是因为这对我来说是最快的方法,而且我也不从事VS插件业务(如果听起来很有趣,任何人都可以随意将它们重写为插件). Perl程序旨在使您易于阅读和调整,而不是使用现代Perl样式的模型.有些片段可能对您有用,例如”(I used Perl for this because it was the quickest approach for me, and I’m not in the VS add-in business (anyone should feel free to rewrite them as add-ins if that sounds like fun). The Perl programs are intended to be simple to read and tweakable by you, rather than models of modern Perl style. There are some snippets that you might find useful, such as “) sub SendCharacters
“,它将模拟按键发送到前窗,以及将正则表达式发送到(” which sends simulated key presses to the front window, and regular expressions near the top of)**perl/vsprogs/openlink.pl(perl/vsprogs/openlink.pl)**识别完整的文件路径和URL.(to recognize full file paths and URLs.)
这就是包装.我希望您喜欢在Visual Studio中拥有时尚的文档,并且,如果您提出改进或添加的内容,不要害羞分享它们!(And that’s a wrap. I hope you enjoy having stylish documents in Visual Studio, and if you come up with improvements or additions, don’t be shy about sharing them!)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ Perl VC7.1 WinXP Win2003 Windows Win2K Visual-Studio VS.NET2003 Dev 新闻 翻译