Beispiel #1
0
        // Token: 0x0600660E RID: 26126 RVA: 0x001CB324 File Offset: 0x001C9524
        internal static TextDecorationCollection GetTextDecorationsForInlineObject(DependencyObject element, TextDecorationCollection textDecorations)
        {
            DependencyObject         parent = LogicalTreeHelper.GetParent(element);
            TextDecorationCollection textDecorationCollection = null;

            if (parent != null)
            {
                textDecorationCollection = DynamicPropertyReader.GetTextDecorations(parent);
            }
            if (!((textDecorations == null) ? (textDecorationCollection == null) : textDecorations.ValueEquals(textDecorationCollection)))
            {
                if (textDecorationCollection == null)
                {
                    textDecorations = null;
                }
                else
                {
                    textDecorations = new TextDecorationCollection();
                    int count = textDecorationCollection.Count;
                    for (int i = 0; i < count; i++)
                    {
                        textDecorations.Add(textDecorationCollection[i]);
                    }
                }
            }
            return(textDecorations);
        }
        // Token: 0x06006607 RID: 26119 RVA: 0x001CB000 File Offset: 0x001C9200
        private TextRun HandleElementStartEdge(StaticTextPointer position)
        {
            TextElement textElement = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
            TextRun     result;

            if (textElement is LineBreak)
            {
                result = new TextEndOfLine(ComplexLine._elementEdgeCharacterLength * 2);
            }
            else if (textElement.IsEmpty)
            {
                TextRunProperties textRunProperties = new TextProperties(textElement, position, false, true, base.PixelsPerDip);
                char[]            array             = new char[ComplexLine._elementEdgeCharacterLength * 2];
                array[0] = '​';
                array[1] = '​';
                result   = new TextCharacters(array, 0, array.Length, textRunProperties);
            }
            else
            {
                Inline inline = textElement as Inline;
                if (inline == null)
                {
                    result = new TextHidden(ComplexLine._elementEdgeCharacterLength);
                }
                else
                {
                    DependencyObject parent         = inline.Parent;
                    FlowDirection    flowDirection  = inline.FlowDirection;
                    FlowDirection    flowDirection2 = flowDirection;
                    if (parent != null)
                    {
                        flowDirection2 = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                    }
                    TextDecorationCollection textDecorations = DynamicPropertyReader.GetTextDecorations(inline);
                    if (flowDirection != flowDirection2)
                    {
                        if (textDecorations == null || textDecorations.Count == 0)
                        {
                            result = new TextSpanModifier(ComplexLine._elementEdgeCharacterLength, null, null, flowDirection);
                        }
                        else
                        {
                            result = new TextSpanModifier(ComplexLine._elementEdgeCharacterLength, textDecorations, inline.Foreground, flowDirection);
                        }
                    }
                    else if (textDecorations == null || textDecorations.Count == 0)
                    {
                        result = new TextHidden(ComplexLine._elementEdgeCharacterLength);
                    }
                    else
                    {
                        result = new TextSpanModifier(ComplexLine._elementEdgeCharacterLength, textDecorations, inline.Foreground);
                    }
                }
            }
            return(result);
        }
Beispiel #3
0
        internal TextProperties(DependencyObject target, StaticTextPointer position, bool inlineObjects, bool getBackground, double pixelsPerDip)
        {
            // if none of the number substitution properties have changed, we may be able to
            // initialize the _numberSubstitution field to a known default value
            FrameworkContentElement fce = target as FrameworkContentElement;

            if (fce != null)
            {
                if (!fce.HasNumberSubstitutionChanged)
                {
                    _numberSubstitution = FrameworkContentElement.DefaultNumberSubstitution;
                }
            }
            else
            {
                FrameworkElement fe = target as FrameworkElement;
                if (fe != null && !fe.HasNumberSubstitutionChanged)
                {
                    _numberSubstitution = FrameworkElement.DefaultNumberSubstitution;
                }
            }

            PixelsPerDip = pixelsPerDip;
            InitCommon(target);

            _typographyProperties = GetTypographyProperties(target);
            if (!inlineObjects)
            {
                _baselineAlignment = DynamicPropertyReader.GetBaselineAlignment(target);

                if (!position.IsNull)
                {
                    TextDecorationCollection highlightDecorations = GetHighlightTextDecorations(position);
                    if (highlightDecorations != null)
                    {
                        // Highlights (if present) take precedence over property value TextDecorations.
                        _textDecorations = highlightDecorations;
                    }
                }

                if (getBackground)
                {
                    _backgroundBrush = DynamicPropertyReader.GetBackgroundBrush(target);
                }
            }
            else
            {
                _baselineAlignment = DynamicPropertyReader.GetBaselineAlignmentForInlineObject(target);
                _textDecorations   = DynamicPropertyReader.GetTextDecorationsForInlineObject(target, _textDecorations);

                if (getBackground)
                {
                    _backgroundBrush = DynamicPropertyReader.GetBackgroundBrushForInlineObject(position);
                }
            }
        }
Beispiel #4
0
        // Token: 0x06006617 RID: 26135 RVA: 0x001CB4C8 File Offset: 0x001C96C8
        internal static Brush GetBackgroundBrush(DependencyObject element)
        {
            Brush brush = null;

            while (brush == null && DynamicPropertyReader.CanApplyBackgroundBrush(element))
            {
                brush = (Brush)element.GetValue(TextElement.BackgroundProperty);
                Invariant.Assert(element is FrameworkContentElement);
                element = ((FrameworkContentElement)element).Parent;
            }
            return(brush);
        }
 // Token: 0x060066A0 RID: 26272 RVA: 0x001CCD18 File Offset: 0x001CAF18
 private void InitCommon(DependencyObject target)
 {
     this._typeface        = DynamicPropertyReader.GetTypeface(target);
     this._fontSize        = (double)target.GetValue(TextElement.FontSizeProperty);
     this._foreground      = (Brush)target.GetValue(TextElement.ForegroundProperty);
     this._textEffects     = DynamicPropertyReader.GetTextEffects(target);
     this._cultureInfo     = DynamicPropertyReader.GetCultureInfo(target);
     this._textDecorations = DynamicPropertyReader.GetTextDecorations(target);
     if (this._numberSubstitution == null)
     {
         this._numberSubstitution = DynamicPropertyReader.GetNumberSubstitution(target);
     }
 }
        // Token: 0x0600669E RID: 26270 RVA: 0x001CCBB0 File Offset: 0x001CADB0
        internal TextProperties(DependencyObject target, StaticTextPointer position, bool inlineObjects, bool getBackground, double pixelsPerDip)
        {
            FrameworkContentElement frameworkContentElement = target as FrameworkContentElement;

            if (frameworkContentElement != null)
            {
                if (!frameworkContentElement.HasNumberSubstitutionChanged)
                {
                    this._numberSubstitution = FrameworkContentElement.DefaultNumberSubstitution;
                }
            }
            else
            {
                FrameworkElement frameworkElement = target as FrameworkElement;
                if (frameworkElement != null && !frameworkElement.HasNumberSubstitutionChanged)
                {
                    this._numberSubstitution = FrameworkElement.DefaultNumberSubstitution;
                }
            }
            base.PixelsPerDip = pixelsPerDip;
            this.InitCommon(target);
            this._typographyProperties = TextProperties.GetTypographyProperties(target);
            if (!inlineObjects)
            {
                this._baselineAlignment = DynamicPropertyReader.GetBaselineAlignment(target);
                if (!position.IsNull)
                {
                    TextDecorationCollection highlightTextDecorations = TextProperties.GetHighlightTextDecorations(position);
                    if (highlightTextDecorations != null)
                    {
                        this._textDecorations = highlightTextDecorations;
                    }
                }
                if (getBackground)
                {
                    this._backgroundBrush = DynamicPropertyReader.GetBackgroundBrush(target);
                    return;
                }
            }
            else
            {
                this._baselineAlignment = DynamicPropertyReader.GetBaselineAlignmentForInlineObject(target);
                this._textDecorations   = DynamicPropertyReader.GetTextDecorationsForInlineObject(target, this._textDecorations);
                if (getBackground)
                {
                    this._backgroundBrush = DynamicPropertyReader.GetBackgroundBrushForInlineObject(position);
                }
            }
        }
Beispiel #7
0
        // Token: 0x06006619 RID: 26137 RVA: 0x001CB564 File Offset: 0x001C9764
        internal static BaselineAlignment GetBaselineAlignment(DependencyObject element)
        {
            Inline            inline = element as Inline;
            BaselineAlignment result = (inline != null) ? inline.BaselineAlignment : BaselineAlignment.Baseline;

            while (inline != null && DynamicPropertyReader.BaselineAlignmentIsDefault(inline))
            {
                inline = (inline.Parent as Inline);
            }
            if (inline != null)
            {
                result = inline.BaselineAlignment;
            }
            return(result);
        }
Beispiel #8
0
 // Token: 0x0600666B RID: 26219 RVA: 0x001CC33C File Offset: 0x001CA53C
 internal MarkerProperties(List list, int index)
 {
     this._offset = list.MarkerOffset;
     if (double.IsNaN(this._offset))
     {
         double lineHeightValue = DynamicPropertyReader.GetLineHeightValue(list);
         this._offset = -0.5 * lineHeightValue;
     }
     else
     {
         this._offset = -this._offset;
     }
     this._style = list.MarkerStyle;
     this._index = index;
 }
Beispiel #9
0
        // ------------------------------------------------------------------
        // Fetch the next run at element close edge position.
        //
        //      position - current position in the text array
        // ------------------------------------------------------------------
        private TextRun HandleElementEndEdge(StaticTextPointer position)
        {
            Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd, "TextPointer does not point to element end edge.");

            TextRun run = null;

            TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);

            Debug.Assert(element != null, "Element should be here.");
            Inline inline = element as Inline;

            if (inline == null)
            {
                run = new TextHidden(_elementEdgeCharacterLength);
            }
            else
            {
                DependencyObject parent = inline.Parent;
                FlowDirection    parentFlowDirection = inline.FlowDirection;

                if (parent != null)
                {
                    parentFlowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                }

                if (inline.FlowDirection != parentFlowDirection)
                {
                    run = new TextEndOfSegment(_elementEdgeCharacterLength);
                }
                else
                {
                    TextDecorationCollection textDecorations = DynamicPropertyReader.GetTextDecorations(inline);
                    if (textDecorations == null || textDecorations.Count == 0)
                    {
                        // (2) End of inline element, hide CloseEdge character and continue
                        run = new TextHidden(_elementEdgeCharacterLength);
                    }
                    else
                    {
                        run = new TextEndOfSegment(_elementEdgeCharacterLength);
                    }
                }
            }
            return(run);
        }
