public PrintfColorManager(ThemeManager themeManager, IEditorFormatMapService editorFormatMapService)
        {
            _themeManager           = themeManager;
            _editorFormatMapService = editorFormatMapService;

            _currentTheme = _themeManager.GetCurrentTheme();
        }
コード例 #2
0
        public void UpdateColors()
        {
            var currentTheme = _themeManager.GetCurrentTheme();

            if (currentTheme == VisualStudioTheme.Unknown || currentTheme == _lastTheme)
                return;

            _lastTheme = currentTheme;

            var colors = _themeColors[currentTheme];
            var formatMap = _classificationFormatMapService.GetClassificationFormatMap("text");

            try
            {
                formatMap.BeginBatchUpdate();
                foreach (var pair in colors)
                {
                    var type = pair.Key;
                    var color = pair.Value;

                    var classificationType = _classificationTypeRegistryService.GetClassificationType(type);

                    var props = formatMap.GetTextProperties(classificationType);
                    props = props.SetForeground(color);

                    formatMap.SetTextProperties(classificationType, props);
                }
            }
            finally
            {
                formatMap.EndBatchUpdate();
            }
        }
コード例 #3
0
        public void UpdateColors()
        {
            var currentTheme = _themeManager.GetCurrentTheme();

            if (currentTheme == VisualStudioTheme.Unknown || currentTheme == _lastTheme)
            {
                return;
            }

            _lastTheme = currentTheme;

            var colors    = _themeColors[currentTheme];
            var formatMap = _classificationFormatMapService.GetClassificationFormatMap("text");

            try
            {
                formatMap.BeginBatchUpdate();
                foreach (var pair in colors)
                {
                    var type  = pair.Key;
                    var color = pair.Value;

                    var classificationType = _classificationTypeRegistryService.GetClassificationType(type);

                    var props = formatMap.GetTextProperties(classificationType);
                    props = props.SetForeground(color);

                    formatMap.SetTextProperties(classificationType, props);
                }
            }
            finally
            {
                formatMap.EndBatchUpdate();
            }
        }
コード例 #4
0
        public ClassificationColorManager(ThemeManager themeManager,
                                          IClassificationFormatMapService classificationFormatMapService,
                                          IClassificationTypeRegistryService classificationTypeRegistryService)
        {
            _themeManager = themeManager;
            _classificationFormatMapService    = classificationFormatMapService;
            _classificationTypeRegistryService = classificationTypeRegistryService;
            _themeColors = new Dictionary <VisualStudioTheme, IDictionary <string, Color> >();
            _lastTheme   = VisualStudioTheme.Unknown;

            // Light / Blue theme colors
            var lightAndBlueColors = new Dictionary <string, Color>
            {
                { SemanticClassificationMetadata.PunctuationClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.SemanticClassificationTypeName, Color.FromRgb(85, 107, 47) },
                { SemanticClassificationMetadata.PackOffsetClassificationTypeName, Colors.Purple },
                { SemanticClassificationMetadata.RegisterLocationClassificationTypeName, Colors.LightCoral },
                { SemanticClassificationMetadata.NamespaceClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.GlobalVariableClassificationTypeName, Color.FromRgb(72, 61, 139) },
                { SemanticClassificationMetadata.FieldIdentifierClassificationTypeName, Color.FromRgb(139, 0, 139) },
                { SemanticClassificationMetadata.LocalVariableClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.ConstantBufferVariableClassificationTypeName, Color.FromRgb(72, 61, 139) },
                { SemanticClassificationMetadata.ParameterClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.FunctionClassificationTypeName, Color.FromRgb(0, 139, 139) },
                { SemanticClassificationMetadata.MethodClassificationTypeName, Color.FromRgb(0, 139, 139) },
                { SemanticClassificationMetadata.ClassIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) },
                { SemanticClassificationMetadata.StructIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) },
                { SemanticClassificationMetadata.InterfaceIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) },
                { SemanticClassificationMetadata.ConstantBufferIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) }
            };

            _themeColors.Add(VisualStudioTheme.Blue, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Light, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Unknown, lightAndBlueColors);

            // Dark theme colors

            var darkColors = new Dictionary <string, Color>
            {
                { SemanticClassificationMetadata.PunctuationClassificationTypeName, Colors.White },
                { SemanticClassificationMetadata.SemanticClassificationTypeName, Color.FromRgb(144, 238, 144) },
                { SemanticClassificationMetadata.PackOffsetClassificationTypeName, Colors.Pink },
                { SemanticClassificationMetadata.RegisterLocationClassificationTypeName, Colors.LightCoral },
                { SemanticClassificationMetadata.NamespaceClassificationTypeName, Colors.White },
                { SemanticClassificationMetadata.GlobalVariableClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.FieldIdentifierClassificationTypeName, Color.FromRgb(221, 160, 221) },
                { SemanticClassificationMetadata.LocalVariableClassificationTypeName, Color.FromRgb(220, 220, 220) },
                { SemanticClassificationMetadata.ConstantBufferVariableClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.ParameterClassificationTypeName, Color.FromRgb(220, 220, 220) },
                { SemanticClassificationMetadata.FunctionClassificationTypeName, Color.FromRgb(0, 255, 255) },
                { SemanticClassificationMetadata.MethodClassificationTypeName, Color.FromRgb(0, 255, 255) },
                { SemanticClassificationMetadata.ClassIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.StructIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.InterfaceIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.ConstantBufferIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) }
            };

            _themeColors.Add(VisualStudioTheme.Dark, darkColors);
        }
コード例 #5
0
        public ClassificationColorManager(ThemeManager themeManager,
            IClassificationFormatMapService classificationFormatMapService,
            IClassificationTypeRegistryService classificationTypeRegistryService)
        {
            _themeManager = themeManager;
            _classificationFormatMapService = classificationFormatMapService;
            _classificationTypeRegistryService = classificationTypeRegistryService;
            _themeColors = new Dictionary<VisualStudioTheme, IDictionary<string, Color>>();
            _lastTheme = VisualStudioTheme.Unknown;

            // Light / Blue theme colors
            var lightAndBlueColors = new Dictionary<string, Color>
            {
                { SemanticClassificationMetadata.PunctuationClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.SemanticClassificationTypeName, Color.FromRgb(85, 107, 47) },
                { SemanticClassificationMetadata.PackOffsetClassificationTypeName, Colors.Purple },
                { SemanticClassificationMetadata.RegisterLocationClassificationTypeName, Colors.LightCoral },
                { SemanticClassificationMetadata.NamespaceClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.GlobalVariableClassificationTypeName, Color.FromRgb(72, 61, 139) },
                { SemanticClassificationMetadata.FieldIdentifierClassificationTypeName, Color.FromRgb(139, 0, 139) },
                { SemanticClassificationMetadata.LocalVariableClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.ConstantBufferVariableClassificationTypeName, Color.FromRgb(72, 61, 139) },
                { SemanticClassificationMetadata.ParameterClassificationTypeName, Colors.Black },
                { SemanticClassificationMetadata.FunctionClassificationTypeName, Color.FromRgb(0, 139, 139) },
                { SemanticClassificationMetadata.MethodClassificationTypeName, Color.FromRgb(0, 139, 139) },
                { SemanticClassificationMetadata.ClassIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) },
                { SemanticClassificationMetadata.StructIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) },
                { SemanticClassificationMetadata.InterfaceIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) },
                { SemanticClassificationMetadata.ConstantBufferIdentifierClassificationTypeName, Color.FromRgb(0, 0, 139) }
            };

            _themeColors.Add(VisualStudioTheme.Blue, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Light, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Unknown, lightAndBlueColors);

            // Dark theme colors

            var darkColors = new Dictionary<string, Color>
            {
                { SemanticClassificationMetadata.PunctuationClassificationTypeName, Colors.White },
                { SemanticClassificationMetadata.SemanticClassificationTypeName, Color.FromRgb(144, 238, 144) },
                { SemanticClassificationMetadata.PackOffsetClassificationTypeName, Colors.Pink },
                { SemanticClassificationMetadata.RegisterLocationClassificationTypeName, Colors.LightCoral },
                { SemanticClassificationMetadata.NamespaceClassificationTypeName, Colors.White },
                { SemanticClassificationMetadata.GlobalVariableClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.FieldIdentifierClassificationTypeName, Color.FromRgb(221, 160, 221) },
                { SemanticClassificationMetadata.LocalVariableClassificationTypeName, Color.FromRgb(220, 220, 220) },
                { SemanticClassificationMetadata.ConstantBufferVariableClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.ParameterClassificationTypeName, Color.FromRgb(220, 220, 220) },
                { SemanticClassificationMetadata.FunctionClassificationTypeName, Color.FromRgb(0, 255, 255) },
                { SemanticClassificationMetadata.MethodClassificationTypeName, Color.FromRgb(0, 255, 255) },
                { SemanticClassificationMetadata.ClassIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.StructIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.InterfaceIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) },
                { SemanticClassificationMetadata.ConstantBufferIdentifierClassificationTypeName, Color.FromRgb(173, 216, 230) }
            };

            _themeColors.Add(VisualStudioTheme.Dark, darkColors);
        }
