Timeline.CurrentTimeInvalidated イベント
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
タイムラインの Clock の CurrentTime プロパティが更新されたときに発生します。
public:
event EventHandler ^ CurrentTimeInvalidated;
public event EventHandler CurrentTimeInvalidated;
member this.CurrentTimeInvalidated : EventHandler
Public Custom Event CurrentTimeInvalidated As EventHandler
イベントの種類
例
次の例は、イベントに登録する方法を CurrentTimeInvalidated 示しています。
/*
This example shows how to register for the
CurrentTimeInvalidated 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 TimelineCurrentTimeInvalidatedExample : Page {
private TextBlock currentTimeTextBlock;
public TimelineCurrentTimeInvalidatedExample()
{
// 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;
Storyboard.SetTargetName(angleAnimation, "animatedTransform");
Storyboard.SetTargetProperty(angleAnimation,
new PropertyPath(RotateTransform.AngleProperty));
Storyboard theStoryboard = new Storyboard();
theStoryboard.Children.Add(angleAnimation);
// Register the CurrentTimeInvalidated event.
// You must register for events before you begin
// the storyboard.
theStoryboard.CurrentTimeInvalidated +=
new EventHandler(storyboard_CurrentTimeInvalidated);
// Start the storyboard.
theStoryboard.Begin(animatedRectangle, true);
}
private void storyboard_CurrentTimeInvalidated(object sender, EventArgs e)
{
// Sender is the clock that was created for this storyboard.
Clock storyboardClock = (Clock)sender;
// Update the TextBlock with the storyboard's current time.
currentTimeTextBlock.Text = storyboardClock.CurrentTime.ToString();
}
}
}
'
'
' This example shows how to register for the
' CurrentTimeInvalidated 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 TimelineCurrentTimeInvalidatedExample
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
Storyboard.SetTargetName(angleAnimation, "animatedTransform")
Storyboard.SetTargetProperty(angleAnimation, New PropertyPath(RotateTransform.AngleProperty))
Dim theStoryboard As New Storyboard()
theStoryboard.Children.Add(angleAnimation)
' Register the CurrentTimeInvalidated event.
' You must register for events before you begin
' the storyboard.
AddHandler theStoryboard.CurrentTimeInvalidated, AddressOf storyboard_CurrentTimeInvalidated
' Start the storyboard.
theStoryboard.Begin(animatedRectangle, True)
End Sub
Private Sub storyboard_CurrentTimeInvalidated(ByVal sender As Object, ByVal e As EventArgs)
' Sender is the clock that was created for this storyboard.
Dim storyboardClock As Clock = CType(sender, Clock)
' Update the TextBlock with the storyboard's current time.
currentTimeTextBlock.Text = storyboardClock.CurrentTime.ToString()
End Sub
End Class
End Namespace
注釈
タイムラインの CurrentStateInvalidated が更新されたときに通知を受け取る場合CurrentTimeは、 イベントをClock使用します。
Objectイベント ハンドラーの EventHandler パラメーターは、タイムラインの Clockです。
このイベント ハンドラーはタイムラインに関連付けられているように見えますが、実際にはこのタイムライン用に作成された にClock登録されます。 詳細については、「 タイミング イベントの概要」を参照してください。
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET