コード例 #1
0
 public ReportColoursProvider(
     IThemeResourceKeyProvider themeResourceKeyProvider
     )
 {
     this.themeResourceKeyProvider = themeResourceKeyProvider;
     lastReportColours             = GetReportColours();
     VSColorTheme.ThemeChanged    += VSColorTheme_ThemeChanged;
 }
コード例 #2
0
        private void VSColorTheme_ThemeChanged(ThemeChangedEventArgs e)
        {
            var newColours = GetReportColours();

            if (lastReportColours == null || !SameColours(lastReportColours, newColours))
            {
                lastReportColours = newColours;
                ColoursChanged?.Invoke(this, newColours);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }