TextRun クラス

定義

単一のプロパティ セットを共有する文字列を表します。

public ref class TextRun abstract
public abstract class TextRun
type TextRun = class
Public MustInherit Class TextRun
継承
TextRun
派生

次の例では、メソッドの GetTextRun オーバーライドが実装されています。

// Retrieve the next formatted text run for the text source.
public override TextRun GetTextRun(int textSourceCharacterIndex)
{
    // Determine whether the text source index is in bounds.
    if (textSourceCharacterIndex < 0)
    {
        throw new ArgumentOutOfRangeException("textSourceCharacterIndex", "Value must be greater than 0.");
    }

    // Determine whether the text source index has exceeded or equaled the text source length.
    if (textSourceCharacterIndex >= _text.Length)
    {
        // Return an end-of-paragraph indicator -- a TextEndOfParagraph object is a special type of text run.
        return new TextEndOfParagraph(1);
    }

    // Create and return a TextCharacters object, which is formatted according to
    // the current layout and rendering properties.
    if (textSourceCharacterIndex < _text.Length)
    {
        // The TextCharacters object is a special type of text run that contains formatted text.
        return new TextCharacters(
           _text,                                       // The text store
           textSourceCharacterIndex,                    // The text store index
           _text.Length - textSourceCharacterIndex,     // The text store length
           new CustomTextRunProperties());              // The layout and rendering properties
    }

    // Return an end-of-paragraph indicator if there is no more text source.
    return new TextEndOfParagraph(1);
}
' Retrieve the next formatted text run for the text source.
Public Overrides Function GetTextRun(ByVal textSourceCharacterIndex As Integer) As TextRun
    ' Determine whether the text source index is in bounds.
    If textSourceCharacterIndex < 0 Then
        Throw New ArgumentOutOfRangeException("textSourceCharacterIndex", "Value must be greater than 0.")
    End If

    ' Determine whether the text source index has exceeded or equaled the text source length.
    If textSourceCharacterIndex >= _text.Length Then
        ' Return an end-of-paragraph indicator -- a TextEndOfParagraph object is a special type of text run.
        Return New TextEndOfParagraph(1)
    End If

    ' Create and return a TextCharacters object, which is formatted according to
    ' the current layout and rendering properties.
    If textSourceCharacterIndex < _text.Length Then
        ' The TextCharacters object is a special type of text run that contains formatted text.
        Return New TextCharacters(_text, textSourceCharacterIndex, _text.Length - textSourceCharacterIndex, New CustomTextRunProperties()) ' The layout and rendering properties -  The text store length -  The text store index -  The text store
    End If

    ' Return an end-of-paragraph indicator if there is no more text source.
    Return New TextEndOfParagraph(1)
End Function

注釈

テキスト実行は、1 つのプロパティ セットを共有する文字のシーケンスです。 フォント スタイル、前景色、フォント ファミリ、その他の書式設定効果など、書式を変更すると、テキストの実行が中断されます。 次の例は、テキスト文字列に対する書式設定の変更によって一連のテキスト実行がどのように行われるかを示しています。各テキスト実行には、一般的な書式設定プロパティのセットがあります。

このクラスは TextRun 、いくつかの種類のテキスト コンテンツを表す型階層のルートです TextFormatter。 派生 TextRun する各クラスは、個別の種類のテキスト コンテンツを表します。

クラス 説明
TextRun 階層のルート。 同じ文字プロパティのセットを共有する文字のグループを定義します。
TextCharacters 個別の物理書体から文字グリフのコレクションを定義します。
TextEmbeddedObject コンテンツ全体の測定、ヒット テスト、描画を個別のエンティティとして実行するテキスト コンテンツの種類を定義します。 この種類のコンテンツの例として、テキスト行の中央にあるボタンがあります。
TextEndOfLine 改行文字コードを定義します。
TextEndOfParagraph 段落区切り文字コードを定義します。 TextEndOfLineから派生します。
TextEndOfSegment セグメント区切りマーカーを定義します。
TextHidden 表示されない文字の範囲を定義します。
TextModifier 変更スコープの先頭を定義します。

コンストラクター

TextRun()

TextRun オブジェクトのインスタンスを作成します。

プロパティ

CharacterBufferReference

テキスト ラン文字バッファーへの参照を取得します。

Length

テキスト ラン内の文字数を取得します。

Properties

タイプフェイスや前景ブラシなど、テキスト ラン内のすべての文字が共有するテキスト プロパティのセットを取得します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください