Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions SharedProject/Core/ReportGenerator/IReportColours.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,52 +54,4 @@ internal interface IReportColours
Color TextBoxTextColour { get; }
}

internal class ReportColours : IReportColours
{
public Color BackgroundColour { get; set; }

public Color ComboBoxBorderColour { get; set; }

public Color ComboBoxColour { get; set; }

public Color ComboBoxTextColour { get; set; }

public Color CoverageTableActiveSortColour { get; set; }

public Color CoverageTableExpandCollapseIconColour { get; set; }

public Color CoverageTableHeaderFontColour { get; set; }

public Color CoverageTableInactiveSortColour { get; set; }

public Color CoverageTableRowHoverBackgroundColour { get; set; }

public Color DivHeaderBackgroundColour { get; set; }

public Color FontColour { get; set; }

public Color GrayCoverage { get; set; }

public Color HeaderBorderColour { get; set; }

public Color HeaderFontColour { get; set; }

public Color LinkColour { get; set; }

public Color ScrollBarArrowColour { get; set; }

public Color ScrollBarThumbColour { get; set; }

public Color ScrollBarTrackColour { get; set; }

public Color TabBackgroundColour { get; set; }

public Color TableBorderColour { get; set; }

public Color TextBoxBorderColour { get; set; }

public Color TextBoxColour { get; set; }

public Color TextBoxTextColour { get; set; }
}
}
12 changes: 12 additions & 0 deletions SharedProject/Core/ReportGenerator/IThemeResourceKeyProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.Shell;

namespace FineCodeCoverage.Engine.ReportGenerator
{
internal interface IThemeResourceKeyProvider
{
ThemeResourceKey Provide(string reportPart);
}
}
57 changes: 57 additions & 0 deletions SharedProject/Core/ReportGenerator/ReportColours.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace FineCodeCoverage.Engine.ReportGenerator
{
internal class ReportColours : IReportColours
{
public Color BackgroundColour { get; set; }

public Color ComboBoxBorderColour { get; set; }

public Color ComboBoxColour { get; set; }

public Color ComboBoxTextColour { get; set; }

public Color CoverageTableActiveSortColour { get; set; }

public Color CoverageTableExpandCollapseIconColour { get; set; }

public Color CoverageTableHeaderFontColour { get; set; }

public Color CoverageTableInactiveSortColour { get; set; }

public Color CoverageTableRowHoverBackgroundColour { get; set; }

public Color DivHeaderBackgroundColour { get; set; }

public Color FontColour { get; set; }

public Color GrayCoverage { get; set; }

public Color HeaderBorderColour { get; set; }

public Color HeaderFontColour { get; set; }

public Color LinkColour { get; set; }

public Color ScrollBarArrowColour { get; set; }

public Color ScrollBarThumbColour { get; set; }

public Color ScrollBarTrackColour { get; set; }

public Color TabBackgroundColour { get; set; }

public Color TableBorderColour { get; set; }

public Color TextBoxBorderColour { get; set; }

public Color TextBoxColour { get; set; }

public Color TextBoxTextColour { get; set; }
}

}
58 changes: 0 additions & 58 deletions SharedProject/Core/ReportGenerator/ReportColoursProvider.cs
Original file line number Diff line number Diff line change
@@ -1,69 +1,11 @@
using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Shell;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq;