コード例 #6
0
        public NShaderColorableItem(VisualStudioTheme theme, string name, string displayName, COLORINDEX foreColorLight, COLORINDEX foreColorDark, COLORINDEX backColor, Color hiForeColorLight, Color hiForeColorDark, Color hiBackColor, FONTFLAGS fontFlags)
            : base(name, displayName, theme == VisualStudioTheme.Dark ? foreColorDark : foreColorLight, backColor, theme == VisualStudioTheme.Dark ? hiForeColorDark : hiForeColorLight, hiBackColor, fontFlags)
        {
            ForeColorLight = foreColorLight;
            ForeColorDark  = foreColorDark;

            HiForeColorLight = hiForeColorLight;
            HiForeColorDark  = hiForeColorDark;
        }
コード例 #7
0
        public NShaderColorableItem(VisualStudioTheme theme, string name, string displayName, COLORINDEX foreColorLight, COLORINDEX foreColorDark, COLORINDEX backColor, Color hiForeColorLight, Color hiForeColorDark, Color hiBackColor, FONTFLAGS fontFlags)
            : base(name, displayName, theme == VisualStudioTheme.Dark ? foreColorDark : foreColorLight, backColor, theme == VisualStudioTheme.Dark ? hiForeColorDark : hiForeColorLight,  hiBackColor, fontFlags)
        {
            ForeColorLight = foreColorLight;
            ForeColorDark = foreColorDark;

            HiForeColorLight = hiForeColorLight;
            HiForeColorDark = hiForeColorDark;
        }
コード例 #8
0
        public ClassificationColorManager(
            ThemeManager themeManager,
            IClassificationFormatMapService classificationFormatMapService,
            IClassificationTypeRegistryService classificationTypeRegistry)
        {
            _themeManager = themeManager;
            _classificationFormatMapService = classificationFormatMapService;
            _classificationTypeRegistry     = classificationTypeRegistry;

            // Theme changed event may fire even though the same theme is still in use.
            // We save a current theme and skip color updates in these cases.
            _currentTheme = _themeManager.GetCurrentTheme();
        }
コード例 #9
0
        private void UpdateColors()
        {
            var theme = themeEngine.GetCurrentTheme();

            // Did theme change?
            if (theme != currentTheme)
            {
                currentTheme = theme;

                var colors = themeColors[theme];
                var formatMap = classificationFormatMapService.GetClassificationFormatMap(ClassificationCategory);

                // TODO: It seems this approach doesn't update Fonts & Colors settings
                try
                {
                    formatMap.BeginBatchUpdate();
                    foreach (var pair in colors)
                    {
                        string type = pair.Key;
                        var color = pair.Value;

                        var classificationType = classificationTypeRegistry.GetClassificationType(type);
                        var oldProp = formatMap.GetTextProperties(classificationType);

                        var foregroundBrush =
                            color.ForegroundColor == null
                                ? null
                                : new SolidColorBrush(color.ForegroundColor.Value);

                        var backgroundBrush =
                            color.BackgroundColor == null
                                ? null
                                : new SolidColorBrush(color.BackgroundColor.Value);

                        var newProp = TextFormattingRunProperties.CreateTextFormattingRunProperties(
                            foregroundBrush, backgroundBrush, oldProp.Typeface, null, null, oldProp.TextDecorations,
                            oldProp.TextEffects, oldProp.CultureInfo);

                        formatMap.SetTextProperties(classificationType, newProp);
                    }
                }
                finally
                {
                    formatMap.EndBatchUpdate();
                }
            }
        }
コード例 #10
0
        private void UpdateColors()
        {
            var theme = themeEngine.GetCurrentTheme();

            // Did theme change?
            if (theme != currentTheme)
            {
                currentTheme = theme;

                var colors    = themeColors[theme];
                var formatMap = classificationFormatMapService.GetClassificationFormatMap(ClassificationCategory);

                // TODO: It seems this approach doesn't update Fonts & Colors settings
                try
                {
                    formatMap.BeginBatchUpdate();
                    foreach (var pair in colors)
                    {
                        string type  = pair.Key;
                        var    color = pair.Value;

                        var classificationType = classificationTypeRegistry.GetClassificationType(type);
                        var oldProp            = formatMap.GetTextProperties(classificationType);

                        var foregroundBrush =
                            color.ForegroundColor == null
                                ? null
                                : new SolidColorBrush(color.ForegroundColor.Value);

                        var backgroundBrush =
                            color.BackgroundColor == null
                                ? null
                                : new SolidColorBrush(color.BackgroundColor.Value);

                        var newProp = TextFormattingRunProperties.CreateTextFormattingRunProperties(
                            foregroundBrush, backgroundBrush, oldProp.Typeface, null, null, oldProp.TextDecorations,
                            oldProp.TextEffects, oldProp.CultureInfo);

                        formatMap.SetTextProperties(classificationType, newProp);
                    }
                }
                finally
                {
                    formatMap.EndBatchUpdate();
                }
            }
        }
コード例 #11
0
        public void UpdateColors()
        {
            var newTheme = _themeManager.GetCurrentTheme();

            if (newTheme != VisualStudioTheme.Unknown && newTheme != _currentTheme)
            {
                _currentTheme = newTheme;

                var colors    = newTheme == VisualStudioTheme.Dark ? DarkColors : LightAndBlueColors;
                var formatMap = _classificationFormatMapService.GetClassificationFormatMap(category: "text");

                try
                {
                    formatMap.BeginBatchUpdate();
                    foreach (var pair in colors)
                    {
                        string    type  = pair.Key;
                        FontColor color = pair.Value;

                        var classificationType = _classificationTypeRegistry.GetClassificationType(type);
                        var oldProp            = formatMap.GetTextProperties(classificationType);

                        var foregroundBrush =
                            color.Foreground == null
                                ? null
                                : new SolidColorBrush(color.Foreground.Value);

                        var backgroundBrush =
                            color.Background == null
                                ? null
                                : new SolidColorBrush(color.Background.Value);

                        var newProp = TextFormattingRunProperties.CreateTextFormattingRunProperties(
                            foregroundBrush, backgroundBrush, oldProp.Typeface, null, null, oldProp.TextDecorations,
                            oldProp.TextEffects, oldProp.CultureInfo);

                        formatMap.SetTextProperties(classificationType, newProp);
                    }
                }
                finally
                {
                    formatMap.EndBatchUpdate();
                }
            }
        }
コード例 #12
0
        private void UpdateColors()
        {
            var theme = themeEngine.GetCurrentTheme();

            // Did theme change?
            if (theme != currentTheme)
            {
                currentTheme = theme;
                var colors = themeColors[theme];

                if (fontAndColorStorage != null && fontAndColorUtilities != null)
                {
                    if (fontAndColorStorage.OpenCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory, (uint)(__FCSTORAGEFLAGS.FCSF_LOADDEFAULTS | __FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES)) == VSConstants.S_OK)
                    {
                        try
                        {
                            foreach (var pair in colors)
                            {
                                var colorInfos = new ColorableItemInfo[1];
                                if (fontAndColorStorage.GetItem(pair.Key, colorInfos) == VSConstants.S_OK)
                                {
                                    if (pair.Value.ForegroundColor != null)
                                    {
                                        colorInfos[0].crForeground = (uint)(pair.Value.ForegroundColor.Value.R | (pair.Value.ForegroundColor.Value.G << 8) | (pair.Value.ForegroundColor.Value.B << 16));
                                    }

                                    if (pair.Value.BackgroundColor != null)
                                    {
                                        colorInfos[0].crBackground = (uint)(pair.Value.BackgroundColor.Value.R | (pair.Value.BackgroundColor.Value.G << 8) | (pair.Value.BackgroundColor.Value.B << 16));
                                    }

                                    fontAndColorStorage.SetItem(pair.Key, colorInfos);
                                }
                            }
                        }
                        finally
                        {
                            fontAndColorStorage.CloseCategory();
                        }
                    }
                }
            }
        }
コード例 #13
0
        protected ClassificationColorManagerBase(ThemeManager themeManager,
            IClassificationFormatMapService classificationFormatMapService,
            IClassificationTypeRegistryService classificationTypeRegistryService)
        {
            _themeManager = themeManager;
            _classificationFormatMapService = classificationFormatMapService;
            _classificationTypeRegistryService = classificationTypeRegistryService;
            _themeColors = new Dictionary<VisualStudioTheme, IDictionary<string, Color>>();
            _lastTheme = VisualStudioTheme.Unknown;

            // Light / Blue theme colors
            var lightAndBlueColors = CreateLightAndBlueColors();
            _themeColors.Add(VisualStudioTheme.Blue, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Light, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Unknown, lightAndBlueColors);

            // Dark theme colors

            var darkColors = CreateDarkColors();
            _themeColors.Add(VisualStudioTheme.Dark, darkColors);
        }
コード例 #14
0
        public ClassificationColorManager(
            ThemeManager themeManager,
            IClassificationFormatMapService classificationFormatMapService,
            IClassificationTypeRegistryService classificationTypeRegistryService,
            [ImportMany] IEnumerable <IClassificationColorProvider> classificationColorProviders)
        {
            _themeManager = themeManager;
            _classificationFormatMapService    = classificationFormatMapService;
            _classificationTypeRegistryService = classificationTypeRegistryService;
            _lastTheme = VisualStudioTheme.Unknown;

            var themeColors = ImmutableDictionary <VisualStudioTheme, ImmutableDictionary <string, Color> > .Empty.ToBuilder();

            void addToThemeColors(VisualStudioTheme theme, ImmutableDictionary <string, Color> newColors)
            {
                if (!themeColors.TryGetValue(theme, out var colors))
                {
                    colors = ImmutableDictionary <string, Color> .Empty;
                }

                colors = colors.AddRange(newColors);

                themeColors[theme] = colors;
            }

            foreach (var colorProvider in classificationColorProviders)
            {
                // Light / Blue theme colors
                var lightAndBlueColors = colorProvider.LightAndBlueColors;
                addToThemeColors(VisualStudioTheme.Blue, lightAndBlueColors);
                addToThemeColors(VisualStudioTheme.Light, lightAndBlueColors);
                addToThemeColors(VisualStudioTheme.Unknown, lightAndBlueColors);

                // Dark theme colors
                var darkColors = colorProvider.DarkColors;
                addToThemeColors(VisualStudioTheme.Dark, darkColors);
            }

            _themeColors = themeColors.ToImmutable();
        }
