示例#1
0
        private void SetProperties(IClassificationType classificationType)
        {
            //? Might need to benchmark this function for performance.

            var properties = formatMap.GetTextProperties(classificationType);
            var settings   = FontSettingsManager.CurrentSettings;
            var fontSize   = GetEditorTextSize() + settings.Size;

            if (!string.IsNullOrWhiteSpace(FontSettingsManager.CurrentSettings.Font))
            {
                properties = properties.SetTypeface(new Typeface(settings.Font));
            }

            if (Math.Abs(fontSize - properties.FontRenderingEmSize) > 0)
            {
                properties = properties.SetFontRenderingEmSize(fontSize);
            }

            if (properties.Italic != settings.Italic)
            {
                properties = properties.SetItalic(settings.Italic);
            }

            if (settings.Opacity >= 0.1 && settings.Opacity <= 1)
            {
                properties = properties.SetForegroundOpacity(settings.Opacity);
            }

            formatMap.SetTextProperties(classificationType, properties);
        }
示例#2
0
        void FixFormatMap(IEnumerable <IClassificationType> classificationTypes)
        {
            try
            {
                _inUpdate = true;

                foreach (var type in classificationTypes)
                {
                    if (type == null)
                    {
                        continue;
                    }

                    // There are a couple we want to skip, no matter what.  These are classification types that aren't
                    // used for text formatting.
                    string name = type.Classification.ToUpperInvariant();

                    if (name.Contains("WORD WRAP GLYPH") ||
                        name.Contains("LINE NUMBER") ||
                        name == "STRING")
                    {
                        continue;
                    }

                    var format = _formatMap.GetTextProperties(type);

                    if (format.BackgroundBrushEmpty)
                    {
                        continue;
                    }

                    var solidColorBrush = format.BackgroundBrush as SolidColorBrush;
                    if (solidColorBrush != null && solidColorBrush.Opacity == BackgroundOpacity)
                    {
                        format = format.SetBackgroundBrush(new SolidColorBrush(solidColorBrush.Color)
                        {
                            Opacity = Transparent
                        });
                        _formatMap.SetTextProperties(type, format);
                    }
                }
            }
            catch (Exception)
            {
                // Do nothing, just prevent this exception from bringing down the editor.
            }
            finally
            {
                _inUpdate = false;
            }
        }
        private void Bold(IClassificationType classification)
        {
            var textFormat = _formatMap.GetTextProperties(_typeRegistry.GetClassificationType("text"));
            var properties = _formatMap.GetTextProperties(classification);
            var typeface   = properties.Typeface;

            var boldedTypeface = new Typeface(typeface.FontFamily, typeface.Style, FontWeights.Bold, typeface.Stretch);
            var biggerSize     = textFormat.FontRenderingEmSize + 2;

            properties = properties.SetTypeface(boldedTypeface);
            properties = properties.SetFontRenderingEmSize(biggerSize);

            _formatMap.SetTextProperties(classification, properties);
        }
示例#4
0
        private void CreateNormalizedSpans()
        {
            Int32          startCharacterIndex = _startCharacterIndex;
            Int32          length = _text.Length;
            NormalizedSpan span   = new NormalizedSpan("", "_gap_", _startCharacterIndex, TextFormattingRunProperties.DefaultProperties);

            _startNode = span;
            for (Int32 i = 0; i < _classificationSpanList.Count; i++)
            {
                ClassificationSpan span2 = _classificationSpanList[i];
                Span span3 = span2.Span();
                if (span3.Start >= (_startCharacterIndex + length))
                {
                    break;
                }
                Int32 num4 = span3.Start - startCharacterIndex;
                if (num4 > 0)
                {
                    NormalizedSpan span4 = new NormalizedSpan(_text.Substring(startCharacterIndex - _startCharacterIndex, span3.Start - startCharacterIndex), "_gap_", startCharacterIndex, TextFormattingRunProperties.DefaultProperties);
                    span = span.AddNode(span4);
                    startCharacterIndex += num4;
                }
                else if (num4 < 0)
                {
                    Int32 num5 = span3.Length + num4;
                    if (num5 <= 0)
                    {
                        continue;
                    }
                    span3 = new Span(startCharacterIndex, num5);
                }
                if (span3.Length > 0)
                {
                    Int32 num6 = startCharacterIndex - _startCharacterIndex;
                    TextFormattingRunProperties textProperties = _classificationFormatMap.GetTextProperties(span2.Classification);
                    if ((span3.Length + num6) > length)
                    {
                        Int32          num7  = length - num6;
                        NormalizedSpan span5 = new NormalizedSpan(_text.Substring(span3.Start - _startCharacterIndex, num7), span2.Classification, span3.Start, textProperties);
                        span = span.AddNode(span5);
                        startCharacterIndex = _startCharacterIndex + length;
                        break;
                    }
                    NormalizedSpan span6 = new NormalizedSpan(_text.Substring(span3.Start - _startCharacterIndex, span3.Length), span2.Classification, span3.Start, textProperties);
                    span = span.AddNode(span6);
                    startCharacterIndex += span3.Length;
                }
            }
            if (startCharacterIndex < (_startCharacterIndex + length))
            {
                Int32          num8  = length - (startCharacterIndex - _startCharacterIndex);
                NormalizedSpan span7 = new NormalizedSpan(_text.Substring(startCharacterIndex - _startCharacterIndex, num8), "_gap_", startCharacterIndex, TextFormattingRunProperties.DefaultProperties);
                span = span.AddNode(span7);
            }
            if (_startNode.Next != null)
            {
                _startNode          = _startNode.Next;
                _startNode.Previous = null;
            }
        }
        private void ApplyFormatting(SettingsItem item, IClassificationFormatMap formatMap)
        {
            if (!item.IsActive)
            {
                return;
            }

            var classificationType = ClassificationRegistry.GetClassificationType(item.ClassificationId);

            if (classificationType == null)
            {
                return;
            }
            var oldFormatting   = formatMap.GetTextProperties(classificationType);
            var foregroundBrush = item.ForegroundColor == Colors.Transparent ? null : new SolidColorBrush(item.ForegroundColor);
            var backgroundBrush = item.BackgroundColor == Colors.Transparent ? null : new SolidColorBrush(item.BackgroundColor);
            var formatting      = TextFormattingRunProperties.CreateTextFormattingRunProperties(foregroundBrush, backgroundBrush, oldFormatting.Typeface, null, null, oldFormatting.TextDecorations, oldFormatting.TextEffects, oldFormatting.CultureInfo);

            formatting = Settings.Settings.Instance.UpdateProperties(item, formatting);
            var identifierPosition = formatMap.CurrentPriorityOrder.IndexOf(classificationType);

            if (identifierPosition < 0)
            {
                return;
            }
            var afterIdentifierClassification = formatMap.CurrentPriorityOrder[identifierPosition /* + 1*/];

            // formatMap.AddExplicitTextProperties(classificationType, formatting, afterIdentifierClassification);
            formatMap.AddExplicitTextProperties(classificationType, formatting, afterIdentifierClassification);
        }
        public void UpdateClassifications(IClassificationFormatMap formatMap)
        {
            if (_updating || formatMap.IsInBatchUpdate)
            {
                return;
            }
            try {
                _updating = true;
                foreach (var identifier in _colorizerCache.Values)
                {
                    if (!identifier.IsDirty)
                    {
                        continue;
                    }
                    if (!formatMap.IsInBatchUpdate)
                    {
                        formatMap.BeginBatchUpdate();
                    }

                    var textProperties = formatMap.GetTextProperties(identifier.Classification);
                    textProperties = textProperties.SetForeground(identifier.Color.ToColor());
                    formatMap.SetTextProperties(identifier.Classification, textProperties);
                    identifier.IsDirty = false;
                }
            } finally {
                if (formatMap.IsInBatchUpdate)
                {
                    formatMap.EndBatchUpdate();
                }
                _updating = false;
            }
        }
示例#7
0
        private void FetchColors()
        {
            var ct    = _classificationTypeRegistry.GetClassificationType(MarkdownClassificationTypes.CodeBackground);
            var props = _classificationFormatMap.GetTextProperties(ct);

            _backgroudColorBrush = props.BackgroundBrush;
        }
示例#8
0
		public static FrameworkElement Create(IClassificationFormatMap classificationFormatMap, string text, List<TextClassificationTag> tagsList, TextElementFlags flags) {
			bool useFastTextBlock = (flags & (TextElementFlags.TrimmingMask | TextElementFlags.WrapMask | TextElementFlags.FilterOutNewLines)) == (TextElementFlags.NoTrimming | TextElementFlags.NoWrap | TextElementFlags.FilterOutNewLines);
			bool filterOutNewLines = (flags & TextElementFlags.FilterOutNewLines) != 0;
			if (tagsList.Count != 0) {
				if (useFastTextBlock) {
					return new FastTextBlock((flags & TextElementFlags.NewFormatter) != 0, new TextSrc {
						text = ToString(text, filterOutNewLines),
						classificationFormatMap = classificationFormatMap,
						tagsList = tagsList.ToArray(),
					});
				}

				var propsSpans = tagsList.Select(a => new TextRunPropertiesAndSpan(a.Span, classificationFormatMap.GetTextProperties(a.ClassificationType)));
				var textBlock = TextBlockFactory.Create(text, classificationFormatMap.DefaultTextProperties, propsSpans, TextBlockFactory.Flags.DisableSetTextBlockFontFamily | TextBlockFactory.Flags.DisableFontSize | (filterOutNewLines ? TextBlockFactory.Flags.FilterOutNewlines : 0));
				textBlock.TextTrimming = GetTextTrimming(flags);
				textBlock.TextWrapping = GetTextWrapping(flags);
				return textBlock;
			}

			FrameworkElement fwElem;
			if (useFastTextBlock) {
				fwElem = new FastTextBlock((flags & TextElementFlags.NewFormatter) != 0) {
					Text = ToString(text, filterOutNewLines)
				};
			}
			else {
				fwElem = new TextBlock {
					Text = ToString(text, filterOutNewLines),
					TextTrimming = GetTextTrimming(flags),
					TextWrapping = GetTextWrapping(flags),
				};
			}
			return InitializeDefault(classificationFormatMap, fwElem);
		}
示例#9
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
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CodeCoverageAdornment"/> class.
        /// </summary>
        /// <param name="view">Text view to create the adornment for</param>
        /// <param name="classificationRegistry"></param>
        /// <param name="formatMap"></param>
        public CodeCoverageAdornment(IWpfTextView view,
                                     IClassificationTypeRegistryService classificationRegistry,
                                     IClassificationFormatMapService formatMap)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            IClassificationType         missClassificationType = classificationRegistry.GetClassificationType(CodeCoverageClassifierType.Miss);
            IClassificationFormatMap    missFormat             = formatMap.GetClassificationFormatMap(view);
            TextFormattingRunProperties missText = missFormat.GetTextProperties(missClassificationType);

            MissedBackground = missText.BackgroundBrush;

            IClassificationType         hitClassificationType = classificationRegistry.GetClassificationType(CodeCoverageClassifierType.Hit);
            IClassificationFormatMap    hitFormat             = formatMap.GetClassificationFormatMap(view);
            TextFormattingRunProperties hitText = hitFormat.GetTextProperties(hitClassificationType);

            HitBackground = hitText.BackgroundBrush;


            _layer = view.GetAdornmentLayer("CodeCoverageAdornment");

            _view = view;
            _view.LayoutChanged += OnLayoutChanged;

            _codeCoverage = PowershellService.Current.CodeCoverage;
            _codeCoverage.ModelChanged         += ShowHitsModelChanged;
            _codeCoverage.ShowHitsModelChanged += ShowHitsModelChanged;
        }
示例#11
0
        private void SetItalics(IClassificationType classifierType, bool enable)
        {
            var tp = formatMap.GetTextProperties(classifierType);

            tp = tp.SetItalic(enable);
            formatMap.SetTextProperties(classifierType, tp);
        }
示例#12
0
        private Brush GetRainbowBrush(int depth)
        {
            var rainbow    = rainbowTags[depth % rainbowTags.Length];
            var properties = formatMap.GetTextProperties(rainbow);

            return(properties.ForegroundBrush);
        }
        public static void UpdateTextProperties(IClassificationTypeRegistryService registryService, IClassificationFormatMap formatMap, Settings settings)
        {
            var classificationType = registryService.GetClassificationType(ClassifierKey);
            var textProperties     = formatMap.GetTextProperties(classificationType);

            formatMap.SetTextProperties(classificationType, textProperties.SetBold(settings.IsBold));
        }
示例#14
0
        /// <summary>
        /// Updates properties from a change to the format map. Also forces a redraw of all the time stamped lines.
        /// </summary>
        private void SetFontFromClassification()
        {
            var font = _formatMap.GetTextProperties(_lineNumberClassification);

            _showHours        = _textView.Options.GetOptionValue(TimeStampMarginShowHours.StaticKey);
            _showMilliseconds = _textView.Options.GetOptionValue(TimeStampMarginShowMilliseconds.StaticKey);

            // In the line number margin, we always enforce a 100% opacity.
            // This is to prevent mixing of the line number's background color
            // with its parent's background when the background brush of the
            // line number classified item is not opaque.
            Brush backgroundBrush = font.BackgroundBrush;

            if (backgroundBrush.Opacity != 1.0)
            {
                backgroundBrush         = backgroundBrush.Clone();
                backgroundBrush.Opacity = 1.0;
                backgroundBrush.Freeze();

                font = font.SetBackgroundBrush(backgroundBrush);
            }

            base.Background = backgroundBrush;
            _formatting     = font;
            this.SetClearTypeHint(font);
            this.DetermineMarginWidth();

            // Reformat all the lines
            _translatedCanvas.Children.Clear();
            this.UpdateLineNumbers();
        }
        /// <summary>
        /// Gets the default font size used by VS.
        /// </summary>
        /// <remarks>
        /// The default font size is set in Tools->Options->Environment->Fonts and Colors.
        /// </remarks>
        public double GetDefaultFontSize(IWpfTextView textView)
        {
            IClassificationFormatMap    formatMap = this.FormatMapService.GetClassificationFormatMap(textView);
            IClassificationType         plainTextClassificationType = this.ClassificationTypeRegistryService.GetClassificationType("text");
            TextFormattingRunProperties textProperties = formatMap.GetTextProperties(plainTextClassificationType);

            return(textProperties.FontRenderingEmSize);
        }
示例#16
0
        public static Run ToRun(this ColoredString text, IClassificationFormatMap formatMap, IClassificationTypeRegistryService typeRegistry)
        {
            Run run = new Run(text.Text);

            run.SetTextProperties(formatMap.GetTextProperties(typeRegistry.GetClassificationType(text.GetClassificationType())));

            return(run);
        }
示例#17
0
        public static Run ToRun(this string text, IClassificationFormatMap formatMap, IClassificationType classificationType)
        {
            Run run = new Run(text);

            run.SetTextProperties(formatMap.GetTextProperties(classificationType));

            return(run);
        }
示例#18
0
        private Inline GetClassifiedText(string text, IClassificationType classificationType)
        {
            var properties = _classificationFormatMap.GetTextProperties(classificationType);

            var run = new Run(text);

            SetTextProperties(run, properties, false);
            run.TextDecorations = properties.TextDecorations;
            return(run);
        }
        void SetFontFromClassification()
        {
            if (m_adornment != null)
            {
                var classificationType = m_classificationTypeRegistryService.GetClassificationType(EmptyMarkerClassificationFormatDefinition.Name);
                var textProperties     = m_classificationFormatMap.GetTextProperties(classificationType);

                m_adornment.SetFont(textProperties);
            }
        }
