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.CurrentGlobalSpeedInvalidated, événement
Se produit lorsque le taux auquel l'heure progresse pour l'horloge de la chronologie change.
Assembly : PresentationCore (dans PresentationCore.dll)
XMLNS pour XAML : http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
La vitesse globale actuelle de l'horloge d'une chronologie change dans les cas suivants :
-
L'horloge change de direction en raison du paramètre AutoReverse de sa chronologie.
-
L'horloge accélère ou décélère en raison des paramètres de propriété AccelerationRatio ou DecelerationRatio de sa chronologie.
-
L'horloge fait l'objet d'une suspension ou d'une reprise.
-
L'horloge devient inactive ou se réactive.
-
Le CurrentGlobalSpeed de l'un des parents de l'horloge change.
L'événement CurrentGlobalSpeedInvalidated s'avère utile pour connaître le moment auquel l'horloge d'une chronologie est suspendue ; dans le gestionnaire d'événements, utilisez la méthode GetCurrentGlobalSpeed de la table de montage séquentiel ou vérifiez la propriété IsPaused de l'horloge pour savoir si son horloge est suspendue ; comparez le résultat obtenu à une valeur précédemment mise en cache pour déterminer s'il est différent.
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 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(); } } }
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.