Click or drag to resize
DigitalRuneIAnimatablePropertyT Interface
Represents a property of a certain type that can be animated.

Namespace: DigitalRune.Animation
Assembly: DigitalRune (in DigitalRune.dll) Version: 1.20.0.0 (1.20.1.14552)
Syntax
public interface IAnimatableProperty<T> : IAnimatableProperty

Type Parameters

T
The type of the property.

The IAnimatablePropertyT type exposes the following members.

Properties
  NameDescription
Public propertyAnimationValue
Gets or sets the animation value.
Public propertyBaseValue
Gets the base value.
Public propertyHasBaseValue
Gets a value indicating whether this property has a base value.
(Inherited from IAnimatableProperty.)
Public propertyIsAnimated
Gets or sets a value indicating whether this property is animated by the animation system.
(Inherited from IAnimatableProperty.)
Top
Remarks

An IAnimatableProperty is a property of a certain type that can be animated. It can have two values: a base value and an animation value.

Base Value: The base value is the value of the property that is valid when no animations are active. The base value is optional - not all properties that implement IAnimatablePropertyT need to have a base value. The properties HasBaseValue and BaseValue need to be set by the object that implements the interface. The animation system reads the base value but does not change it. The base value is used by certain types of animations: For example, additive animations will add the result of the animations to the base value value. Another example are "From-To-Animations": If only the "To" value is defined then the animation will animate from the base value of the property to the "To" value defined in the animation.

Animation Value: The animation value of the property is determined by the animations that are controlling the property. The properties IsAnimated and AnimationValue are set by the animations system and should be treated as read-only. IsAnimated is when an animation is active; indicates that no animations are active. In this case the base value, if available, should be treated as the effective value of the property.

Examples
The following examples shows how an IAnimatablePropertyT could be implemented.
C#
public class AnimatableProperty<T> : IAnimatableProperty<T>
{
  private T _baseValue;
  private T _animationValue;
  private bool _isAnimated;

  #region ----- IAnimatableProperty -----
  bool IAnimatableProperty.HasBaseValue
  {
    get { return true; }
  }

  object IAnimatableProperty.BaseValue
  {
    get { return _baseValue; }
  }

  bool IAnimatableProperty.IsAnimated
  {
    get { return _isAnimated; }
    set { _isAnimated = value; }
  }

  object IAnimatableProperty.AnimationValue
  {
    get { return _animationValue; }
  }
  #endregion

  #region ----- IAnimatableProperty<T> -----
  T IAnimatableProperty<T>.BaseValue
  {
    get { return _baseValue; }
  }

  T IAnimatableProperty<T>.AnimationValue
  {
    get { return _animationValue; }
    set { _animationValue = value; }
  }
  #endregion

  public T Value
  {
    get { return _isAnimated ? _animationValue : _baseValue; }
    set { _baseValue = value; }
  }
}

Here is another example showing how a wrapper for existing properties could look like.

C#
public class DelegateAnimatableProperty<T> : IAnimatableProperty<T>
{
  private bool _isAnimated;
  private Func<T> _getter;
  private Action<T> _setter;

  #region ----- IAnimatableProperty -----

  bool IAnimatableProperty.HasBaseValue
  {
    get { return false; }
  }

  object IAnimatableProperty.BaseValue
  {
    get { throw new NotImplementedException(); }
  }

  bool IAnimatableProperty.IsAnimated
  {
    get { return _isAnimated; }
    set { _isAnimated = value; }
  }

  object IAnimatableProperty.AnimationValue
  {
    get { return (object)_getter(); }
  }
  #endregion

  #region ----- IAnimatableProperty<T> -----

  T IAnimatableProperty<T>.BaseValue
  {
    get { throw new NotImplementedException(); }
  }

  T IAnimatableProperty<T>.AnimationValue
  {
    get { return _getter(); }
    set { _setter(value); }
  }
  #endregion

  public DelegateAnimatableProperty(Func<T> getter, Action<T> setter)
  {
    if (getter == null)
      throw new ArgumentNullException("getter");
    if (setter == null)
      throw new ArgumentNullException("setter");

    _getter = getter;
    _setter = setter;
  }
}
See Also