Click or drag to resize
AB4D logo

AnimationController Class

AnimationController class can be used to animate multiple AnimationNodeBase objects that define animation behavior. The class support starting animation (StartAnimation(Boolean) or StartAnimation(Double, Boolean)), stopping animation (StopAnimation), pausing animation (PauseAnimation), resuming paused animation (ResumeAnimation), getting animation time (GetAnimationTimeInSeconds) and current frame (GetFrameNumber) and going to specified frame (GoToFrame(Double)).
Inheritance Hierarchy
SystemObject
  Ab3d.AnimationAnimationController

Namespace: Ab3d.Animation
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.1.8864.1045
Syntax
C#
public class AnimationController : ICompositionRenderingSubscriber

The AnimationController type exposes the following members.

Constructors
 NameDescription
Public methodAnimationController Constructor
Top
Properties
 NameDescription
Public propertyAnimationNodes Gets a list of AnimationNodeBase object that are animated by this AnimationController.
Public propertyAnimationStartTime Gets a DateTime that specifies the start time of the animation (when the StartAnimation(Boolean) or StartAnimation(Double, Boolean)method was called). If animation is not started a DateTime.MinValue is returned.
Public propertyAutoRepeat Gets or set if the animation should automatically repeat itself or not. Default value is false.
Public propertyAutoReverse Gets or sets if animation should go backwards when coming to the last frame or should it start from beginning. Default value is false.
Public propertyAutoStopAnimation Gets or sets if animation is automatically stopped (calling StopAnimation method) when the animation is completed. Animation can be completed only when AutoRepeat property is false. In case AutoRepeat and AutoReverse are false the animation is completed when the LastFrameNumber is reached; when AutoReverse is true, the animation is completed when the first frame is reached again (after reversing back from the last frame). The property is used only only when StartAnimation(Boolean) or StartAnimation(Double, Boolean) method is called without parameters or with subscribeToRenderingEvent parameter set to true. Default value is true.
Public propertyCurrentFrameNumber Gets the frame number where this animation controller currently is - the same as frameNumber parameter in the last call to GoToFrame(Double) method.
Public propertyFirstFrameNumber Gets the first defined frame number for this AnimationController. This number is calculated each time with going though all AnimationNodes.
Public propertyFramesPerSecond Gets or sets a double value that specifies for how many frames per second animation advances. This does not change the rendering but the speed of animation. The frame numbers are not related to rendering frames but are defined in the KeyFrameBase and derived objects.
Public propertyIsAnimating Gets a Boolean that specifies if animation is currently running (was started and is not paused).
Public propertyIsAnimationPaused Gets a Boolean that specifies if animation was started and and is currently paused.
Public propertyIsAnimationStarted Gets a Boolean that specifies if animation was started and is not yet stopped (also returns true if animation is paused).
Public propertyLastFrameNumber Gets the last defined frame number for this AnimationController. This number is calculated each time with going though all AnimationNodes.
Top
Methods
 NameDescription