示例#20
0
 public HtmlMarkupProvider(
     IClassificationFormatMap classificationFormatMap,
     IClassificationType defaultClassificationType,
     Brush backgroundColor)
 {
     _classificationFormatMap   = classificationFormatMap;
     _defaultClassificationType = defaultClassificationType;
     _defaultTextProperties     = _classificationFormatMap.GetTextProperties(_defaultClassificationType);
     _defaultCss = GetCssStyles(_defaultClassificationType);
     _defaultCss["background"] = GetColor(backgroundColor);
 }
        public static Run ToRun(this SymbolDisplayPart part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
        {
            var text = part.ToVisibleDisplayString(includeLeftToRightMarker: true);

            var run = new Run(text);

            var format = formatMap.GetTextProperties(typeMap.GetClassificationType(part.Kind.ToClassificationTypeName()));
            run.SetTextProperties(format);

            return run;
        }
示例#22
0
        private void CreateDrawingObjects()
        {
            // this gets the color settings configured by the
            // user in Fonts and Colors (or the default in out
            // classification type).
            TextFormattingRunProperties format =
                formatMap.GetTextProperties(formatType);

            this.lineRect.Fill            = format.BackgroundBrush;
            this.lineRect.Stroke          = format.ForegroundBrush;
            this.lineRect.StrokeThickness = settings.HighlightLineWidth;
        }
        public static Run ToRun(this SymbolDisplayPart part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
        {
            var text = part.ToVisibleDisplayString(includeLeftToRightMarker: true);

            var run = new Run(text);

            var format = formatMap.GetTextProperties(typeMap.GetClassificationType(part.Kind.ToClassificationTypeName()));

            run.SetTextProperties(format);

            return(run);
        }
        Run ToRun(string text, SyntaxTokenClassification classification, IClassificationFormatMap formatMap) {
            var run = new Run(text);

            IClassificationType ct;
            _classificationMap.TryGetValue(classification, out ct);
            if (ct != null) {
                var props = formatMap.GetTextProperties(ct);
                run.SetTextProperties(props);
            }

            return run;
        }
        void ClearForeground(IClassificationType classification)
        {
            var properties = formatMap.GetTextProperties(classification);

            // If this is already cleared out, skip it
            if (properties.ForegroundBrushEmpty)
            {
                return;
            }

            formatMap.SetTextProperties(classification, properties.ClearForegroundBrush());
        }
        public static Run ToRun(this ClassifiedText part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
        {
            var text = part.Text;

            var run = new Run(text);

            var format = formatMap.GetTextProperties(typeMap.GetClassificationType(
                part.ClassificationType));
            run.SetTextProperties(format);

            return run;
        }
示例#27
0
            public static Run GetRun(TaggedText part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
            {
                var text = GetVisibleDisplayString(part, includeLeftToRightMarker: true);

                var run = new Run(text);

                var format = formatMap.GetTextProperties(typeMap.GetClassificationType(ClassificationTags.GetClassificationTypeName(part.Tag)));

                run.SetTextProperties(format);

                return(run);
            }
示例#28
0
        public static Run ToRun(this ClassifiedText part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
        {
            var run = new Run(part.Text);

            var classificationType = typeMap.GetClassificationType(part.ClassificationType);

            var format = formatMap.GetTextProperties(classificationType);

            run.SetTextProperties(format);

            return(run);
        }
            public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
            {
                ITextSnapshot  snapshot     = _buffer.CurrentSnapshot;
                ITrackingPoint triggerPoint = session.GetTriggerPoint(_buffer);
                SnapshotPoint  point        = triggerPoint.GetPoint(snapshot);

                SyntaxTree syntax            = snapshot.GetSyntaxTree();
                RobotsTxtDocumentSyntax root = syntax.Root as RobotsTxtDocumentSyntax;

                applicableToSpan = null;

                // find section
                RobotsTxtLineSyntax line = root.Records
                                           .SelectMany(r => r.Lines)
                                           .FirstOrDefault(s => s.NameToken.Span.Span.Contains(point));

                if (line != null)
                {
                    IClassificationFormatMap formatMap = _classificationFormatMapService.GetClassificationFormatMap(session.TextView);

                    string fieldName = line.NameToken.Value;

                    // get glyph
                    var glyph = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
                    var classificationType = _classificationRegistry.GetClassificationType("RobotsTxt/RecordName");
                    var format             = formatMap.GetTextProperties(classificationType);

                    // construct content
                    ISemanticModel model = syntax.GetSemanticModel();
                    var            field = model.GetFieldSymbol(line);

                    var content = new QuickInfoContent
                    {
                        Glyph     = glyph,
                        Signature = new Run(field.Name)
                        {
                            Foreground = format.ForegroundBrush
                        },
                        Documentation = RobotsTxtDocumentation.GetDocumentation(field),
                    };

                    // add to session
                    quickInfoContent.Add(
                        new ContentPresenter
                    {
                        Content         = content,
                        ContentTemplate = Template,
                    }
                        );
                    applicableToSpan = snapshot.CreateTrackingSpan(line.NameToken.Span.Span, SpanTrackingMode.EdgeInclusive);
                    return;
                }
            }
        private static void UpdateFormatMap(IClassificationFormatMap formatMap, IClassificationTypeRegistryService typeRegistryService, string type, Color color)
        {
            var classificationType = typeRegistryService.GetClassificationType(type);
            var oldProp            = formatMap.GetTextProperties(classificationType);

            var backgroundBrush = new SolidColorBrush(color);

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

            formatMap.SetTextProperties(classificationType, newProp);
        }
示例#31
0
        private static TextFormattingRunProperties GetClassificationTypeTextProperties(string classificationTypeName)
        {
            var componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel));

            var classificationTypeRegistry = componentModel.DefaultExportProvider.GetExportedValue <IClassificationTypeRegistryService>();
            IClassificationType delimiterClassification = classificationTypeRegistry.GetClassificationType(classificationTypeName);

            var formatMapService = componentModel.DefaultExportProvider.GetExportedValue <IClassificationFormatMapService>();
            IClassificationFormatMap    formatMap  = formatMapService.GetClassificationFormatMap("Text Editor");
            TextFormattingRunProperties properties = formatMap.GetTextProperties(delimiterClassification);

            return(properties);
        }
示例#32
0
        private Dictionary <string, string> GetCssStyles(IClassificationType classificationType)
        {
            TextRunProperties properties =
                _classificationFormatMap.GetTextProperties(classificationType);

            var styles = new Dictionary <string, string>();

            var face = GetFontFamily(properties);

            if (!string.IsNullOrEmpty(face))
            {
                styles.Add("font-family", face);
            }

            string currentSize = GetFontSize(properties);

            if (!string.IsNullOrEmpty(currentSize))
            {
                styles.Add("font-size", currentSize);
            }

            var fontStyle = GetFontStyle(properties);

            if (!string.IsNullOrEmpty(fontStyle))
            {
                styles.Add("font-style", fontStyle);
            }

            var fontWeight = GetFontWeight(properties);

            if (!string.IsNullOrEmpty(fontWeight))
            {
                styles.Add("font-weight", fontWeight);
            }

            var foreground = GetColor(properties.ForegroundBrush);

            if (!string.IsNullOrEmpty(foreground))
            {
                styles.Add("color", foreground);
            }

            var background = GetColor(properties.BackgroundBrush);

            if (!string.IsNullOrEmpty(background))
            {
                styles.Add("background", background);
            }

            return(styles);
        }
示例#33
0
        private void CreateDrawingObjects()
        {
            // this gets the color settings configured by the
            // user in Fonts and Colors (or the default in out
            // classification type).
            TextFormattingRunProperties format = formatMap.GetTextProperties(formatType);

            fillBrush = format.BackgroundBrush;
            Brush penBrush = format.ForegroundBrush;

            borderPen = new Pen(penBrush, 0.5);
            borderPen.Freeze();
            RedrawAdornments();
        }
        public static void UpdateTextProperties(IClassificationTypeRegistryService registryService, IClassificationFormatMap formatMap, Settings settings)
        {
            var classificationType = registryService.GetClassificationType(ClassifierKey);
            var textProperties     = formatMap.GetTextProperties(classificationType);

            if (settings.Background.HasValue)
            {
                formatMap.SetTextProperties(classificationType, textProperties.SetBackground(settings.Background.Value));
            }
            else
            {
                formatMap.SetTextProperties(classificationType, textProperties.ClearBackgroundBrush());
            }
        }
        internal static void Fade(IClassificationFormatMap formatMap, IClassificationType classificationType)
        {
            // Argument validation
            if (formatMap == null) {
                throw new ArgumentNullException(nameof(formatMap));
            }
            if (classificationType == null) {
                throw new ArgumentNullException(nameof(classificationType));
            }

            // Perform formatting
            TextFormattingRunProperties properties = formatMap.GetTextProperties(classificationType);
            properties = properties.SetForegroundOpacity(2d / 3d);
            formatMap.SetTextProperties(classificationType, properties);
        }
        internal static void Normalize(IClassificationFormatMap formatMap, IClassificationType classificationType)
        {
            // Argument validation
            if (formatMap == null) {
                throw new ArgumentNullException(nameof(formatMap));
            }
            if (classificationType == null) {
                throw new ArgumentNullException(nameof(classificationType));
            }

            // Perform formatting
            TextFormattingRunProperties properties = formatMap.GetTextProperties(classificationType);

            if (!properties.ItalicEmpty || properties.Italic) {
                properties = properties.SetItalic(false);
                formatMap.SetTextProperties(classificationType, properties);
            }
        }
		IEnumerable<TextRunPropertiesAndSpan> CreateTextRunPropertiesAndSpans(ImmutableArray<TaggedText> taggedParts, IClassificationFormatMap classificationFormatMap, IThemeClassificationTypeService themeClassificationTypeService) {
			int pos = 0;
			foreach (var part in taggedParts) {
				var color = TextTagsHelper.ToTextColor(part.Tag);
				var classificationType = themeClassificationTypeService.GetClassificationType(color);
				yield return new TextRunPropertiesAndSpan(new Span(pos, part.Text.Length), classificationFormatMap.GetTextProperties(classificationType));
				pos += part.Text.Length;
			}
		}
 TextFormattingRunProperties GetTextProperties(IClassificationFormatMap formatMap, string classifactionType) {
   var plainTextClassificationType = _classificationTypeRegistryService.GetClassificationType(classifactionType);
   return formatMap.GetTextProperties(plainTextClassificationType);
 }
示例#39
0
        private void UpdateForegroundColor(
            string classificationTypeName,
            IClassificationFormatMap sourceFormatMap,
            IClassificationFormatMap targetFormatMap)
        {
            var classificationType = _classificationTypeRegistryService.GetClassificationType(classificationTypeName);
            if (classificationType == null)
            {
                return;
            }

            var sourceProps = sourceFormatMap.GetTextProperties(classificationType);
            var targetProps = targetFormatMap.GetTextProperties(classificationType);

            targetProps = targetProps.SetForegroundBrush(sourceProps.ForegroundBrush);

            targetFormatMap.SetTextProperties(classificationType, targetProps);
        }
示例#40
0
		public void OnTextPropertiesChanged(IClassificationFormatMap classificationFormatMap) {
			replLineNumberInput1TextFormattingRunProperties = classificationFormatMap.GetTextProperties(replLineNumberInput1ClassificationType);
			replLineNumberInput2TextFormattingRunProperties = classificationFormatMap.GetTextProperties(replLineNumberInput2ClassificationType);
			replLineNumberOutputTextFormattingRunProperties = classificationFormatMap.GetTextProperties(replLineNumberOutputClassificationType);
		}