Timeline.CurrentGlobalSpeedInvalidated 이벤트

정의

Timeline Clock의 진행 속도가 변경될 때 발생됩니다.

public:
 event EventHandler ^ CurrentGlobalSpeedInvalidated;
public event EventHandler CurrentGlobalSpeedInvalidated;
member this.CurrentGlobalSpeedInvalidated : EventHandler 
Public Custom Event CurrentGlobalSpeedInvalidated As EventHandler 

이벤트 유형

예제

다음 예제에서는 이벤트에 등록 하는 방법을 보여 있습니다 CurrentGlobalSpeedInvalidated .

/*

   This example shows how to register for the
   CurrentGlobalSpeedInvalidated event
   using a Timeline. 

*/

using System;
using System.Windows;
using System.Windows.Navigation;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Input;

namespace Microsoft.Samples.Animation.TimingBehaviors
{

    public class TimelineCurrentGlobalSpeedInvalidatedExample : Page {

        private TextBlock currentTimeTextBlock;
        public TimelineCurrentGlobalSpeedInvalidatedExample()
        {
            
            // Create a name scope.
            NameScope.SetNameScope(this, new NameScope());
            
            WindowTitle = "GetAnimationBaseValue Example";
            StackPanel myPanel = new StackPanel();
            myPanel.Margin = new Thickness(20);     
            
            // Create a rectangle.
            Rectangle animatedRectangle = new Rectangle();
            animatedRectangle.Width = 100;
            animatedRectangle.Height = 50;
            animatedRectangle.Margin = new Thickness(50);
            animatedRectangle.Fill = Brushes.Orange;
            animatedRectangle.Stroke = Brushes.Gray;
            animatedRectangle.StrokeThickness = 2;
            
            // Create a RotateTransform.
            RotateTransform animatedTransform = new RotateTransform();
            animatedTransform.Angle = 0;
            this.RegisterName("animatedTransform", animatedTransform);
            animatedRectangle.RenderTransform = animatedTransform;
            animatedRectangle.RenderTransformOrigin = new Point(0.5,0.5);
            myPanel.Children.Add(animatedRectangle);
            this.Content = myPanel;

            // Create a TextBlock to show the storyboard's current time.
            currentTimeTextBlock = new TextBlock();
            myPanel.Children.Add(currentTimeTextBlock);
            
            // Animate the RotateTransform's angle using a Storyboard.
            DoubleAnimation angleAnimation = new DoubleAnimation(0,360, TimeSpan.FromSeconds(5));
            angleAnimation.RepeatBehavior = RepeatBehavior.Forever;
            angleAnimation.AutoReverse = true;
            Storyboard.SetTargetName(angleAnimation, "animatedTransform");
            Storyboard.SetTargetProperty(angleAnimation, 
                new PropertyPath(RotateTransform.AngleProperty));
  
            Storyboard theStoryboard = new Storyboard();
            theStoryboard.Children.Add(angleAnimation);            
            
            // Register the CurrentGlobalSpeedInvalidated event.
            // You must register for events before you begin 
            // the storyboard.
            angleAnimation.CurrentGlobalSpeedInvalidated += 
                new EventHandler(angleAnimation_CurrentGlobalSpeedInvalidated);
            
            // Start the storyboard.
            theStoryboard.Begin(animatedRectangle, true);
        }
        
        private void angleAnimation_CurrentGlobalSpeedInvalidated(object sender, EventArgs e)
        {
            
            // Sender is the clock that was created for the DoubleAnimation.
            Clock doubleAnimationClock = (Clock)sender;
            
            // Update the TextBlock with the time of its parent.
            currentTimeTextBlock.Text = doubleAnimationClock.Parent.CurrentTime.ToString();       
        }
    }
}
'
'
'   This example shows how to register for the
'   CurrentGlobalSpeedInvalidated event
'   using a Timeline. 
'
'

Imports System.Windows
Imports System.Windows.Navigation
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports System.Windows.Controls
Imports System.Windows.Input