コード例 #15
0
        public void UpdateColors()
        {
            var currentTheme = _themeManager.GetCurrentTheme();

            if (currentTheme == VisualStudioTheme.Unknown || currentTheme == _lastTheme)
            {
                return;
            }

            _lastTheme = currentTheme;

            var colors    = _themeColors[currentTheme];
            var formatMap = _classificationFormatMapService.GetClassificationFormatMap(category: "text");

            try
            {
                formatMap.BeginBatchUpdate();
                foreach (var pair in colors)
                {
                    var type  = pair.Key;
                    var color = pair.Value;

                    var classificationType = _classificationTypeRegistryService.GetClassificationType(type);
                    var oldProp            = formatMap.GetTextProperties(classificationType);

                    var brush = new SolidColorBrush(color);

                    var newProp = TextFormattingRunProperties.CreateTextFormattingRunProperties(
                        brush, null, oldProp.Typeface, null, null, oldProp.TextDecorations,
                        oldProp.TextEffects, oldProp.CultureInfo);

                    formatMap.SetTextProperties(classificationType, newProp);
                }
            }
            finally
            {
                formatMap.EndBatchUpdate();
            }
        }
        public void UpdateColors()
        {
            var newTheme = _themeManager.GetCurrentTheme();

            if (newTheme != VisualStudioTheme.Unknown && newTheme != _currentTheme)
            {
                _currentTheme = newTheme;
                var formatMap = _editorFormatMapService.GetEditorFormatMap(category: "text");

                try
                {
                    formatMap.BeginBatchUpdate();
                    var dict = formatMap.GetProperties(Constants.fsharpPrintfTagType);
                    dict["BackgroundColor"] = GetDefaultColor();
                    formatMap.SetProperties(Constants.fsharpPrintfTagType, dict);
                }
                finally
                {
                    formatMap.EndBatchUpdate();
                }
            }
        }
コード例 #17
0
        protected ClassificationColorManagerBase(ThemeManager themeManager,
                                                 IClassificationFormatMapService classificationFormatMapService,
                                                 IClassificationTypeRegistryService classificationTypeRegistryService)
        {
            _themeManager = themeManager;
            _classificationFormatMapService    = classificationFormatMapService;
            _classificationTypeRegistryService = classificationTypeRegistryService;
            _themeColors = new Dictionary <VisualStudioTheme, IDictionary <string, Color> >();
            _lastTheme   = VisualStudioTheme.Unknown;

            // Light / Blue theme colors
            var lightAndBlueColors = CreateLightAndBlueColors();

            _themeColors.Add(VisualStudioTheme.Blue, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Light, lightAndBlueColors);
            _themeColors.Add(VisualStudioTheme.Unknown, lightAndBlueColors);

            // Dark theme colors

            var darkColors = CreateDarkColors();

            _themeColors.Add(VisualStudioTheme.Dark, darkColors);
        }
コード例 #18
0
        public void UpdateColors()
        {
            var currentTheme = _themeManager.GetCurrentTheme();

            if (currentTheme == VisualStudioTheme.Unknown || currentTheme == _lastTheme)
                return;

            _lastTheme = currentTheme;

            var colors = _themeColors[currentTheme];
            var formatMap = _classificationFormatMapService.GetClassificationFormatMap(category: "text");

            try
            {
                formatMap.BeginBatchUpdate();
                foreach (var pair in colors)
                {
                    var type = pair.Key;
                    var color = pair.Value;

                    var classificationType = _classificationTypeRegistryService.GetClassificationType(type);
                    var oldProp = formatMap.GetTextProperties(classificationType);

                    var brush = new SolidColorBrush(color);

                    var newProp = TextFormattingRunProperties.CreateTextFormattingRunProperties(
                        brush, null, oldProp.Typeface, null, null, oldProp.TextDecorations,
                        oldProp.TextEffects, oldProp.CultureInfo);

                    formatMap.SetTextProperties(classificationType, newProp);
                }
            }
            finally
            {
                formatMap.EndBatchUpdate();
            }
        }
