TextEffectResolver.Resolve(TextPointer, TextPointer, TextEffect) 메서드

정의

텍스트 범위의 텍스트 효과를 텍스트 효과 대상의 목록으로 확인합니다.

public:
 static cli::array <System::Windows::Documents::TextEffectTarget ^> ^ Resolve(System::Windows::Documents::TextPointer ^ startPosition, System::Windows::Documents::TextPointer ^ endPosition, System::Windows::Media::TextEffect ^ effect);
public static System.Windows.Documents.TextEffectTarget[] Resolve (System.Windows.Documents.TextPointer startPosition, System.Windows.Documents.TextPointer endPosition, System.Windows.Media.TextEffect effect);
static member Resolve : System.Windows.Documents.TextPointer * System.Windows.Documents.TextPointer * System.Windows.Media.TextEffect -> System.Windows.Documents.TextEffectTarget[]
Public Shared Function Resolve (startPosition As TextPointer, endPosition As TextPointer, effect As TextEffect) As TextEffectTarget()

매개 변수

startPosition
TextPointer

시작 텍스트 포인터입니다.

endPosition
TextPointer

끝 텍스트 포인터입니다.

effect
TextEffect

텍스트에 적용할 효과입니다.

반환

TextEffectTarget[]

텍스트 범위에 해당하는 TextEffectTarget 개체의 컬렉션입니다.

예제

다음 예제에 적용 하는 방법을 보여 줍니다는 TranslateTransform, ScaleTransform, 및 RotateTransform 텍스트를 텍스트 효과입니다. 다음은 예제에 대 한 XAML입니다.

<Page  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SDKSample.TextEffectTargetExample"
    Title="TextBlock Properties Sample">

  <StackPanel>

    <RadioButton Click="teTranslate" Margin="5,0,5,0">TranslateTransform</RadioButton>
    <RadioButton Click="teScale" Margin="5,0,5,0">ScaleTransform</RadioButton>
    <RadioButton Click="teRotate" Margin="5,0,5,0">RotateTransform</RadioButton>

    <TextBlock Background="LightGray" TextWrapping="Wrap" Name="tb1">
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
      Nam laoreet dolor et dolor. Vestibulum quis nunc auctor ante dignissim venenatis. Curabitur wisi.
      Donec faucibus auctor ipsum. In fermentum dui.  Ut suscipit aliquam eros. Nullam elementum quam eu
      enim. Sed a purus id nisl imperdiet blandit. Cum sociis natoque penatibus et magnis dis parturient
      montes, nascetur ridiculus mus. Sed at quam.
    </TextBlock>

  </StackPanel>

</Page>

예제에 대한 코드 숨김은 다음과 같습니다.

using System;
using System.Windows;
using System.Collections;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Documents;

namespace SDKSample
{
    public partial class TextEffectTargetExample : Page
    {

        // Event handler for translating (moving) the text element.
        public void teTranslate(object sender, RoutedEventArgs e)
        {
            // Wipe out existing TextEffects on the TextBlock
            DisableTextEffects();

            TextEffect myEffect = new TextEffect();
            myEffect.PositionStart = 0;
            myEffect.PositionCount = 999;

            // Create a TranslateTransform that moves the TextBlock to an offset position of
            // 50,50.
            TranslateTransform myTranslateTransform = new TranslateTransform(50,50);
            myEffect.Transform = myTranslateTransform;

            // Apply the effect to the TextBlock
            EnableTextEffects(tb1, myEffect);
         }

         // Event handler for transforming the size of the text element.
        public void teScale(object sender, RoutedEventArgs e)
        {
            // Wipe out existing TextEffects on the TextBlock
            DisableTextEffects();

            TextEffect myEffect = new TextEffect();
            myEffect.PositionStart = 0;
            myEffect.PositionCount = 999;

            // Create a ScaleTransform that scales the TextBlock by 5.
            ScaleTransform myScaleTransform = new ScaleTransform(5,5);
            myEffect.Transform = myScaleTransform;

            // Apply the effect to the TextBlock
            EnableTextEffects(tb1, myEffect);
        }

        public void teRotate(object sender, RoutedEventArgs e)
        {
            // Wipe out existing TextEffects on the TextBlock
            DisableTextEffects();

            TextEffect myEffect = new TextEffect();
            myEffect.PositionStart = 0;
            myEffect.PositionCount = 999;

            // Create a ScaleTransform that rotates the text by 45 degrees.
            RotateTransform myRotateTransform = new RotateTransform(45);
            myEffect.Transform = myRotateTransform;

            // Apply the effect to the TextBlock
            EnableTextEffects(tb1, myEffect);
        }

        // Disable all existing text effects to make way for new ones.
        private void DisableTextEffects()
        {
            if (_textEffectTargets != null)
            {
                foreach (TextEffectTarget target in _textEffectTargets) 
                     target.Disable();
            }
        }

        // Enable TextEffectTargets and apply effect to TextBlock.
        private void EnableTextEffects(TextBlock tb, TextEffect effect)
        {
            _textEffectTargets = TextEffectResolver.Resolve(tb.ContentStart, tb.ContentEnd, effect);
            foreach (TextEffectTarget target in _textEffectTargets)
                target.Enable();           
        }

        private TextEffectTarget[] _textEffectTargets; 
    }
}

설명

이 메서드는 텍스트의 각 연속 블록에 대 한 범위 지정 (부모) 요소를 대상으로 하는 텍스트 효과를 만듭니다.

적용 대상