Cet article a fait l'objet d'une traduction manuelle. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. |
Traduction
Source
|
Timeline.CurrentTimeInvalidated, événement
Se produit lorsque la propriété CurrentTime du Clock de la chronologie est mise à jour.
Assembly : PresentationCore (dans PresentationCore.dll)
XMLNS pour XAML : http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Utilisez l'événement CurrentStateInvalidated pour être notifié en cas de mise à jour du CurrentTime du Clock d'une chronologie.
Le paramètre Object du gestionnaire d'événements EventHandler correspond au Clock de la chronologie.
Même si ce gestionnaire d'événements semble être associé à une chronologie, il s'inscrit en fait avec le Clock créé pour la chronologie en question. Pour plus d'informations, consultez Vue d'ensemble des événements de minutage.
L'exemple suivant montre comment inscrire l'événement 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(); } } }
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.