Beispiel #10
0
        // assigns values to all fields except for _typographyProperties, _baselineAlignment,
        // and _background, which are set appropriately in each constructor
        private void InitCommon(DependencyObject target)
        {
            _typeface = DynamicPropertyReader.GetTypeface(target);

            _fontSize    = (double)target.GetValue(TextElement.FontSizeProperty);
            _foreground  = (Brush)target.GetValue(TextElement.ForegroundProperty);
            _textEffects = DynamicPropertyReader.GetTextEffects(target);

            _cultureInfo     = DynamicPropertyReader.GetCultureInfo(target);
            _textDecorations = DynamicPropertyReader.GetTextDecorations(target);

            // as an optimization, we may have already initialized _numberSubstitution to a default
            // value if none of the NumberSubstitution dependency properties have changed
            if (_numberSubstitution == null)
            {
                _numberSubstitution = DynamicPropertyReader.GetNumberSubstitution(target);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <remarks>
        /// The listWidth parameter gives the width of the list element, and is used to clip the MarkerOffset value
        /// </remarks>
        internal MarkerProperties(List list, int index)
        {
            _offset = list.MarkerOffset;
            // Negative value for offset because it is required by TextFormatter line box model.
            // If offset is NaN - default value - set it as 0.5 * line height
            if (Double.IsNaN(_offset))
            {
                // Obtain list's line height to set defualt marker offsert
                double lineHeight = DynamicPropertyReader.GetLineHeightValue(list);
                _offset = -0.5 * lineHeight;
            }
            else
            {
                _offset = -_offset;
            }

            _style = list.MarkerStyle;
            _index = index;
        }
        // Token: 0x06006600 RID: 26112 RVA: 0x001CAB08 File Offset: 0x001C8D08
        public override TextSpan <CultureSpecificCharacterBufferRange> GetPrecedingText(int dcp)
        {
            int num = 0;
            CharacterBufferRange empty   = CharacterBufferRange.Empty;
            CultureInfo          culture = null;

            if (dcp > 0)
            {
                ITextPointer textPointer = this._owner.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward);
                while (textPointer.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text && textPointer.CompareTo(this._owner.TextContainer.Start) != 0)
                {
                    textPointer.MoveByOffset(-1);
                    num++;
                }
                string textInRun = textPointer.GetTextInRun(LogicalDirection.Backward);
                empty = new CharacterBufferRange(textInRun, 0, textInRun.Length);
                StaticTextPointer staticTextPointer = textPointer.CreateStaticPointer();
                DependencyObject  element           = (staticTextPointer.Parent != null) ? staticTextPointer.Parent : this._owner;
                culture = DynamicPropertyReader.GetCultureInfo(element);
            }
            return(new TextSpan <CultureSpecificCharacterBufferRange>(num + empty.Length, new CultureSpecificCharacterBufferRange(culture, empty)));
        }
        // Token: 0x06006608 RID: 26120 RVA: 0x001CB13C File Offset: 0x001C933C
        private TextRun HandleElementEndEdge(StaticTextPointer position)
        {
            TextElement textElement = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
            Inline      inline      = textElement as Inline;
            TextRun     result;

            if (inline == null)
            {
                result = new TextHidden(ComplexLine._elementEdgeCharacterLength);
            }
            else
            {
                DependencyObject parent        = inline.Parent;
                FlowDirection    flowDirection = inline.FlowDirection;
                if (parent != null)
                {
                    flowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                }
                if (inline.FlowDirection != flowDirection)
                {
                    result = new TextEndOfSegment(ComplexLine._elementEdgeCharacterLength);
                }
                else
                {
                    TextDecorationCollection textDecorations = DynamicPropertyReader.GetTextDecorations(inline);
                    if (textDecorations == null || textDecorations.Count == 0)
                    {
                        result = new TextHidden(ComplexLine._elementEdgeCharacterLength);
                    }
                    else
                    {
                        result = new TextEndOfSegment(ComplexLine._elementEdgeCharacterLength);
                    }
                }
            }
            return(result);
        }
Beispiel #14
0
        // ------------------------------------------------------------------
        // Get text immediately before specified text source position.
        // ------------------------------------------------------------------
        public override TextSpan <CultureSpecificCharacterBufferRange> GetPrecedingText(int dcp)
        {
            // Parameter validation
            Debug.Assert(dcp >= 0);

            int nonTextLength = 0;
            CharacterBufferRange precedingText = CharacterBufferRange.Empty;
            CultureInfo          culture       = null;

            if (dcp > 0)
            {
                // Create TextPointer at dcp
                ITextPointer position = _owner.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward);

                // Move backward until we find a position at the end of a text run, or reach start of TextContainer
                while (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text &&
                       position.CompareTo(_owner.TextContainer.Start) != 0)
                {
                    position.MoveByOffset(-1);
                    nonTextLength++;
                }

                // Return text in run. If it is at start of TextContainer this will return an empty string
                string precedingTextString = position.GetTextInRun(LogicalDirection.Backward);
                precedingText = new CharacterBufferRange(precedingTextString, 0, precedingTextString.Length);

                StaticTextPointer pointer = position.CreateStaticPointer();
                DependencyObject  element = (pointer.Parent != null) ? pointer.Parent : _owner;
                culture = DynamicPropertyReader.GetCultureInfo(element);
            }

            return(new TextSpan <CultureSpecificCharacterBufferRange>(
                       nonTextLength + precedingText.Length,
                       new CultureSpecificCharacterBufferRange(culture, precedingText)
                       ));
        }
