Imports
EnvDTE
Imports System.Diagnostics
Imports System
Public Module LinesCsharp Module LinesCsharp
Private Count As Integer = 0
Public Sub CodeLinesTotal()Sub CodeLinesTotal()
Count = 0
Dim projs As System.Array = DTE.ActiveSolutionProjects
For Each proj As Project In DTE.ActiveSolutionProjects
ReCheck(proj.ProjectItems)
Next
MsgBox("非环境代码统计总计:" + Count.ToString() + "行", MsgBoxStyle.Information, "代码总计")
End Sub
Public Sub ReCheck()Sub ReCheck(ByVal projitems As ProjectItems)
For i As Integer = 1 To projitems.Count
ReCheck(projitems.Item(i).ProjectItems)
CalCount(projitems.Item(i))
Next
End Sub
Public Sub CalCount()Sub CalCount(ByVal projitem As ProjectItem)
With projitem
If Mid(.Name, Len(.Name) - 2, 3) = ".cs" And .Name <> "Assemblyinfo.cs" Then
If .Name.Length > 13 Then
If .Name.Length > 13 Then
If Mid(.Name, Len(.Name) - 11, 12) <> ".Designer.cs" Then
.Open()
.Document.Activate()
DTE.ExecuteCommand("View.ViewCode")
CType(.Document.Selection, TextSelection).EndOfDocument()
Count += CType(.Document.Selection, TextSelection).TopPoint.Line
.Document.Close(vsSaveChanges.vsSaveChangesNo)
End If
Else
.Open()
.Document.Activate()
DTE.ExecuteCommand("View.ViewCode")
CType(.Document.Selection, TextSelection).EndOfDocument()
Count += CType(.Document.Selection, TextSelection).TopPoint.Line
.Document.Close(vsSaveChanges.vsSaveChangesNo)
End If
End If
End If
End With
End Sub
End Module
Imports System.Diagnostics
Imports System
Public Module LinesCsharp Module LinesCsharp
Private Count As Integer = 0
Public Sub CodeLinesTotal()Sub CodeLinesTotal()
Count = 0
Dim projs As System.Array = DTE.ActiveSolutionProjects
For Each proj As Project In DTE.ActiveSolutionProjects
ReCheck(proj.ProjectItems)
Next
MsgBox("非环境代码统计总计:" + Count.ToString() + "行", MsgBoxStyle.Information, "代码总计")
End Sub
Public Sub ReCheck()Sub ReCheck(ByVal projitems As ProjectItems)
For i As Integer = 1 To projitems.Count
ReCheck(projitems.Item(i).ProjectItems)
CalCount(projitems.Item(i))
Next
End Sub
Public Sub CalCount()Sub CalCount(ByVal projitem As ProjectItem)
With projitem
If Mid(.Name, Len(.Name) - 2, 3) = ".cs" And .Name <> "Assemblyinfo.cs" Then
If .Name.Length > 13 Then
If .Name.Length > 13 Then
If Mid(.Name, Len(.Name) - 11, 12) <> ".Designer.cs" Then
.Open()
.Document.Activate()
DTE.ExecuteCommand("View.ViewCode")
CType(.Document.Selection, TextSelection).EndOfDocument()
Count += CType(.Document.Selection, TextSelection).TopPoint.Line
.Document.Close(vsSaveChanges.vsSaveChangesNo)
End If
Else
.Open()
.Document.Activate()
DTE.ExecuteCommand("View.ViewCode")
CType(.Document.Selection, TextSelection).EndOfDocument()
Count += CType(.Document.Selection, TextSelection).TopPoint.Line
.Document.Close(vsSaveChanges.vsSaveChangesNo)
End If
End If
End If
End With
End Sub
End Module