Public methodDump Writes details about this AnimationNodeBase to the Visual Studio Output window. This method calls the GetDumpString method to get details about each keyframe.
Public methodGetAnimationPauseTimeInSeconds Returns total elapsed time in seconds in which the animation was paused (time during PauseAnimation and ResumeAnimation method calls).
Public methodGetAnimationTimeInSeconds Returns time in seconds that elapsed from the start of the animation (time after calling StartAnimation(Boolean) or StartAnimation(Double, Boolean)). The pause time is not included in the returned time. If animation was not started, 0 is returned. To get the elapsed time to some specified time use the GetAnimationTimeInSeconds(DateTime) method that takes time as parameter.
Public methodGetAnimationTimeInSeconds(DateTime) Returns time in seconds that elapsed from the start of the animation to the time specified as a parameter to this method. The pause time is not included in the returned time. When animation is started with startFrameNumber parameter, then the animation time is increased by the startFrameNumber divided by FramesPerSecond. If animation was not started, 0 is returned.
Public methodGetDumpString GetDumpString virtual method can be overridden to provide detailed description of this object.
Public methodGetFrameNumber GetFrameNumber returns a double that specifies the current frame number (can be a fraction between two integer values). The number is calculated based on the current animation time (get with calling GetAnimationTimeInSeconds method). If the animation was not yet starter or first frame was not yet reached, then -1 us returned. When animation has passed the last frame and the animation is not repeating, then the last frame number is returned.
Public methodGetFrameNumber(Double) GetFrameNumber returns a double that specifies the frame number at the specified animationTimeInSeconds (can be a fraction between two integer values). If the animation was not yet starter or first frame was not yet reached, then -1 us returned. When animation has passed the last frame and the animation is not repeating, then the last frame number is returned.
Public methodGoToFrame GoToFrame method updates the objects animated with this animation node based on the specified frame number. The method calls GoToFrame(Double) method on all AnimationNodes objects.
Protected methodOnAfterFrameUpdated OnAfterFrameUpdated fires AfterFrameUpdated event
Protected methodOnAnimationCompleted OnAnimationCompleted fires AnimationCompleted event
Protected methodOnAnimationStarted OnAnimationStarted fires AnimationStarted event
Protected methodOnAnimationStopped OnAnimationStopped fires AnimationStopped event
Protected methodOnBeforeFrameUpdated OnBeforeFrameUpdated fires BeforeFrameUpdated event
Public methodPauseAnimation PauseAnimation method pauses the animation. After pausing the animation, the call to GetFrameNumber method will return the frame number at the moment of pausing the animation. To resume the animation call the ResumeAnimation method.
Public methodResumeAnimation ResumeAnimation method resumes the animation after it was paused with PauseAnimation method.
Public methodStartAnimation(Boolean) StartAnimation method starts the animation in this AnimationController. If the animation was paused, this method continues the animation (is the same as ResumeAnimation method). When the subscribeToRenderingEvent parameter is true (by default), then animation controller subscribes to the WPF's RenderingEvent and automatically updates the animated objects by calling GetFrameNumber and GoToFrame(Double) methods. If subscribeToRenderingEvent is false, user needs to manually call GetFrameNumber or other methods to update the animated objects.
Public methodStartAnimation(Double, Boolean) StartAnimation method starts the animation in this AnimationController. If the animation was paused, this method continues the animation (is the same as ResumeAnimation method). When the subscribeToRenderingEvent parameter is true (by default), then animation controller subscribes to the WPF's RenderingEvent and automatically updates the animated objects by calling GetFrameNumber and GoToFrame(Double) methods. If subscribeToRenderingEvent is false, user needs to manually call GetFrameNumber or other methods to update the animated objects.
Public methodStopAnimation StopAnimation method stops the animation. After animation has been stopped, the call to GetFrameNumber method will return the first frame (index = 0).
Top
Events
 NameDescription
Public eventAfterFrameUpdated AfterFrameUpdated is fired after the objects have been animated in the GoToFrame(Double) method.
Public eventAnimationCompleted AnimationCompleted is fired when the animation is completed. Animation can be completed only when AutoRepeat is false. In case AutoRepeat and AutoReverse are false the animation is completed when the LastFrameNumber is reached; when AutoReverse is true, the animation is completed when the first frame is reached again (after reversing back from the last frame). This event is not fired when StopAnimation method is called by the user (use AnimationStopped in this case). The event is only fired when StartAnimation(Boolean) or StartAnimation(Double, Boolean) method is called without parameters or with subscribeToRenderingEvent parameter set to true.
Public eventAnimationStarted AnimationStarted is fired when the animation is started with calling StartAnimation(Boolean) or StartAnimation(Double, Boolean) method.
Public eventAnimationStopped AnimationStopped is fired when the animation is stopped with calling StopAnimation.
Public eventBeforeFrameUpdated BeforeFrameUpdated is fired before the objects are animated in the GoToFrame(Double) method.
Top
Fields
 NameDescription
Protected fieldisGoingBackwards Specifies if animation is going backwards. This value is set in the GetFrameNumber(Double) method.
Top
See Also