예제 #1
0
        // ------------------------------------------------------------------
        //
        //  TextSource Implementation
        //
        // ------------------------------------------------------------------

        #region TextSource Implementation

        /// <summary>
        /// Get a text run at specified text source position and return it.
        /// </summary>
        /// <param name="dcp">
        /// dcp of position relative to start of line
        /// </param>
        internal override TextRun GetTextRun(int dcp)
        {
            TextRun           run           = null;
            ITextContainer    textContainer = _paraClient.Paragraph.StructuralCache.TextContainer;
            StaticTextPointer position      = textContainer.CreateStaticPointerAtOffset(_cpPara + dcp);

            switch (position.GetPointerContext(LogicalDirection.Forward))
            {
            case TextPointerContext.Text:
                run = HandleText(position);
                break;

            case TextPointerContext.ElementStart:
                run = HandleElementStartEdge(position);
                break;

            case TextPointerContext.ElementEnd:
                run = HandleElementEndEdge(position);
                break;

            case TextPointerContext.EmbeddedElement:
                run = HandleEmbeddedObject(dcp, position);
                break;

            case TextPointerContext.None:
                run = new ParagraphBreakRun(_syntheticCharacterLength, PTS.FSFLRES.fsflrEndOfParagraph);
                break;
            }
            Invariant.Assert(run != null, "TextRun has not been created.");
            Invariant.Assert(run.Length > 0, "TextRun has to have positive length.");

            return(run);
        }
예제 #2
0
파일: linebase.cs 프로젝트: beda2280/wpf-1
        /// <summary>
        /// Fetch the next run at element end edge position.
        /// ElementEndEdge; we can have 2 possibilities:
        /// (1) Close edge of element associated with the text paragraph,
        ///     create synthetic LineBreak run to end the current line.
        /// (2) End of inline element, hide CloseEdge character and continue
        /// </summary>
        /// <param name="position"></param>
        /// Position in current text array
        protected TextRun HandleElementEndEdge(StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd, "TextPointer does not point to element end edge.");

            TextRun run;

            if (position.Parent == _paraClient.Paragraph.Element)
            {
                // (1) Close edge of element associated with the text paragraph,
                //     create synthetic LineBreak run to end the current line.
                run = new ParagraphBreakRun(_syntheticCharacterLength, PTS.FSFLRES.fsflrEndOfParagraph);
            }
            else
            {
                TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
                Debug.Assert(element != null, "Element should be here.");
                Inline           inline = (Inline)element;
                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);
        }
        // Token: 0x0600688F RID: 26767 RVA: 0x001D802C File Offset: 0x001D622C
        protected TextRun HandleElementEndEdge(StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd, "TextPointer does not point to element end edge.");
            TextRun result;

            if (position.Parent == this._paraClient.Paragraph.Element)
            {
                result = new ParagraphBreakRun(LineBase._syntheticCharacterLength, PTS.FSFLRES.fsflrEndOfParagraph);
            }
            else
            {
                TextElement      textElement   = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
                Inline           inline        = (Inline)textElement;
                DependencyObject parent        = inline.Parent;
                FlowDirection    flowDirection = inline.FlowDirection;
                if (parent != null)
                {
                    flowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                }
                if (inline.FlowDirection != flowDirection)
                {
                    result = new TextEndOfSegment(LineBase._elementEdgeCharacterLength);
                }
                else
                {
                    TextDecorationCollection textDecorations = DynamicPropertyReader.GetTextDecorations(inline);
                    if (textDecorations == null || textDecorations.Count == 0)
                    {
                        result = new TextHidden(LineBase._elementEdgeCharacterLength);
                    }
                    else
                    {
                        result = new TextEndOfSegment(LineBase._elementEdgeCharacterLength);
                    }
                }
            }
            return(result);
        }
예제 #4
0
파일: linebase.cs 프로젝트: JianwenSun/cc
        /// <summary>
        /// Fetch the next run at element end edge position.
        /// ElementEndEdge; we can have 2 possibilities:
        /// (1) Close edge of element associated with the text paragraph,
        ///     create synthetic LineBreak run to end the current line.
        /// (2) End of inline element, hide CloseEdge character and continue
        /// </summary>
        /// <param name="position"></param>
        /// Position in current text array
        protected TextRun HandleElementEndEdge(StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd, "TextPointer does not point to element end edge.");

            TextRun run;
            if (position.Parent == _paraClient.Paragraph.Element)
            {
                // (1) Close edge of element associated with the text paragraph,
                //     create synthetic LineBreak run to end the current line.
                run = new ParagraphBreakRun(_syntheticCharacterLength, PTS.FSFLRES.fsflrEndOfParagraph);
            }
            else
            {
                TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
                Debug.Assert(element != null, "Element should be here.");
                Inline inline = (Inline) element;
                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;
        }
예제 #5
0
파일: Line.cs 프로젝트: sjyanxin/WPFSource
        // ------------------------------------------------------------------
        // 
        //  TextSource Implementation 
        //
        // ------------------------------------------------------------------ 

        #region TextSource Implementation

        /// <summary> 
        /// Get a text run at specified text source position and return it.
        /// </summary> 
        /// <param name="dcp"> 
        /// dcp of position relative to start of line
        /// </param> 
        internal override TextRun GetTextRun(int dcp)
        {
            TextRun run = null;
            ITextContainer textContainer = _paraClient.Paragraph.StructuralCache.TextContainer; 
            StaticTextPointer position = textContainer.CreateStaticPointerAtOffset(_cpPara + dcp);
 
            switch (position.GetPointerContext(LogicalDirection.Forward)) 
            {
                case TextPointerContext.Text: 
                    run = HandleText(position);
                    break;

                case TextPointerContext.ElementStart: 
                    run = HandleElementStartEdge(position);
                    break; 
 
                case TextPointerContext.ElementEnd:
                    run = HandleElementEndEdge(position); 
                    break;

                case TextPointerContext.EmbeddedElement:
                    run = HandleEmbeddedObject(dcp, position); 
                    break;
 
                case TextPointerContext.None: 
                    run = new ParagraphBreakRun(_syntheticCharacterLength, PTS.FSFLRES.fsflrEndOfParagraph);
                    break; 
            }
            Invariant.Assert(run != null, "TextRun has not been created.");
            Invariant.Assert(run.Length > 0, "TextRun has to have positive length.");
            return run; 
        }