public ReportColoursProvider(
     IThemeResourceKeyProvider themeResourceKeyProvider
     )
 {
     this.themeResourceKeyProvider = themeResourceKeyProvider;
     lastReportColours             = GetReportColours();
     VSColorTheme.ThemeChanged    += VSColorTheme_ThemeChanged;
 }
        private void VSColorTheme_ThemeChanged(ThemeChangedEventArgs e)
        {
            var newColours = GetReportColours();

            if (lastReportColours == null || !SameColours(lastReportColours, newColours))
            {
                lastReportColours = newColours;
                ColoursChanged?.Invoke(this, newColours);
            }
        }
        private ReportColours GetReportColours()
        {
            var reportColours = new ReportColours();

            foreach (var propertyInfo in propertyInfos)
            {
                var color = VSColorTheme.GetThemedColor(themeResourceKeyProvider.Provide(propertyInfo.Name));
                propertyInfo.SetValue(reportColours, color);
            }
            return(reportColours);
        }
        private static bool SameColours(ReportColours oldColours, ReportColours newColours)
        {
            var same = true;

            foreach (var propertyInfo in propertyInfos)
            {
                var oldColor = (Color)propertyInfo.GetValue(oldColours);
                var newColor = (Color)propertyInfo.GetValue(newColours);
                same = oldColor.ToString() == newColor.ToString();
                if (!same)
                {
                    break;
                }
            }
            return(same);
        }