WPF animation - (c) timeline (the TimeLine) (rpm) WPF animation - (c) timeline (the TimeLine)

Timeline (the TimeLine) represents time period. It provides attribute allows the length of the control period, start time, number of repetitions, schedule the time period the speed and so on. TimeLine several built-in WPF follows:

  • AnimationTimeline  : It has been introduced, mainly for the transition property, which is the most common animation.
  • MediaTimeline: timeline for controlling playback of media files.
  • ParallelTimeline: ParallelTimeline  a timeline can be grouped other timeline can be used to implement more complex animations.
  • Your storyboard  : a special  ParallelTimeline , objects and attributes can be provided for target information contained in the time line. It is frequently used in XAML, then special described later.
  • It may contain other: TimelineGroup  Timeline  object  Timeline  abstract class object.

 

Common attributes:

  • Duration: the length of time animation
  • RepeatBehavior: repetitive behavior (repetitions)
  • FillBehavior: after the end of the animation behavior (the held state of the animation or return to the initial state)
  • AutoReverse: Repeat the animation in reverse order
  • SpeedRatio: animation speed (acceleration or deceleration for playback)
  • BeginTime: animation playback start time

 

Timeline control:

So far, although we can create and execute animation, but only through UIElement. BeginAnimation execution start animation, interactive animation can not control. In WPF, a series of control operations is also provided on the timeline, such as: start, stop, pause. They are carried out by the Controller property Clock object. Here is a simple example:

    var widthAnimation = new DoubleAnimation()
    {
        From = 0,
        To = 320,
        Duration = TimeSpan.FromSeconds(5),
    };

    var clock = widthAnimation.CreateClock();
    button.ApplyAnimationClock(WidthProperty, clock);

    await Task.Delay(3000);
    clock.Controller.Pause();

As can be seen from this code, the step of controlling the general timeline as follows:

  1. Creating the clock object Clock function by CreateClock
  2. . ApplyAnimationClock function enables animation support clocked by UIElement
  3. Use Clock. Controller method to control the animation

More detailed examples can be found in the MSDN documentation: interactively control the clock

In addition to providing an interactive method that in the Controller, Clock object also provides a range of properties and events to help us get status, common are:

  • CurrentProgress current progress
  • CurrentState current state
  • CurrentTime current playing time
  • Are IsPaused is paused
  • NaturalDuration duration of the animation

Also it provides a series of events to take the initiative to inform the state of change, common events:

  • Completed: notice at the end of the animation
  • When the playback rate change notification CurrentGlobalSpeedInvalidated,
  • Notification of status changes CurrentStateInvalidated
  • Notification of CurrentTimeInvalidated time to play
  • Notice RemoveRequested remove animation time

Is there, so, can these events or changes in TimeLine object when not in use Clock objects of these states. If you want to understand timing system work more income, you can see animation and timing system overview article.

Further, some special TimeLine objects, such as the package itself Storyboard control the animation content, the animation can be controlled directly. About the need to introduce more content Storyboard, followed by re-writing articles presented separately.

 

References:

 
Category:  WPF

Timeline (the TimeLine) represents time period. It provides attribute allows the length of the control period, start time, number of repetitions, schedule the time period the speed and so on. TimeLine several built-in WPF follows:

  • AnimationTimeline  : It has been introduced, mainly for the transition property, which is the most common animation.
  • MediaTimeline: timeline for controlling playback of media files.
  • ParallelTimeline: ParallelTimeline  a timeline can be grouped other timeline can be used to implement more complex animations.
  • Your storyboard  : a special  ParallelTimeline , objects and attributes can be provided for target information contained in the time line. It is frequently used in XAML, then special described later.
  • It may contain other: TimelineGroup  Timeline  object  Timeline  abstract class object.

 

Common attributes:

  • Duration: the length of time animation
  • RepeatBehavior: repetitive behavior (repetitions)
  • FillBehavior: after the end of the animation behavior (the held state of the animation or return to the initial state)
  • AutoReverse: Repeat the animation in reverse order
  • SpeedRatio: animation speed (acceleration or deceleration for playback)
  • BeginTime: animation playback start time

 

Timeline control:

So far, although we can create and execute animation, but only through UIElement. BeginAnimation execution start animation, interactive animation can not control. In WPF, a series of control operations is also provided on the timeline, such as: start, stop, pause. They are carried out by the Controller property Clock object. Here is a simple example:

    var widthAnimation = new DoubleAnimation()
    {
        From = 0,
        To = 320,
        Duration = TimeSpan.FromSeconds(5),
    };

    var clock = widthAnimation.CreateClock();
    button.ApplyAnimationClock(WidthProperty, clock);

    await Task.Delay(3000);
    clock.Controller.Pause();

As can be seen from this code, the step of controlling the general timeline as follows:

  1. Creating the clock object Clock function by CreateClock
  2. . ApplyAnimationClock function enables animation support clocked by UIElement
  3. Use Clock. Controller method to control the animation

More detailed examples can be found in the MSDN documentation: interactively control the clock

In addition to providing an interactive method that in the Controller, Clock object also provides a range of properties and events to help us get status, common are:

  • CurrentProgress current progress
  • CurrentState current state
  • CurrentTime current playing time
  • Are IsPaused is paused
  • NaturalDuration duration of the animation

Also it provides a series of events to take the initiative to inform the state of change, common events:

  • Completed: notice at the end of the animation
  • When the playback rate change notification CurrentGlobalSpeedInvalidated,
  • Notification of status changes CurrentStateInvalidated
  • Notification of CurrentTimeInvalidated time to play
  • Notice RemoveRequested remove animation time

Is there, so, can these events or changes in TimeLine object when not in use Clock objects of these states. If you want to understand timing system work more income, you can see animation and timing system overview article.

Further, some special TimeLine objects, such as the package itself Storyboard control the animation content, the animation can be controlled directly. About the need to introduce more content Storyboard, followed by re-writing articles presented separately.

 

References:

Guess you like

Origin www.cnblogs.com/LiZhongZhongY/p/11080817.html