有没有一种方法可以一次打印解决方案中的所有(*.cs)文件,也就是说,不需要单击每个文件然后点击打印?
发布于 2009-03-25 22:51:40
从我从a similar question asked elsewhere收集到的信息来看,这个“特性”并没有内置到Visual Studio中。
尽管它看起来像MSDN has a macro you can use to print all of your code;也许您可以使用下面的代码,或者使用类似的代码:
Sub PrintItemsInSelectedProject()
Dim proj As Project
Dim objProj As Object()
objProj = DTE.ActiveSolutionProjects
If objProj.Length = 0 Then
Exit Sub
End If
proj = DTE.ActiveSolutionProjects(0)
PrintItemsInSelectedProject(proj.ProjectItems)
End Sub
Private Sub PrintItemsInSelectedProject( _
ByVal projitems As ProjectItems)
Dim projitem As ProjectItem
For Each projitem In projitems
If (IsPrintableFile(projitem) = True) Then
If (projitem.IsOpen( _
EnvDTE.Constants.vsViewKindTextView)) Then
projitem.Document.PrintOut()
Else
Dim doc As Document
doc = projitem.Open( _
EnvDTE.Constants.vsViewKindTextView).Document
doc.PrintOut()
doc.Close(vsSaveChanges.vsSaveChangesNo)
End If
End If
PrintItemsInSelectedProject(projitem.ProjectItems)
Next
End Sub
Function IsPrintableFile( _
ByVal projItem As ProjectItem) As Boolean
Dim fileName As String
Dim extensions As _
New System.Collections.Specialized.StringCollection
' If you add a file to your project that is of
' a type that can be printed,
' then add the extension of that
' file type to this list.
Dim exts As String() = {".cs", ".vb", _
".aspx", ".xsd", ".xml", ".xslt", _
".config", ".htm", ".html", ".css", _
".js", ".vbs", ".wsf", ".txt", ".cpp", _
".c", ".h", ".idl", ".def", ".rgs", ".rc"}
extensions.AddRange(exts)
fileName = projItem.FileNames(1)
Return extensions.Contains( _
System.IO.Path.GetExtension(fileName).ToLower())
End Function
发布于 2012-01-25 06:56:21
发布于 2015-04-11 00:11:58
你可以在我的电脑中下载用于.NET 2.0的PrettyCode.Print (VS2008和VS2005):http://pan.baidu.com/wap/shareview?&shareid=3968547697&uk=286220058&dir=%2FSoftz&page=1&num=20&fsid=1117386981714891&third=0 In my computer work fine with Visual Studio2013。
https://stackoverflow.com/questions/683759
复制相似问题