Namespace Microsoft.Samples.Animation.TimingBehaviors


    Public Class TimelineCurrentGlobalSpeedInvalidatedExample
        Inherits Page


        Private currentTimeTextBlock As TextBlock
        Public Sub New()

            ' Create a name scope.
            NameScope.SetNameScope(Me, New NameScope())

            WindowTitle = "GetAnimationBaseValue Example"
            Dim myPanel As New StackPanel()
            myPanel.Margin = New Thickness(20)

            ' Create a rectangle.
            Dim animatedRectangle As New Rectangle()
            With animatedRectangle
                .Width = 100
                .Height = 50
                .Margin = New Thickness(50)
                .Fill = Brushes.Orange
                .Stroke = Brushes.Gray
                .StrokeThickness = 2
            End With

            ' Create a RotateTransform.
            Dim animatedTransform As New RotateTransform()
            animatedTransform.Angle = 0
            Me.RegisterName("animatedTransform", animatedTransform)
            animatedRectangle.RenderTransform = animatedTransform
            animatedRectangle.RenderTransformOrigin = New Point(0.5, 0.5)
            myPanel.Children.Add(animatedRectangle)
            Me.Content = myPanel

            ' Create a TextBlock to show the storyboard's current time.
            currentTimeTextBlock = New TextBlock()
            myPanel.Children.Add(currentTimeTextBlock)

            ' Animate the RotateTransform's angle using a Storyboard.
            Dim angleAnimation As New DoubleAnimation(0, 360, TimeSpan.FromSeconds(5))
            angleAnimation.RepeatBehavior = RepeatBehavior.Forever
            angleAnimation.AutoReverse = True
            Storyboard.SetTargetName(angleAnimation, "animatedTransform")
            Storyboard.SetTargetProperty(angleAnimation, New PropertyPath(RotateTransform.AngleProperty))

            Dim theStoryboard As New Storyboard()
            theStoryboard.Children.Add(angleAnimation)

            ' Register the CurrentGlobalSpeedInvalidated event.
            ' You must register for events before you begin 
            ' the storyboard.
            AddHandler angleAnimation.CurrentGlobalSpeedInvalidated, AddressOf angleAnimation_CurrentGlobalSpeedInvalidated

            ' Start the storyboard.
            theStoryboard.Begin(animatedRectangle, True)

        End Sub

        Private Sub angleAnimation_CurrentGlobalSpeedInvalidated(ByVal sender As Object, ByVal e As EventArgs)

            ' Sender is the clock that was created for the DoubleAnimation.
            Dim doubleAnimationClock As Clock = CType(sender, Clock)

            ' Update the TextBlock with the time of its parent.
            currentTimeTextBlock.Text = doubleAnimationClock.Parent.CurrentTime.ToString()
        End Sub



    End Class

End Namespace

설명

타임라인 시계의 현재 글로벌 속도는 다음과 같은 상황에서 변경됩니다.

  • 클록은 타임라인 AutoReverse 설정으로 인해 방향을 변경합니다.

  • 타임라인 또는 속성 설정으로 인해 시계가 AccelerationRatio 가속되거나 DecelerationRatio 감속됩니다.

  • 시계가 일시 중지되거나 다시 시작됩니다.

  • 시계가 비활성 상태가 되거나 다시 활성화됩니다.

  • CurrentGlobalSpeed 클록의 부모 변경 내용 중 하나의 입니다.

CurrentGlobalSpeedInvalidated 이벤트는 타임라인 시계가 일시 중지되는 시기를 추적하는 데 유용합니다. 이벤트 처리기에서 스토리보드의 GetCurrentGlobalSpeed 메서드를 사용하거나 클록의 속성을 검사 시계가 IsPaused 일시 중지되었는지 확인합니다. 이 값을 이전에 캐시된 값과 비교하여 변경 여부를 확인합니다.

이벤트 처리기의 EventHandler 매개 변수는 Object 타임라인 입니다Clock.

이 이벤트 처리기는 타임라인 연결된 것처럼 보이지만 실제로 이 타임라인 대해 만든 에 등록됩니다Clock. 자세한 내용은 타이밍 이벤트 개요를 참조하세요.

적용 대상

추가 정보