語言

TextEffect 建構函式

定義

初始化 TextEffect 類別的新執行個體。

多載

名稱 Description
TextEffect()

初始化 TextEffect 類別的新執行個體。

TextEffect(Transform, Brush, Geometry, Int32, Int32)

透過指定類別屬性值來初始化該類別的新 TextEffect 實例。

TextEffect()

初始化 TextEffect 類別的新執行個體。

public:
 TextEffect();
public TextEffect();
Public Sub New ()

範例

以下程式碼範例說明如何建立 TextEffect,設定其屬性,並將其加入指定文字物件的 。TextEffectCollection

// Create and configure a simple color animation sequence.  Timespan is in 1000ns ticks.
ColorAnimation colorAnimation =
    new ColorAnimation(Colors.Maroon, Colors.White, new Duration(new TimeSpan(1000000)));
colorAnimation.AutoReverse = true;
colorAnimation.RepeatBehavior = RepeatBehavior.Forever;

// Create a new brush and apply the color animation.
SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Black);
solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);

// Create a new TextEffect object. Set the foreground to the color-animated brush.
TextEffect textEffect = new TextEffect();
textEffect.Foreground = solidColorBrush;

// Apply the TextEffect to the entire range of characters.
textEffect.PositionStart = 0;
textEffect.PositionCount = int.MaxValue;

// Create a new text Run, and add the TextEffect to the TextEffectCollection of the Run.
Run flickerRun = new Run("Text that flickers...");
flickerRun.TextEffects = new TextEffectCollection();
flickerRun.TextEffects.Add(textEffect);

MyFlowDocument.Blocks.Add(new Paragraph(flickerRun));
' Create and configure a simple color animation sequence.  Timespan is in 1000ns ticks.
Dim colorAnimation As New ColorAnimation(Colors.Maroon, Colors.White, New Duration(New TimeSpan(1000000)))
colorAnimation.AutoReverse = True
colorAnimation.RepeatBehavior = RepeatBehavior.Forever

' Create a new brush and apply the color animation.
Dim solidColorBrush As New SolidColorBrush(Colors.Black)
solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation)

' Create a new TextEffect object. Set the foreground to the color-animated brush.
Dim textEffect As New TextEffect()
textEffect.Foreground = solidColorBrush

' Apply the TextEffect to the entire range of characters.
textEffect.PositionStart = 0
textEffect.PositionCount = Integer.MaxValue

' Create a new text Run, and add the TextEffect to the TextEffectCollection of the Run.
Dim flickerRun As New Run("Text that flickers...")
flickerRun.TextEffects = New TextEffectCollection()
flickerRun.TextEffects.Add(textEffect)

MyFlowDocument.Blocks.Add(New Paragraph(flickerRun))

適用於

TextEffect(Transform, Brush, Geometry, Int32, Int32)

透過指定類別屬性值來初始化該類別的新 TextEffect 實例。

public:
 TextEffect(System::Windows::Media::Transform ^ transform, System::Windows::Media::Brush ^ foreground, System::Windows::Media::Geometry ^ clip, int positionStart, int positionCount);
public TextEffect(System.Windows.Media.Transform transform, System.Windows.Media.Brush foreground, System.Windows.Media.Geometry clip, int positionStart, int positionCount);
new System.Windows.Media.TextEffect : System.Windows.Media.Transform * System.Windows.Media.Brush * System.Windows.Media.Geometry * int * int -> System.Windows.Media.TextEffect
Public Sub New (transform As Transform, foreground As Brush, clip As Geometry, positionStart As Integer, positionCount As Integer)

參數

transform
Transform

Transform這個 被應用於 TextEffect。

foreground
Brush

將 Brush 應用於 TextEffect的內容。

clip
Geometry

的裁剪區域 TextEffect。

positionStart
Int32

就是該詞 TextEffect 適用的文本起始位置。

positionCount
Int32

是該詞 TextEffect 適用於文本中位置的數量。

範例

以下程式碼範例說明如何呼叫 TextEffect 建構子。 注意此時, transform 和 clip 參數被設定為 null,因為不需要這些參數值。

// Create a new TextEffect object, setting only the foreground brush, position start, and position count.
TextEffect textEffect = new TextEffect(null, solidColorBrush, null, 0, int.MaxValue);
' Create a new TextEffect object, setting only the foreground brush, position start, and position count.
Dim textEffect As New TextEffect(Nothing, solidColorBrush, Nothing, 0, Integer.MaxValue)

適用於