コード例 #19
0
        public void UpdateColors()
        {
            var currentTheme = themeManager.GetCurrentTheme();

            if (currentTheme != VisualStudioTheme.Unknown && currentTheme != lastTheme)
            {
                lastTheme = currentTheme;

                IDictionary<string, Color> colors = themeColors[currentTheme];
                IClassificationFormatMap formatMap = classificationFormatMapService.GetClassificationFormatMap(category: "text");

                try
                {
                    formatMap.BeginBatchUpdate();
                    foreach (var pair in colors)
                    {
                        string type = pair.Key;
                        Color color = pair.Value;

                        var classificationType = classificationTypeRegistry.GetClassificationType(type);
                        var oldProp = formatMap.GetTextProperties(classificationType);
                        var newProp = TextFormattingRunProperties.CreateTextFormattingRunProperties(oldProp.Typeface,
                            oldProp.FontRenderingEmSize, color);

                        formatMap.SetTextProperties(classificationType, newProp);
                    }
                }
                finally
                {
                    formatMap.EndBatchUpdate();
                }
            }
        }
コード例 #20
0
 public NShaderColorableItem(VisualStudioTheme theme, string name, string displayName, COLORINDEX foreColorLight, COLORINDEX foreColorDark, COLORINDEX backColor)
     : base(name, displayName, theme == VisualStudioTheme.Dark ? foreColorDark : foreColorLight, backColor, Color.Empty, Color.Empty, FONTFLAGS.FF_DEFAULT)
 {
     ForeColorLight = foreColorLight;
     ForeColorDark = foreColorDark;
 }
コード例 #21
0
 public NShaderColorableItem(VisualStudioTheme theme, string name, COLORINDEX foreColorLight, COLORINDEX foreColorDark, COLORINDEX backColor, FONTFLAGS fontFlags)
     : base(name, name, theme == VisualStudioTheme.Dark ? foreColorDark : foreColorLight, backColor, Color.Empty, Color.Empty, fontFlags)
 {
     ForeColorLight = foreColorLight;
     ForeColorDark = foreColorDark;
 }
コード例 #22
0
        public void UpdateColors()
        {
            var currentTheme = themeManager.GetCurrentTheme();

            if (currentTheme != VisualStudioTheme.Unknown && currentTheme != lastTheme)
            {
                lastTheme = currentTheme;

                var colors = themeColors[currentTheme];
                var formatMap = classificationFormatMapService.GetClassificationFormatMap(category: "text");

                try
                {
                    formatMap.BeginBatchUpdate();
                    foreach (var pair in colors)
                    {
                        string type = pair.Key;
                        FontColor color = pair.Value;

                        var classificationType = classificationTypeRegistry.GetClassificationType(type);
                        var oldProp = formatMap.GetTextProperties(classificationType);

                        var foregroundBrush =
                            color.Foreground == null
                                ? null
                                : new SolidColorBrush(color.Foreground.Value);

                        var backgroundBrush =
                            color.Background == null
                                ? null
                                : new SolidColorBrush(color.Background.Value);

                        var newProp = TextFormattingRunProperties.CreateTextFormattingRunProperties(
                            foregroundBrush, backgroundBrush, oldProp.Typeface, null, null, oldProp.TextDecorations,
                            oldProp.TextEffects, oldProp.CultureInfo);

                        formatMap.SetTextProperties(classificationType, newProp);
                    }
                }
                finally
                {
                    formatMap.EndBatchUpdate();
                }
            }
        }
コード例 #23
0
 public NShaderColorableItem(VisualStudioTheme theme, string name, string displayName, COLORINDEX foreColorLight, COLORINDEX foreColorDark, COLORINDEX backColor)
     : base(name, displayName, theme == VisualStudioTheme.Dark ? foreColorDark : foreColorLight, backColor, Color.Empty, Color.Empty, FONTFLAGS.FF_DEFAULT)
 {
     ForeColorLight = foreColorLight;
     ForeColorDark  = foreColorDark;
 }
コード例 #24
0
 public NShaderColorableItem(VisualStudioTheme theme, string name, COLORINDEX foreColorLight, COLORINDEX foreColorDark, COLORINDEX backColor, FONTFLAGS fontFlags)
     : base(name, name, theme == VisualStudioTheme.Dark ? foreColorDark : foreColorLight, backColor, Color.Empty, Color.Empty, fontFlags)
 {
     ForeColorLight = foreColorLight;
     ForeColorDark  = foreColorDark;
 }