namespace FineCodeCoverage.Engine.ReportGenerator
{
internal interface IThemeResourceKeyProvider
{
ThemeResourceKey Provide(string reportPart);
}

// could watch
[Export(typeof(IThemeResourceKeyProvider))]
internal class ThemeResourceKeyProvider : IThemeResourceKeyProvider
{
private XElement root;
public ThemeResourceKeyProvider()
{
var fccExtensionsDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var fccResourcesDirectory = Path.Combine(fccExtensionsDirectory, "Resources");
var reportPartsPath = Path.Combine(fccResourcesDirectory, "reportparts.xml");
root = XElement.Load(reportPartsPath);
}
public ThemeResourceKey Provide(string reportPart)
{
var matchingElement = root.Elements("ReportPart").First(reportPartElement => reportPartElement.Attribute("Name").Value == reportPart);
if (matchingElement != null)
{
// probably should change the attribute name
var themeResourceKeyString = matchingElement.Attribute("SelectedThemeColourName").Value;
var parts = themeResourceKeyString.Split('.');
if(parts.Length == 2 && !String.IsNullOrWhiteSpace(parts[1]))
{
var @class = parts[0];
Type classType = null;
switch (@class)
{
case "EnvironmentColors":
classType = typeof(EnvironmentColors);
break;
case "CommonControlsColors":
classType = typeof(CommonControlsColors);
break;
}
if(classType != null)
{
//try ?
var themeResourceKeyProperty = classType.GetProperty(parts[1], BindingFlags.Public | BindingFlags.Static);
if(themeResourceKeyProperty != null)
{
return themeResourceKeyProperty.GetValue(null) as ThemeResourceKey;
}
}
}
}
return null;
}
}

[Export(typeof(IReportColoursProvider))]
internal class ReportColoursProvider : IReportColoursProvider
{
Expand Down
80 changes: 39 additions & 41 deletions SharedProject/Core/ReportGenerator/ReportGeneratorUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public void Initialize(string appDataFolder)

public async Task<ReportGeneratorResult> GenerateAsync(IEnumerable<string> coverOutputFiles, string reportOutputFolder, bool throwError = false)
{
var darkMode = false;
var title = "ReportGenerator Run";

var unifiedHtmlFile = Path.Combine(reportOutputFolder, "index.html");
Expand Down Expand Up @@ -181,7 +180,7 @@ async Task<bool> run(string outputReportType, string inputReports)

}

private void SetInitialStyle(HtmlAgilityPack.HtmlDocument document)
private void SetInitialTheme(HtmlAgilityPack.HtmlDocument document)
{

var backgroundColor = ToJsColour(reportColours.BackgroundColour);
Expand Down Expand Up @@ -277,7 +276,7 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo


doc.LoadHtml(htmlForProcessing);
SetInitialStyle(doc);
SetInitialTheme(doc);
htmlForProcessing = null;

doc.DocumentNode.QuerySelectorAll(".footer").ToList().ForEach(x => x.SetAttributeValue("style", "display:none"));
Expand Down Expand Up @@ -374,8 +373,8 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo
table,tr,th,td {{ font-size: small; }}
body {{ -webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none }}
table.overview th, table.overview td {{ font-size: small; white-space: nowrap; word-break: normal; padding-left:10px;padding-right:10px; }}
coverage-info div.customizebox div:nth-child(2) {{ opacity:0;font-size:1px;height:1px;padding:0;border:0;margin:0 }} */
coverage-info div.customizebox div:nth-child(2) * {{ opacity:0;font-size:1px;height:1px;padding:0;border:0;margin:0 }} */
coverage-info div.customizebox div:nth-child(2) {{ visibility:hidden;font-size:1px;height:1px;padding:0;border:0;margin:0 }}
coverage-info div.customizebox div:nth-child(2) * {{ visibility:hidden;font-size:1px;height:1px;padding:0;border:0;margin:0 }}
table,tr,th,td {{ border: 1px solid; font-size: small; }}
input[type=text] {{ color:{ToJsColour(reportColours.TextBoxTextColour)}; background-color:{ToJsColour(reportColours.TextBoxColour)};border-color:{ToJsColour(reportColours.TextBoxBorderColour)} }}
select {{ color:{ToJsColour(reportColours.ComboBoxTextColour)}; background-color:{ToJsColour(reportColours.ComboBoxColour)};border-color:{ToJsColour(reportColours.ComboBoxBorderColour)} }}
Expand Down Expand Up @@ -405,79 +404,79 @@ function getStyleSheetById(id){{
}}
}}
}}
function {ThemeChangedJSFunctionName}(colours){{
function {ThemeChangedJSFunctionName}(theme){{
var fccMediaStylesheet = getStyleSheetById('fccMediaStyle');
var highContrastRule = fccMediaStylesheet.cssRules[1]
var highContrastRules = highContrastRule.cssRules
getStyleBySelector(highContrastRules,'table.coverage > td.gray').setProperty('background-color',colours.{nameof(JsThemeStyling.GrayCoverage)});
getStyleBySelector(highContrastRules,'table.coverage > td.gray').setProperty('background-color',theme.{nameof(JsThemeStyling.GrayCoverage)});

var fccStyleSheet1Rules = getStyleSheetById('fccStyle1').cssRules;

var scrollBarStyle = getStyleBySelector(fccStyleSheet1Rules,'body, html');
scrollBarStyle.setProperty('scrollbar-arrow-color',colours.{nameof(JsThemeStyling.ScrollBarArrow)});
scrollBarStyle.setProperty('scrollbar-track-color',colours.{nameof(JsThemeStyling.ScrollBarTrack)});
scrollBarStyle.setProperty('scrollbar-face-color',colours.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-shadow-color',colours.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-highlight-color',colours.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-3dlight-color',colours.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-darkshadow-color',colours.{nameof(JsThemeStyling.ScrollBarThumb)});

getStyleBySelector(fccStyleSheet1Rules,'*, body').setProperty('color',colours.{nameof(JsThemeStyling.FontColour)});
scrollBarStyle.setProperty('scrollbar-arrow-color',theme.{nameof(JsThemeStyling.ScrollBarArrow)});
scrollBarStyle.setProperty('scrollbar-track-color',theme.{nameof(JsThemeStyling.ScrollBarTrack)});
scrollBarStyle.setProperty('scrollbar-face-color',theme.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-shadow-color',theme.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-highlight-color',theme.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-3dlight-color',theme.{nameof(JsThemeStyling.ScrollBarThumb)});
scrollBarStyle.setProperty('scrollbar-darkshadow-color',theme.{nameof(JsThemeStyling.ScrollBarThumb)});

getStyleBySelector(fccStyleSheet1Rules,'*, body').setProperty('color',theme.{nameof(JsThemeStyling.FontColour)});
var textStyle = getStyleBySelector(fccStyleSheet1Rules,'input[type=text]');
textStyle.setProperty('color',colours.{nameof(JsThemeStyling.TextBoxTextColour)});
textStyle.setProperty('background-color',colours.{nameof(JsThemeStyling.TextBoxColour)});
textStyle.setProperty('border-color',colours.{nameof(JsThemeStyling.TextBoxBorderColour)});
textStyle.setProperty('color',theme.{nameof(JsThemeStyling.TextBoxTextColour)});
textStyle.setProperty('background-color',theme.{nameof(JsThemeStyling.TextBoxColour)});
textStyle.setProperty('border-color',theme.{nameof(JsThemeStyling.TextBoxBorderColour)});

var comboStyle = getStyleBySelector(fccStyleSheet1Rules,'select');
comboStyle.setProperty('color',colours.{nameof(JsThemeStyling.ComboBoxText)});
comboStyle.setProperty('background-color',colours.{nameof(JsThemeStyling.ComboBox)});
comboStyle.setProperty('border-color',colours.{nameof(JsThemeStyling.ComboBoxBorder)});
comboStyle.setProperty('color',theme.{nameof(JsThemeStyling.ComboBoxText)});
comboStyle.setProperty('background-color',theme.{nameof(JsThemeStyling.ComboBox)});
comboStyle.setProperty('border-color',theme.{nameof(JsThemeStyling.ComboBoxBorder)});

var fccStyleSheet2Rules = getStyleSheetById('fccStyle2').cssRules;
getStyleBySelector(fccStyleSheet2Rules,'#divHeader').setProperty('background-color',colours.{nameof(JsThemeStyling.DivHeaderBackgroundColour)});
getStyleBySelector(fccStyleSheet2Rules,'#divHeader').setProperty('background-color',theme.{nameof(JsThemeStyling.DivHeaderBackgroundColour)});
var headerTabsStyle = getStyleBySelector(fccStyleSheet2Rules,'table#headerTabs td');
headerTabsStyle.setProperty('color',colours.{nameof(JsThemeStyling.HeaderFontColour)});
headerTabsStyle.setProperty('border-color',colours.{nameof(JsThemeStyling.HeaderBorderColour)});
getStyleBySelector(fccStyleSheet2Rules,'table#headerTabs td.tab').setProperty('background-color',colours.{nameof(JsThemeStyling.TabBackgroundColour)});
headerTabsStyle.setProperty('color',theme.{nameof(JsThemeStyling.HeaderFontColour)});
headerTabsStyle.setProperty('border-color',theme.{nameof(JsThemeStyling.HeaderBorderColour)});
getStyleBySelector(fccStyleSheet2Rules,'table#headerTabs td.tab').setProperty('background-color',theme.{nameof(JsThemeStyling.TabBackgroundColour)});

var mainStyle = document.styleSheets[0];
var mainRules = mainStyle.cssRules;

getStyleBySelector(mainRules,'.gray').setProperty('background-color',colours.{nameof(JsThemeStyling.GrayCoverage)});
getStyleBySelector(mainRules,'.gray').setProperty('background-color',theme.{nameof(JsThemeStyling.GrayCoverage)});

getStyleBySelector(mainRules,'html').setProperty('background-color',colours.{nameof(JsThemeStyling.BackgroundColour)});
getStyleBySelector(mainRules,'.container').setProperty('background-color',colours.{nameof(JsThemeStyling.BackgroundColour)});
getStyleBySelector(mainRules,'html').setProperty('background-color',theme.{nameof(JsThemeStyling.BackgroundColour)});
getStyleBySelector(mainRules,'.container').setProperty('background-color',theme.{nameof(JsThemeStyling.BackgroundColour)});

var overviewTableBorder = '1px solid ' + colours.{nameof(JsThemeStyling.TableBorderColour)};
var overviewTableBorder = '1px solid ' + theme.{nameof(JsThemeStyling.TableBorderColour)};
var overviewStyle = getStyleBySelector(mainRules,'.overview');
overviewStyle.setProperty('border',overviewTableBorder);
var overviewThStyle = getStyleBySelector(mainRules,'.overview th');
overviewThStyle.setProperty('background-color',colours.{nameof(JsThemeStyling.BackgroundColour)});
overviewThStyle.setProperty('background-color',theme.{nameof(JsThemeStyling.BackgroundColour)});
overviewThStyle.setProperty('border',overviewTableBorder);
var overviewTdStyle = getStyleBySelector(mainRules,'.overview td');
overviewTdStyle.setProperty('border',overviewTableBorder);

var overviewHeaderLinksStyle = getStyleBySelector(mainRules,'.overview th a');
overviewHeaderLinksStyle.setProperty('color',colours.{nameof(JsThemeStyling.CoverageTableHeaderFontColour)});
overviewHeaderLinksStyle.setProperty('color',theme.{nameof(JsThemeStyling.CoverageTableHeaderFontColour)});

var overviewTrHoverStyle = getStyleBySelector(mainRules,'.overview tr:hover');
overviewTrHoverStyle.setProperty('background',colours.{nameof(JsThemeStyling.CoverageTableRowHoverBackgroundColour)});
overviewTrHoverStyle.setProperty('background',theme.{nameof(JsThemeStyling.CoverageTableRowHoverBackgroundColour)});

var linkStyle = getStyleBySelector(mainRules,'a');
var linkHoverStyle = getStyleBySelector(mainRules,'a:hover');
linkStyle.setProperty('color',colours.{nameof(JsThemeStyling.LinkColour)});
linkHoverStyle.setProperty('color',colours.{nameof(JsThemeStyling.LinkColour)});
linkStyle.setProperty('color',theme.{nameof(JsThemeStyling.LinkColour)});
linkHoverStyle.setProperty('color',theme.{nameof(JsThemeStyling.LinkColour)});

var iconPlusStyle = getStyleBySelector(mainRules,'.icon-plus');
iconPlusStyle.setProperty('background-image',colours.{nameof(JsThemeStyling.PlusBase64)});
iconPlusStyle.setProperty('background-image',theme.{nameof(JsThemeStyling.PlusBase64)});
var iconMinusStyle = getStyleBySelector(mainRules,'.icon-minus');
iconMinusStyle.setProperty('background-image',colours.{nameof(JsThemeStyling.MinusBase64)});
iconMinusStyle.setProperty('background-image',theme.{nameof(JsThemeStyling.MinusBase64)});
var iconDownActiveStyle = getStyleBySelector(mainRules,'.icon-down-dir_active');
iconDownActiveStyle.setProperty('background-image',colours.{nameof(JsThemeStyling.DownActiveBase64)});
iconDownActiveStyle.setProperty('background-image',theme.{nameof(JsThemeStyling.DownActiveBase64)});
var iconDownInactiveStyle = getStyleBySelector(mainRules,'.icon-down-dir');
iconDownInactiveStyle.setProperty('background-image',colours.{nameof(JsThemeStyling.DownInactiveBase64)});
iconDownInactiveStyle.setProperty('background-image',theme.{nameof(JsThemeStyling.DownInactiveBase64)});
var iconUpActiveStyle = getStyleBySelector(mainRules,'.icon-up-dir_active');
iconUpActiveStyle.setProperty('background-image',colours.{nameof(JsThemeStyling.UpActiveBase64)});
iconUpActiveStyle.setProperty('background-image',theme.{nameof(JsThemeStyling.UpActiveBase64)});
}}
var htmlExtension = '.html';

Expand Down Expand Up @@ -528,7 +527,6 @@ function getStyleSheetById(id){{

htmlSb.Replace("</head>", $@"
<style type=""text/css"" id='fccMediaStyle'>
table.overview.table-fixed.stripped > thead > tr > th:nth-of-type(4) > a:nth-of-type(2) {{ display: none; }}
@media screen and (-ms-high-contrast:active){{
table.coverage > td.green{{ background-color: windowText }}
table.coverage > td.gray{{
Expand Down
Loading