Example #1
0
        public ColorSchemeApplier(
            IThreadingContext threadingContext,
            IGlobalOptionService globalOptions,
            [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
            : base(threadingContext)
        {
            _serviceProvider = serviceProvider;

            _settings               = new ColorSchemeSettings(_serviceProvider, globalOptions);
            _colorSchemes           = _settings.GetColorSchemes();
            _classificationVerifier = new ClassificationVerifier(threadingContext, serviceProvider, _colorSchemes);

            _colorSchemeRegistryItems = new AsyncLazy <ImmutableDictionary <SchemeName, ImmutableArray <RegistryItem> > >(GetColorSchemeRegistryItemsAsync, cacheResult: true);
        }
        public ColorSchemeApplier(
            IThreadingContext threadingContext,
            VisualStudioWorkspace visualStudioWorkspace,
            [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
            : base(threadingContext)
        {
            _serviceProvider = serviceProvider;

            _settings       = new ColorSchemeSettings(_serviceProvider, visualStudioWorkspace);
            _colorSchemes   = _settings.GetColorSchemes();
            _colorDefaulter = new ForegroundColorDefaulter(threadingContext, serviceProvider, _settings, _colorSchemes);

            _colorSchemeRegistryItems = new AsyncLazy <ImmutableDictionary <SchemeName, ImmutableArray <RegistryItem> > >(GetColorSchemeRegistryItemsAsync, cacheResult: true);
        }
            public ForegroundColorDefaulter(IThreadingContext threadingContext, IServiceProvider serviceProvider, ColorSchemeSettings settings, ImmutableDictionary <SchemeName, ColorScheme> colorSchemes)
                : base(threadingContext)
            {
                _serviceProvider = serviceProvider;
                _settings        = settings;

                // Convert colors schemes into an array of theme dictionaries which contain classification dictionaries of colors.
                _colorSchemes = colorSchemes.Values.Select(
                    scheme => scheme.Themes.ToImmutableDictionary(
                        theme => theme.Guid,
                        theme => theme.Category.Colors
                        .Where(color => color.Foreground.HasValue)
                        .ToImmutableDictionary(
                            color => color.Name,
                            color => color.Foreground !.Value)))
                                .ToImmutableArray();

                // Gather all the classifications from the core and scheme dictionaries.
                var coreClassifications        = DarkThemeForeground.Keys.Concat(BlueLightThemeForeground.Keys).Distinct();
                var colorSchemeClassifications = _colorSchemes.SelectMany(scheme => scheme.Values.SelectMany(theme => theme.Keys)).Distinct();

                Classifications = coreClassifications.Concat(colorSchemeClassifications).ToImmutableArray();
            }