Esempio n. 1
0
        // Gathers text decorations set on scoping highlights.
        // If no highlight properties are found, returns null
        private static TextDecorationCollection GetHighlightTextDecorations(StaticTextPointer highlightPosition)
        {
            TextDecorationCollection textDecorations = null;
            Highlights highlights = highlightPosition.TextContainer.Highlights;

            if (highlights == null)
            {
                return(textDecorations);
            }

            //
            // Speller
            //
            textDecorations = highlights.GetHighlightValue(highlightPosition, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection;

            //
            // IME composition
            //
#if UNUSED_IME_HIGHLIGHT_LAYER
            TextDecorationCollection imeTextDecorations = highlights.GetHighlightValue(highlightPosition, LogicalDirection.Forward, typeof(FrameworkTextComposition)) as TextDecorationCollection;
            if (imeTextDecorations != null)
            {
                textDecorations = imeTextDecorations;
            }
#endif

            return(textDecorations);
        }
        // Token: 0x060066A1 RID: 26273 RVA: 0x001CCD98 File Offset: 0x001CAF98
        private static TextDecorationCollection GetHighlightTextDecorations(StaticTextPointer highlightPosition)
        {
            TextDecorationCollection result = null;
            Highlights highlights           = highlightPosition.TextContainer.Highlights;

            if (highlights == null)
            {
                return(result);
            }
            return(highlights.GetHighlightValue(highlightPosition, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection);
        }
        // Token: 0x06004143 RID: 16707 RVA: 0x0012A510 File Offset: 0x00128710
        private TextRun HandleText(StaticTextPointer position)
        {
            StaticTextPointer position2 = this._owner.Host.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            if (position.GetOffsetToPosition(position2) > 4096)
            {
                position2 = position.CreatePointer(4096);
            }
            Highlights highlights = position.TextContainer.Highlights;
            TextDecorationCollection textDecorationCollection = highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection;
            TextRunProperties        textRunProperties        = this._lineProperties.DefaultTextRunProperties;

            if (textDecorationCollection != null)
            {
                if (this._spellerErrorProperties == null)
                {
                    this._spellerErrorProperties = new TextProperties((TextProperties)textRunProperties, textDecorationCollection);
                }
                textRunProperties = this._spellerErrorProperties;
            }
            ITextSelection textSelection = position.TextContainer.TextSelection;
            TextEditor     textEditor    = (textSelection != null) ? textSelection.TextEditor : null;

            if (textEditor != null)
            {
                ITextView textView = textEditor.TextView;
                if (((textView != null) ? new bool?(textView.RendersOwnSelection) : null) == true && highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(TextSelection)) != DependencyProperty.UnsetValue)
                {
                    TextProperties   textProperties   = new TextProperties((TextProperties)textRunProperties, textDecorationCollection);
                    FrameworkElement frameworkElement = (textEditor != null) ? textEditor.UiScope : null;
                    if (frameworkElement != null)
                    {
                        textProperties.SetBackgroundBrush(null);
                        Brush brush = frameworkElement.GetValue(TextBoxBase.SelectionTextBrushProperty) as Brush;
                        if (brush != null)
                        {
                            textProperties.SetForegroundBrush(brush);
                        }
                    }
                    textRunProperties = textProperties;
                }
            }
            char[] array     = new char[position.GetOffsetToPosition(position2)];
            int    textInRun = position.GetTextInRun(LogicalDirection.Forward, array, 0, array.Length);

            Invariant.Assert(textInRun == array.Length);
            return(new TextCharacters(array, 0, textInRun, textRunProperties));
        }