Beispiel #15
0
 // Token: 0x0600661A RID: 26138 RVA: 0x001CB5A9 File Offset: 0x001C97A9
 internal static BaselineAlignment GetBaselineAlignmentForInlineObject(DependencyObject element)
 {
     return(DynamicPropertyReader.GetBaselineAlignment(LogicalTreeHelper.GetParent(element)));
 }
Beispiel #16
0
        // ------------------------------------------------------------------
        // Fetch the next run at element open edge position.
        //
        //      position - current position in the text array
        // ------------------------------------------------------------------
        private TextRun HandleElementStartEdge(StaticTextPointer position)
        {
            Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge.");

            //

            TextRun     run     = null;
            TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);

            Debug.Assert(element != null, "Cannot use ITextContainer that does not provide TextElement instances.");

            if (element is LineBreak)
            {
                run = new TextEndOfLine(_elementEdgeCharacterLength * 2);
            }
            else if (element.IsEmpty)
            {
                // Empty TextElement should affect line metrics.
                // TextFormatter does not support this feature right now, so as workaround
                // TextRun with ZERO WIDTH SPACE is used.
                TextRunProperties textProps  = new TextProperties(element, position, false /* inline objects */, true /* get background */);
                char[]            textBuffer = new char[_elementEdgeCharacterLength * 2];
                textBuffer[0] = (char)0x200B;
                textBuffer[1] = (char)0x200B;
                run           = new TextCharacters(textBuffer, 0, textBuffer.Length, textProps);
            }
            else
            {
                Inline inline = element as Inline;
                if (inline == null)
                {
                    run = new TextHidden(_elementEdgeCharacterLength);
                }
                else
                {
                    DependencyObject parent = inline.Parent;
                    FlowDirection    inlineFlowDirection = inline.FlowDirection;
                    FlowDirection    parentFlowDirection = inlineFlowDirection;

                    if (parent != null)
                    {
                        parentFlowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                    }

                    TextDecorationCollection inlineTextDecorations = DynamicPropertyReader.GetTextDecorations(inline);

                    if (inlineFlowDirection != parentFlowDirection)
                    {
                        // Inline's flow direction is different from its parent. Need to create new TextSpanModifier with flow direction
                        if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                        {
                            run = new TextSpanModifier(
                                _elementEdgeCharacterLength,
                                null,
                                null,
                                inlineFlowDirection
                                );
                        }
                        else
                        {
                            run = new TextSpanModifier(
                                _elementEdgeCharacterLength,
                                inlineTextDecorations,
                                inline.Foreground,
                                inlineFlowDirection
                                );
                        }
                    }
                    else
                    {
                        if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                        {
                            run = new TextHidden(_elementEdgeCharacterLength);
                        }
                        else
                        {
                            run = new TextSpanModifier(
                                _elementEdgeCharacterLength,
                                inlineTextDecorations,
                                inline.Foreground
                                );
                        }
                    }
                }
            }
            return(run);
        }
Beispiel #17
0
 // Token: 0x06006610 RID: 26128 RVA: 0x001CB39F File Offset: 0x001C959F
 internal static TextEffectCollection GetTextEffects(DependencyObject element)
 {
     return(DynamicPropertyReader.GetCollectionValue(element, TextElement.TextEffectsProperty) as TextEffectCollection);
 }
Beispiel #18
0
 // Token: 0x0600660F RID: 26127 RVA: 0x001CB38D File Offset: 0x001C958D
 internal static TextDecorationCollection GetTextDecorations(DependencyObject element)
 {
     return(DynamicPropertyReader.GetCollectionValue(element, Inline.TextDecorationsProperty) as TextDecorationCollection);
 }