Skip to content

Commit 3f7dbd7

Browse files
committed
Add some support for Themes but they are not really usable,
1 parent 409b731 commit 3f7dbd7

19 files changed

+9407
-278
lines changed

CodeCoverage/App.config

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22
<configuration>
33
<configSections>
44
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5+
<section name="CodeCoverage.Settings" type="System.Configuration.ClientSettingsSection, System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
56
<section name="CodeCoverage.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
67
</sectionGroup>
78
</configSections>
89
<startup>
910
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
1011
</startup>
1112
<userSettings>
13+
<CodeCoverage.Settings>
14+
<setting name="Last_jsonFile" serializeAs="String">
15+
<value />
16+
</setting>
17+
<setting name="UpgradeRequired" serializeAs="String">
18+
<value>True</value>
19+
</setting>
20+
<setting name="DefaultProjectDirectory" serializeAs="String">
21+
<value />
22+
</setting>
23+
<setting name="LastTheme" serializeAs="String">
24+
<value />
25+
</setting>
26+
</CodeCoverage.Settings>
1227
<CodeCoverage.My.MySettings>
1328
<setting name="Last_jsonFile" serializeAs="String">
1429
<value />

CodeCoverage/Assets/BigFace.xml

Lines changed: 8824 additions & 0 deletions
Large diffs are not rendered by default.

CodeCoverage/CodeColorSelector.vb

Lines changed: 0 additions & 134 deletions
This file was deleted.

CodeCoverage/CodeCoverage.vbproj

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
</PropertyGroup>
1515
<PropertyGroup>
1616
<Version>1.1.0.0</Version>
17+
<AssemblyVersion>1.1.0.0</AssemblyVersion>
18+
<ProductVersion>1.1.0.0</ProductVersion>
1719
<NeutralLanguage>en-US</NeutralLanguage>
1820
<RepositoryType>GitHub</RepositoryType>
1921
<RepositoryUrl>https://github.com/paul1956/CodeCoverage</RepositoryUrl>
2022
<Authors>Paul M Cohen</Authors>
2123
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
24+
<PackageTags>Code Coverage</PackageTags>
2225
</PropertyGroup>
2326
<ItemGroup>
2427
<Compile Remove="My Project\User.vb" />
@@ -40,28 +43,35 @@
4043
</Compile>
4144
</ItemGroup>
4245
<ItemGroup>
46+
<None Update="Assets\BigFace.xml">
47+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
48+
</None>
4349
<None Update="My Project\Application.myapp">
4450
<Generator>MyApplicationCodeGenerator</Generator>
4551
<LastGenOutput>Application.Designer.vb</LastGenOutput>
4652
</None>
53+
<None Update="My Project\Settings.settings">
54+
<Generator>SettingsSingleFileGenerator</Generator>
55+
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
56+
</None>
4757
</ItemGroup>
4858
<ItemGroup>
4959
<PackageReference Include="Microsoft.CodeAnalysis">
50-
<Version>3.4.0</Version>
60+
<Version>3.6.0</Version>
5161
</PackageReference>
5262
<PackageReference Include="Microsoft.CodeAnalysis.Common">
53-
<Version>3.4.0</Version>
63+
<Version>3.6.0</Version>
5464
</PackageReference>
5565
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces">
56-
<Version>3.4.0</Version>
66+
<Version>3.6.0</Version>
5767
</PackageReference>
5868
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
59-
<Version>2.9.8</Version>
69+
<Version>3.0.0</Version>
6070
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6171
<PrivateAssets>all</PrivateAssets>
6272
</PackageReference>
6373
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common">
64-
<Version>3.4.0</Version>
74+
<Version>3.6.0</Version>
6575
</PackageReference>
6676
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
6777
<PackageReference Include="Newtonsoft.Json">

CodeCoverage/CodeCoverageForm.vb

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Imports System.ComponentModel
2+
23
Imports CodeCoverage.Coverlet.Core
34

45
Public Class CodeCoverageForm
@@ -32,11 +33,31 @@ Public Class CodeCoverageForm
3233
Return table
3334
End Function
3435

36+
Private Shared Sub GotoLine(RTF_Box As RichTextBox, WantedLine_One_Based As Integer)
37+
Dim index As Integer = RTF_Box.GetFirstCharIndexFromLine(WantedLine_One_Based - 1)
38+
While index < RTF_Box.TextLength - 1
39+
If RTF_Box.Text.Substring(index, 1) <> " " Then
40+
Exit While
41+
End If
42+
index += 1
43+
End While
44+
RTF_Box.HideSelection = False
45+
RTF_Box.Select(index, 0)
46+
RTF_Box.ScrollToCaret()
47+
RTF_Box.Focus()
48+
Application.DoEvents()
49+
End Sub
50+
3551
Private Sub backgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
3652
' Get the BackgroundWorker object that raised this event.
3753
RTFForm.LoadDocument(CType(e.Argument, Form1))
3854
End Sub
3955

56+
Private Sub CodeCoverageForm_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
57+
_dT.Dispose()
58+
_dV.Dispose()
59+
End Sub
60+
4061
Private Sub CodeCoverageForm_Load(sender As Object, e As EventArgs) Handles Me.Load
4162
If RTFForm Is Nothing Then
4263
RTFForm = New Form1
@@ -89,21 +110,6 @@ Public Class CodeCoverageForm
89110
Initializing = False
90111
End Sub
91112

92-
Private Sub GotoLine(RTF_Box As RichTextBox, WantedLine_One_Based As Integer)
93-
Dim index As Integer = RTF_Box.GetFirstCharIndexFromLine(WantedLine_One_Based - 1)
94-
While index < RTF_Box.TextLength - 1
95-
If RTF_Box.Text.Substring(index, 1) <> " " Then
96-
Exit While
97-
End If
98-
index += 1
99-
End While
100-
RTF_Box.HideSelection = False
101-
RTF_Box.Select(index, 0)
102-
RTF_Box.ScrollToCaret()
103-
RTF_Box.Focus()
104-
Application.DoEvents()
105-
End Sub
106-
107113
Private Sub LoadDocumentIfNeeded(DocumentName As String)
108114
If RTFForm.LoadedDocument <> DocumentName Then
109115
RTFForm.LoadedDocument = DocumentName
@@ -227,9 +233,4 @@ Public Class CodeCoverageForm
227233
Initializing = False
228234
End Sub
229235

230-
Private Sub CodeCoverageForm_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
231-
_dT.Dispose()
232-
_dV.Dispose()
233-
End Sub
234-
235236
End Class

CodeCoverage/Coverlet/ColorRTB.vb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ Public Module ColorRTB
127127
For i As Integer = 0 To FragmentRange.Count - 1
128128
Dim _Range As Range = FragmentRange(i)
129129
.Select(.TextLength, 0)
130-
.SelectionColor = CodeColorSelector.GetColorFromName(_Range.ClassificationType)
130+
Dim ClassificationColor As (ForegroundColor As Color, BackGroundColor As Color) = GetColorFromName(_Range.ClassificationType)
131+
.SelectionColor = ClassificationColor.ForegroundColor
132+
.SelectionBackColor = ClassificationColor.BackGroundColor
131133
.AppendText(_Range.Text)
132134
If _Range.Text.Contains(vbLf, StringComparison.OrdinalIgnoreCase) Then
133135
Progress.UpdateProgress(_Range.Text.Count(CType(vbLf, Char)))

