public void SetTreeViewColors(
            IClassificationTypeRegistryService classificationTypeRegistryService,
            IClassificationFormatMap classificationFormatMap,
            IEditorFormatMap editorFormatMap)
        {
            var syntaxNodeBrush = (SolidColorBrush)FindResource(SyntaxNodeTextBrushKey);

            syntaxNodeBrush.Color = GetForegroundColor(editorFormatMap.GetProperties(classificationFormatMap.GetEditorFormatMapKey(classificationTypeRegistryService.GetClassificationType(PredefinedClassificationTypeNames.Keyword))));

            var syntaxTokenBrush = (SolidColorBrush)FindResource(SyntaxTokenTextBrushKey);

            syntaxTokenBrush.Color = GetForegroundColor(editorFormatMap.GetProperties(classificationFormatMap.GetEditorFormatMapKey(classificationTypeRegistryService.GetClassificationType(PredefinedClassificationTypeNames.Comment))));

            var syntaxTriviaBrush = (SolidColorBrush)FindResource(SyntaxTriviaTextBrushKey);

            syntaxTriviaBrush.Color = GetForegroundColor(editorFormatMap.GetProperties(classificationFormatMap.GetEditorFormatMapKey(classificationTypeRegistryService.GetClassificationType(PredefinedClassificationTypeNames.String))));

            var operationBrush = (SolidColorBrush)FindResource(OperationTextBrushKey);

            operationBrush.Color = GetForegroundColor(editorFormatMap.GetProperties(classificationFormatMap.GetEditorFormatMapKey(classificationTypeRegistryService.GetClassificationType(PredefinedClassificationTypeNames.Number))));

            var errorBrush = (SolidColorBrush)FindResource(ErrorSquiggleBrushKey);

            errorBrush.Color = GetForegroundColor(editorFormatMap.GetProperties(PredefinedErrorTypeNames.SyntaxError));
        }
示例#2
0
        private Inline GetClassifiedText(string text, IClassificationType classificationType)
        {
            var properties         = _classificationFormatMap.GetTextProperties(classificationType);
            var editorFormatMapKey = _classificationFormatMap.GetEditorFormatMapKey(classificationType);
            var resourceDictionary = _editorFormatMap.GetProperties(editorFormatMapKey);

            var isItalicValue = resourceDictionary[ClassificationFormatDefinition.IsItalicId];
            var fontStyle     = isItalicValue != null && Convert.ToBoolean(isItalicValue)
                                ? FontStyles.Italic
                                : FontStyles.Normal;

            var isBoldValue = resourceDictionary[ClassificationFormatDefinition.IsBoldId];
            var fontWeights = isBoldValue != null && Convert.ToBoolean(isBoldValue)
                                  ? FontWeights.Bold
                                  : FontWeights.Normal;

            return(new Run(text)
            {
                Foreground = properties.ForegroundBrush,
                Background = properties.BackgroundBrush,
                FontStyle = fontStyle,
                FontWeight = fontWeights,
                TextEffects = properties.TextEffects,
                TextDecorations = properties.TextDecorations
            });
        }
示例#3
0
        static void InitStyleClassificationCache <TStyleEnum, TCodeStyle>(Dictionary <string, StyleBase> styleCache, IClassificationTypeRegistryService service, List <TCodeStyle> styles)
            where TCodeStyle : StyleBase
        {
            var cs = typeof(TStyleEnum);

            foreach (var f in cs.GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                var styleId = (int)f.GetValue(null);
                var cso     = styles.Find(i => i.Id == styleId);
                if (cso == null)
                {
                    continue;
                }
                foreach (var item in f.GetCustomAttributes <ClassificationTypeAttribute>(false))
                {
                    var n = item.ClassificationTypeNames;
                    if (String.IsNullOrWhiteSpace(n))
                    {
                        continue;
                    }
                    var ct = service.GetClassificationType(n);
                    if (ct != null)
                    {
                        styleCache[DefaultClassificationFormatMap.GetEditorFormatMapKey(ct)] = cso;
                    }
                }
            }
        }
示例#4
0
 public string GetEditorFormatMapKey(IClassificationType classificationType) =>
 categoryMap.GetEditorFormatMapKey(classificationType);