Exemplo n.º 1
0
        /// <overloads>
        /// <summary>
        /// Assigns this animation tree to objects or properties.
        /// </summary>
        /// </overloads>
        ///
        /// <summary>
        /// Assigns this animation tree to the specified set of objects.
        /// </summary>
        /// <param name="objects">The collection of animatable object.</param>
        internal virtual void AssignTo(IEnumerable <IAnimatableObject> objects)
        {
            string objectName = Animation.TargetObject;

            if (String.IsNullOrEmpty(objectName))
            {
                // No target object set. All objects are potential targets.
                foreach (var child in Children)
                {
                    child.AssignTo(objects);
                }
            }
            else
            {
                // Find target object.
                IAnimatableObject targetObject = null;
                foreach (var obj in objects)
                {
                    if (obj.Name == objectName)
                    {
                        targetObject = obj;
                        break;
                    }
                }

                if (targetObject != null)
                {
                    // Assign children to the selected object.
                    foreach (var child in Children)
                    {
                        child.AssignTo(targetObject);
                    }
                }
            }
        }
Exemplo n.º 2
0
    /// <inheritdoc/>
    public void UpdateAndApplyAnimation(IAnimatableObject animatedObject)
    {
      if (animatedObject == null)
        return;

      foreach (var animatedProperty in animatedObject.GetAnimatedProperties())
        UpdateAndApplyAnimation(animatedProperty);
    }
Exemplo n.º 3
0
    /// <inheritdoc/>
    public void StopAnimation(IAnimatableObject animatedObject)
    {
      if (animatedObject == null)
        return;

      foreach (var animatedProperty in animatedObject.GetAnimatedProperties())
        StopAnimation(animatedProperty);
    }
Exemplo n.º 4
0
        /// <inheritdoc/>
        internal override void AssignTo(IAnimatableObject obj)
        {
            var property = GetTargetProperty(obj);

            if (property != null)
            {
                Property = property;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Assigns this animation tree to the specified object.
        /// </summary>
        /// <param name="obj">The animatable object.</param>
        internal virtual void AssignTo(IAnimatableObject obj)
        {
            // Note: In this case we do not check whether Animation.TargetObject matches obj.Name.
            // This method should only be called to explicitly assign the animation to the given object.

            foreach (var child in Children)
            {
                child.AssignTo(obj);
            }
        }
Exemplo n.º 6
0
    /// <inheritdoc/>
    public AnimationController CreateController(ITimeline animation, IAnimatableObject targetObject)
    {
      if (targetObject == null)
        throw new ArgumentNullException("targetObject");
      if (animation == null)
        throw new ArgumentNullException("animation");

      var animationInstance = animation.CreateInstance();
      animationInstance.AssignTo(targetObject);
      return new AnimationController(this, animationInstance);
    }
Exemplo n.º 7
0
    /// <inheritdoc/>
    public bool IsAnimated(IAnimatableObject animatableObject)
    {
      if (animatableObject == null)
        throw new ArgumentNullException("animatableObject");

      foreach (var animatableProperty in animatableObject.GetAnimatedProperties())
        if (IsAnimated(animatableProperty))
          return true;

      return false;
    }
Exemplo n.º 8
0
        private IAnimatableProperty <T> GetTargetProperty(IAnimatableObject obj)
        {
            // Note: In this case we do not check whether Animation.TargetObject matches obj.Name.
            // This method should only be called to explicitly assign the animation to the given object.

            var propertyName = Animation.TargetProperty;

            if (!String.IsNullOrEmpty(propertyName))
            {
                return(obj.GetAnimatableProperty <T>(propertyName));
            }

            return(null);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Determines whether this animation tree can be assigned to the specified object.
        /// </summary>
        /// <param name="obj">The animatable object.</param>
        /// <returns>
        /// <see langword="true"/> if this animation instance (or one of its children) can be assigned
        /// to <paramref name="obj"/>; otherwise, <see langword="false"/>.
        /// </returns>
        internal virtual bool IsAssignableTo(IAnimatableObject obj)
        {
            // Note: In this case we do not check whether Animation.TargetObject matches obj.Name.
            // This method should only be called to explicitly assign the animation to the given object.

            foreach (var child in Children)
            {
                if (child.IsAssignableTo(obj))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 10
0
        /// <inheritdoc/>
        public AnimationController StartAnimation(ITimeline animation, IAnimatableObject targetObject, AnimationTransition transition)
        {
            if (targetObject == null)
            {
                throw new ArgumentNullException("targetObject");
            }
            if (animation == null)
            {
                throw new ArgumentNullException("animation");
            }

            var animationInstance = animation.CreateInstance();

            animationInstance.AssignTo(targetObject);
            StartAnimation(animationInstance, transition);
            return(new AnimationController(this, animationInstance));
        }
Exemplo n.º 11
0
        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        /// <inheritdoc/>
        public bool IsAnimated(IAnimatableObject animatableObject)
        {
            if (animatableObject == null)
            {
                throw new ArgumentNullException("animatableObject");
            }

            foreach (var animatableProperty in animatableObject.GetAnimatedProperties())
            {
                if (IsAnimated(animatableProperty))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 12
0
        /// <overloads>
        /// <summary>
        /// Determines whether the animation tree can be assigned to the given objects or properties.
        /// </summary>
        /// </overloads>
        ///
        /// <summary>
        /// Determines whether this animation tree can be assigned to the specified set of objects.
        /// </summary>
        /// <param name="objects">The set of animatable objects.</param>
        /// <returns>
        /// <see langword="true"/> if this animation instance (or one of its children) can be assigned
        /// to <paramref name="objects"/>; otherwise, <see langword="false"/>.
        /// </returns>
        internal virtual bool IsAssignableTo(IEnumerable <IAnimatableObject> objects)
        {
            string objectName = Animation.TargetObject;

            if (String.IsNullOrEmpty(objectName))
            {
                // No target object set. All objects are potential targets.
                foreach (var child in Children)
                {
                    if (child.IsAssignableTo(objects))
                    {
                        return(true);
                    }
                }
            }
            else
            {
                // Find target object.
                IAnimatableObject targetObject = null;
                foreach (var obj in objects)
                {
                    if (obj.Name == objectName)
                    {
                        targetObject = obj;
                        break;
                    }
                }

                if (targetObject != null)
                {
                    // Check whether any child can be assigned to the target object.
                    foreach (var child in Children)
                    {
                        if (child.IsAssignableTo(targetObject))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 13
0
 /// <inheritdoc/>
 internal override bool IsAssignableTo(IAnimatableObject obj)
 {
     return(GetTargetProperty(obj) != null);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Starts building an AnimationSequence for the given object.
 /// The generated animation is managed by this object.
 /// </summary>
 /// <typeparam name="TargetObjectType">The type of the target object.</typeparam>
 /// <param name="animationHost">The host object of the animation.</param>
 /// <param name="animatableObject">The object to be animated.</param>
 public static IAnimationSequenceBuilder <TargetObjectType> BuildAnimationSequence <TargetObjectType>(this IAnimatableObject animationHost, TargetObjectType animatableObject)
     where TargetObjectType : class
 {
     return(animationHost.AnimationHandler.BuildAnimationSequence <TargetObjectType>(animatableObject));
 }
Exemplo n.º 15
0
 /// <inheritdoc/>
 public AnimationController StartAnimation(ITimeline animation, IAnimatableObject targetObject)
 {
   return StartAnimation(animation, targetObject, null);
 }