Timeline.CurrentGlobalSpeedInvalidated Olay

Tanım

Zaman çizelgesinin saatinin ilerleme hızı değiştiğinde gerçekleşir.

C#
public event EventHandler CurrentGlobalSpeedInvalidated;

Olay Türü

Örnekler

Aşağıdaki örnek, olaya nasıl kaydolacaklarını CurrentGlobalSpeedInvalidated gösterir.

C#
/*

   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();       
        }
    }
}

Açıklamalar

Zaman çizelgesi saatinin geçerli genel hızı aşağıdaki koşullarda değişir:

  • Zaman çizelgesinin AutoReverse ayarı nedeniyle saat yönünü değiştirir.

  • Zaman çizelgesi AccelerationRatio veya özellik ayarları nedeniyle saat hızlanır veya DecelerationRatio yavaşlatılır.

  • Saat duraklatıldı veya sürdürüldü.

  • Saat devre dışı duruma gelir veya yeniden etkinleştirilir.

  • Saatin CurrentGlobalSpeed üst öğe değişikliklerinden biri.

Olay CurrentGlobalSpeedInvalidated , zaman çizelgesinin saati duraklatıldığında izlemek için yararlıdır; olay işleyicinizde görsel taslakınızın GetCurrentGlobalSpeed yöntemini kullanın veya saatinin duraklatılıp duraklatılmadığını belirlemek için saatin IsPaused özelliğini denetleyin; değiştirilip değiştirilmediğini belirlemek için bunu önceden önbelleğe alınmış bir değerle karşılaştırın.

Object Olay işleyicisinin EventHandler parametresi zaman çizelgesinin Clockparametresidir.

Bu olay işleyicisi bir zaman çizelgesiyle ilişkilendirilmiş gibi görünse de, aslında bu zaman çizelgesi için oluşturulan ile Clock kaydeder. Daha fazla bilgi için bkz . Zamanlama Olaylarına Genel Bakış.

Şunlara uygulanır

Ürün Sürümler
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Ayrıca bkz.