CodeCoverage/Coverlet/CoverageColorSelector.vb

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,34 @@ Public Module CoverageColorSelector
1111
End If
1212
Dim FileStream As FileStream = File.OpenRead(FPath)
1313
Dim sr As New StreamReader(FileStream)
14-
sr.ReadLine()
14+
Dim HeaderLine As String = sr.ReadLine()
15+
Dim ForeGroundOnlyFormat As Boolean = True = True
16+
If HeaderLine.Contains("BA", StringComparison.InvariantCulture) Then
17+
ForeGroundOnlyFormat = False
18+
End If
1519
While (sr.Peek() <> -1)
1620
Dim line As String = sr.ReadLine()
1721
Dim Split() As String = line.Split(","c)
1822
Dim key As String = Split(0)
19-
Dim A As Integer = Convert.ToInt32(Split(1), Globalization.CultureInfo.InvariantCulture)
20-
Dim R As Integer = Convert.ToInt32(Split(2), Globalization.CultureInfo.InvariantCulture)
21-
Dim G As Integer = Convert.ToInt32(Split(3), Globalization.CultureInfo.InvariantCulture)
22-
Dim B As Integer = Convert.ToInt32(Split(4), Globalization.CultureInfo.InvariantCulture)
23-
CoverageColors.ColorMappingDictionary(key) = Color.FromArgb(A, R, G, B)
23+
Dim ForeGroundA As Integer = Convert.ToInt32(Split(1), Globalization.CultureInfo.InvariantCulture)
24+
Dim ForeGroundR As Integer = Convert.ToInt32(Split(2), Globalization.CultureInfo.InvariantCulture)
25+
Dim ForeGroundG As Integer = Convert.ToInt32(Split(3), Globalization.CultureInfo.InvariantCulture)
26+
Dim ForeGroundB As Integer = Convert.ToInt32(Split(4), Globalization.CultureInfo.InvariantCulture)
27+
Dim BackGroundA As Integer
28+
Dim BackGroundR As Integer
29+
Dim BackGroundG As Integer
30+
Dim BackGroundB As Integer
31+
Dim BackGroundColor As Color
32+
If Not ForeGroundOnlyFormat Then
33+
BackGroundA = Convert.ToInt32(Split(1), Globalization.CultureInfo.InvariantCulture)
34+
BackGroundR = Convert.ToInt32(Split(2), Globalization.CultureInfo.InvariantCulture)
35+
BackGroundG = Convert.ToInt32(Split(3), Globalization.CultureInfo.InvariantCulture)
36+
BackGroundB = Convert.ToInt32(Split(4), Globalization.CultureInfo.InvariantCulture)
37+
BackGroundColor = Color.FromArgb(BackGroundA, BackGroundR, BackGroundG, BackGroundB)
38+
Else
39+
BackGroundColor = Color.White
40+
End If
41+
CoverageColors.ColorMappingDictionary(key) = (Color.FromArgb(ForeGroundA, ForeGroundR, ForeGroundG, ForeGroundB), BackGroundColor)
2442
End While
2543
sr.Close()
2644
FileStream.Close()
@@ -29,33 +47,33 @@ Public Module CoverageColorSelector
2947
Private Sub WriteColorDictionaryToFile(FPath As String)
3048
Dim FileStream As FileStream = File.OpenWrite(FPath)
3149
Dim sw As New StreamWriter(FileStream)
32-
sw.WriteLine($"Key,A,R,G,B")
33-
For Each kvp As KeyValuePair(Of String, Color) In CoverageColors.ColorMappingDictionary
34-
sw.WriteLine($"{kvp.Key},{kvp.Value.A},{kvp.Value.R},{kvp.Value.G},{kvp.Value.B}")
50+
sw.WriteLine($"Key,A,R,G,B,BA,BR,BG,BB")
51+
For Each kvp As KeyValuePair(Of String, (ForeGround As Color, Background As Color)) In CoverageColors.ColorMappingDictionary
52+
sw.WriteLine($"{kvp.Key},{kvp.Value.ForeGround.A},{kvp.Value.ForeGround.R},{kvp.Value.ForeGround.G},{kvp.Value.ForeGround.B},{kvp.Value.Background.A},{kvp.Value.Background.R},{kvp.Value.Background.G},{kvp.Value.Background.B}")
3553
Next
3654
sw.Flush()
3755
sw.Close()
3856
FileStream.Close()
3957
End Sub
4058

41-
Friend Function GetColorFromName(Name As String) As Color
59+
Friend Function GetColorFromName(Name As String) As (Foreground As Color, Background As Color)
4260
Try
4361
If String.IsNullOrWhiteSpace(Name) Then
44-
Return CoverageColors.ColorMappingDictionary("default")
62+
Return CodeColorSelector.ColorMappingDictionary("default")
4563
End If
46-
Return CoverageColors.ColorMappingDictionary(Name)
64+
Return CodeColorSelector.ColorMappingDictionary(Name)
4765
Catch ex As Exception
4866
Debug.Print($"GetColorFromName missing({Name})")
4967
Stop
50-
Return CoverageColors.ColorMappingDictionary("error")
68+
Return CodeColorSelector.ColorMappingDictionary("error")
5169
End Try
5270
End Function
5371

54-
Public Function GetColorNameList() As Dictionary(Of String, Color).KeyCollection
72+
Public Function GetColorNameList() As Dictionary(Of String, (Foreground As Color, Background As Color)).KeyCollection
5573
Return CoverageColors.ColorMappingDictionary.Keys
5674
End Function
5775

58-
Public Sub SetColor(name As String, value As Color)
76+
Public Sub SetColor(name As String, value As (Foreground As Color, Background As Color))
5977
CoverageColors.ColorMappingDictionary(name) = value
6078
WriteColorDictionaryToFile(FullPath)
6179
End Sub

0 commit comments

Comments
 (0)