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

        #region TextSource Implementation

        // ------------------------------------------------------------------
        // Get a text run at specified text source position.
        // ------------------------------------------------------------------
        public override TextRun GetTextRun(int dcp)
        {
            TextRun           run      = null;
            StaticTextPointer position = _owner.TextContainer.CreateStaticPointerAtOffset(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 = HandleInlineObject(position, dcp);
                break;

            case TextPointerContext.None:
                run = new TextEndOfParagraph(_syntheticCharacterLength);
                break;
            }
            Debug.Assert(run != null, "TextRun has not been created.");
            Debug.Assert(run.Length > 0, "TextRun has to have positive length.");
            return(run);
        }
예제 #2
0
        /// <summary>
        /// Get a text run at specified text source position.
        /// </summary>
        public override TextRun GetTextRun(int dcp)
        {
            TextRun           run      = null;
            StaticTextPointer position = _owner.Host.TextContainer.CreateStaticPointerAtOffset(dcp);

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

            case TextPointerContext.None:
                run = new TextEndOfParagraph(_syntheticCharacterLength);
                break;

            case TextPointerContext.ElementStart:
            case TextPointerContext.ElementEnd:
            case TextPointerContext.EmbeddedElement:
            default:
                Invariant.Assert(false, "Unsupported position type.");
                break;
            }
            Invariant.Assert(run != null, "TextRun has not been created.");
            Invariant.Assert(run.Length > 0, "TextRun has to have positive length.");

            return(run);
        }
예제 #3
0
        public override TextRun GetTextRun(int textSourceCharacterIndex)
        {
            if (this._itemsCount <= 0)
            {
                this.UniscribeScriptItemizeOpenType();
            }
            TextRun result;

            if (textSourceCharacterIndex < 0)
            {
                result = new TextEndOfParagraph(1);
            }
            else
            {
                if (textSourceCharacterIndex < this.Text.Length)
                {
                    for (int index = 0; index < this._itemsCount - 1; index++)
                    {
                        if (this._items[index].iCharPos <= textSourceCharacterIndex && this._items[index + 1].iCharPos > textSourceCharacterIndex)
                        {
                            result = this.MakeTextCharactors(index, textSourceCharacterIndex, this._items[index + 1].iCharPos - textSourceCharacterIndex);
                            return(result);
                        }
                    }
                    result = this.MakeTextCharactors(this._itemsCount - 1, textSourceCharacterIndex, this.Text.Length - textSourceCharacterIndex);
                }
                else
                {
                    result = new TextEndOfParagraph(1);
                }
            }
            return(result);
        }
        // Token: 0x060065FF RID: 26111 RVA: 0x001CAA74 File Offset: 0x001C8C74
        public override TextRun GetTextRun(int dcp)
        {
            TextRun           textRun  = null;
            StaticTextPointer position = this._owner.TextContainer.CreateStaticPointerAtOffset(dcp);

            switch (position.GetPointerContext(LogicalDirection.Forward))
            {
            case TextPointerContext.None:
                textRun = new TextEndOfParagraph(Line._syntheticCharacterLength);
                break;

            case TextPointerContext.Text:
                textRun = this.HandleText(position);
                break;

            case TextPointerContext.EmbeddedElement:
                textRun = this.HandleInlineObject(position, dcp);
                break;

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

            case TextPointerContext.ElementEnd:
                textRun = this.HandleElementEndEdge(position);
                break;
            }
            if (textRun.Properties != null)
            {
                textRun.Properties.PixelsPerDip = base.PixelsPerDip;
            }
            return(textRun);
        }
        // ------------------------------------------------------------------
        //
        //  TextSource Implementation
        //
        // ------------------------------------------------------------------

        #region TextSource Implementation

        // ------------------------------------------------------------------
        // Get a text run at specified text source position.
        // ------------------------------------------------------------------
        public override TextRun GetTextRun(int dcp)
        {
            Debug.Assert(dcp >= 0, "Character index must be non-negative.");

            TextRun run;

            // There is only one run of text.
            if (dcp < _content.Length)
            {
                // LineLayout may ask for dcp != 0. This case may only happen during partial
                // validation of TextRunCache.
                // Example:
                //  1) TextRunCache and LineMetrics array were created during measure process.
                //  2) Before OnRender is called somebody invalidates render only property.
                //     This invalidates TextRunCache.
                //  3) Before OnRender is called InputHitTest is invoked. Because LineMetrics
                //     array is valid, we don't have to recreate all lines. There is only
                //     need to recreate the N-th line (line that has been hit).
                //     During line recreation LineLayout will not refetch all runs from the
                //     beginning of TextBlock control - it will ask for the run at the beginning
                //     of the current line.
                // For this reason set 'offsetToFirstChar' to 'dcp' value.
                run = new TextCharacters(_content, dcp, _content.Length - dcp, _textProps);
            }
            else
            {
                run = new TextEndOfParagraph(_syntheticCharacterLength);
            }

            return(run);
        }
        // Token: 0x06004131 RID: 16689 RVA: 0x0012A0E0 File Offset: 0x001282E0
        public override TextRun GetTextRun(int dcp)
        {
            TextRun           textRun  = null;
            StaticTextPointer position = this._owner.Host.TextContainer.CreateStaticPointerAtOffset(dcp);

            switch (position.GetPointerContext(LogicalDirection.Forward))
            {
            case TextPointerContext.None:
                textRun = new TextEndOfParagraph(1);
                goto IL_5C;

            case TextPointerContext.Text:
                textRun = this.HandleText(position);
                goto IL_5C;
            }
            Invariant.Assert(false, "Unsupported position type.");
IL_5C:
            Invariant.Assert(textRun != null, "TextRun has not been created.");
            Invariant.Assert(textRun.Length > 0, "TextRun has to have positive length.");
            if (textRun.Properties != null)
            {
                textRun.Properties.PixelsPerDip = base.PixelsPerDip;
            }
            return(textRun);
        }
예제 #7
0
        // Token: 0x0600666D RID: 26221 RVA: 0x001CC3BC File Offset: 0x001CA5BC
        public override TextRun GetTextRun(int dcp)
        {
            TextRun textRun;

            if (dcp < this._content.Length)
            {
                textRun = new TextCharacters(this._content, dcp, this._content.Length - dcp, this._textProps);
            }
            else
            {
                textRun = new TextEndOfParagraph(Line._syntheticCharacterLength);
            }
            if (textRun.Properties != null)
            {
                textRun.Properties.PixelsPerDip = base.PixelsPerDip;
            }
            return(textRun);
        }