Skip to content

Commit b81fc8b

Browse files
authored
Report grouping part2 (#206)
* correct hack grouping. Better theme keys. Consistent colour naming and reflection convert.
1 parent 5cbaf45 commit b81fc8b

9 files changed

+171
-105
lines changed

Shared Files/Resources/reportparts.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ReportParts>
3+
<ReportPart Name="SliderLeftColour" SelectedThemeColourName="EnvironmentColors.ToolWindowTextColorKey" />
4+
<ReportPart Name="SliderRightColour" SelectedThemeColourName="EnvironmentColors.ToolWindowTextColorKey" />
5+
<ReportPart Name="SliderThumbColour" SelectedThemeColourName="EnvironmentColors.ScrollBarThumbBackgroundColorKey" />
36
<ReportPart Name="ScrollBarArrowColour" SelectedThemeColourName="EnvironmentColors.ScrollBarArrowBackgroundColorKey" />
47
<ReportPart Name="ScrollBarTrackColour" SelectedThemeColourName="EnvironmentColors.ScrollBarBackgroundColorKey" />
58
<ReportPart Name="ScrollBarThumbColour" SelectedThemeColourName="EnvironmentColors.ScrollBarThumbBackgroundColorKey" />
69
<ReportPart Name="ComboBoxColour" SelectedThemeColourName="CommonControlsColors.ComboBoxBackgroundColorKey" />
710
<ReportPart Name="ComboBoxBorderColour" SelectedThemeColourName="CommonControlsColors.ComboBoxBorderColorKey" />
811
<ReportPart Name="ComboBoxTextColour" SelectedThemeColourName="CommonControlsColors.ComboBoxTextColorKey" />
9-
<ReportPart Name="GrayCoverage" SelectedThemeColourName="EnvironmentColors.SystemGrayTextColorKey" />
12+
<ReportPart Name="GrayCoverageColour" SelectedThemeColourName="EnvironmentColors.SystemGrayTextColorKey" />
1013
<ReportPart Name="BackgroundColour" SelectedThemeColourName="EnvironmentColors.ToolWindowBackgroundColorKey" />
1114
<ReportPart Name="FontColour" SelectedThemeColourName="EnvironmentColors.ToolWindowTextColorKey" />
1215
<ReportPart Name="TableBorderColour" SelectedThemeColourName="EnvironmentColors.GridLineColorKey" />

SharedProject/Core/ReportGenerator/IReportColours.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal interface IReportColours
2929

3030
Color FontColour { get; }
3131

32-
Color GrayCoverage { get; }
32+
Color GrayCoverageColour { get; }
3333

3434
Color HeaderBorderColour { get; }
3535

@@ -52,6 +52,12 @@ internal interface IReportColours
5252
Color TextBoxColour { get; }
5353

5454
Color TextBoxTextColour { get; }
55+
56+
Color SliderLeftColour { get; }
57+
58+
Color SliderRightColour { get; }
59+
60+
Color SliderThumbColour { get; }
5561
}
5662

5763
}

SharedProject/Core/ReportGenerator/JsThemeStyling.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ public class JsThemeStyling
2929
public string DownActiveBase64;
3030
public string DownInactiveBase64;
3131
public string UpActiveBase64;
32-
public string GrayCoverage;
33-
public string ComboBox;
34-
public string ComboBoxBorder;
35-
public string ComboBoxText;
36-
public string ScrollBarArrow;
37-
public string ScrollBarTrack;
38-
public string ScrollBarThumb;
39-
//#pragma warning restore SA1401 // Fields should be private
40-
//#pragma warning restore IDE0079 // Remove unnecessary suppression
32+
public string GrayCoverageColour;
33+
public string ComboBoxColour;
34+
public string ComboBoxBorderColour;
35+
public string ComboBoxTextColour;
36+
public string ScrollBarArrowColour;
37+
public string ScrollBarTrackColour;
38+
public string ScrollBarThumbColour;
39+
public string SliderLeftColour;
40+
public string SliderRightColour;
41+
public string SliderThumbColour;
42+
//#pragma warning restore SA1401 // Fields should be private
43+
//#pragma warning restore IDE0079 // Remove unnecessary suppression
4144
}
4245
}

SharedProject/Core/ReportGenerator/ReportColours.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class ReportColours : IReportColours
2929

3030
public Color FontColour { get; set; }
3131

32-
public Color GrayCoverage { get; set; }
32+
public Color GrayCoverageColour { get; set; }
3333

3434
public Color HeaderBorderColour { get; set; }
3535

@@ -52,6 +52,12 @@ internal class ReportColours : IReportColours
5252
public Color TextBoxColour { get; set; }
5353

5454
public Color TextBoxTextColour { get; set; }
55+
56+
public Color SliderLeftColour { get; set; }
57+
58+
public Color SliderRightColour { get; set; }
59+
60+
public Color SliderThumbColour { get; set; }
5561
}
5662

5763
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Reflection;
4+
5+
namespace FineCodeCoverage.Engine.ReportGenerator
6+
{
7+
internal static class ReportColoursExtensions
8+
{
9+
private class ColourReflection
10+
{
11+
public PropertyInfo ReportColoursPropertyInfo { get; set; }
12+
public FieldInfo JsThemeStylingFieldInfo { get; set; }
13+
}
14+
private static List<ColourReflection> colourReflections;
15+
private static List<ColourReflection> ColourReflections
16+
{
17+
get
18+
{
19+
if (colourReflections == null)
20+
{
21+
var reportColourPropertyInfos = typeof(IReportColours).GetProperties();
22+
var jsThemeStylingFieldInfos = typeof(JsThemeStyling).GetFields();
23+
colourReflections = reportColourPropertyInfos.Select(prop =>
24+
{
25+
var field = jsThemeStylingFieldInfos.FirstOrDefault(f => f.Name == prop.Name);
26+
if (field == null)
27+
{
28+
return null;
29+
}
30+
else
31+
{
32+
return new ColourReflection { ReportColoursPropertyInfo = prop, JsThemeStylingFieldInfo = field };
33+
}
34+
}).Where(cr => cr != null).ToList();
35+
}
36+
return colourReflections;
37+
}
38+
}
39+
public static JsThemeStyling Convert(this IReportColours reportColours)
40+
{
41+
var jsThemeStyling = new JsThemeStyling();
42+
ColourReflections.ForEach(cr =>
43+
{
44+
cr.JsThemeStylingFieldInfo.SetValue(jsThemeStyling, ((System.Drawing.Color)cr.ReportColoursPropertyInfo.GetValue(reportColours)).ToJsColour());
45+
});
46+
return jsThemeStyling;
47+
}
48+
49+
public static string ToJsColour(this System.Drawing.Color colour)
50+
{
51+
return $"rgba({colour.R},{colour.G},{colour.B},{colour.A})";
52+
}
53+
}
54+
}

SharedProject/Core/ReportGenerator/ReportColoursProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class ReportColoursProvider : IReportColoursProvider
1313

1414
public event EventHandler<IReportColours> ColoursChanged;
1515

16-
private static PropertyInfo[] propertyInfos;
16+
private static readonly PropertyInfo[] propertyInfos;
1717
static ReportColoursProvider()
1818
{
1919
propertyInfos = typeof(ReportColours).GetProperties();

0 commit comments

Comments
 (0)