@@ -11,16 +11,34 @@ Public Module CoverageColorSelector
11
11
End If
12
12
Dim FileStream As FileStream = File.OpenRead(FPath)
13
13
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
15
19
While (sr.Peek() <> - 1 )
16
20
Dim line As String = sr.ReadLine()
17
21
Dim Split() As String = line.Split( ","c )
18
22
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)
24
42
End While
25
43
sr.Close()
26
44
FileStream.Close()
@@ -29,33 +47,33 @@ Public Module CoverageColorSelector
29
47
Private Sub WriteColorDictionaryToFile(FPath As String )
30
48
Dim FileStream As FileStream = File.OpenWrite(FPath)
31
49
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}" )
35
53
Next
36
54
sw.Flush()
37
55
sw.Close()
38
56
FileStream.Close()
39
57
End Sub
40
58
41
- Friend Function GetColorFromName(Name As String ) As Color
59
+ Friend Function GetColorFromName(Name As String ) As (Foreground As Color, Background As Color)
42
60
Try
43
61
If String .IsNullOrWhiteSpace(Name) Then
44
- Return CoverageColors .ColorMappingDictionary("default" )
62
+ Return CodeColorSelector .ColorMappingDictionary("default" )
45
63
End If
46
- Return CoverageColors .ColorMappingDictionary(Name)
64
+ Return CodeColorSelector .ColorMappingDictionary(Name)
47
65
Catch ex As Exception
48
66
Debug.Print( $"GetColorFromName missing({Name})" )
49
67
Stop
50
- Return CoverageColors .ColorMappingDictionary("error" )
68
+ Return CodeColorSelector .ColorMappingDictionary("error" )
51
69
End Try
52
70
End Function
53
71
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
55
73
Return CoverageColors.ColorMappingDictionary.Keys
56
74
End Function
57
75
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) )
59
77
CoverageColors.ColorMappingDictionary(name) = value
60
78
WriteColorDictionaryToFile(FullPath)
61
79
End Sub
0 commit comments