コード例 #1
0
        /// <inheritdoc/>
        internal override void RemoveFromCompositionChains(AnimationManager animationManager)
        {
            var property         = Property;
            var compositionChain = animationManager.GetCompositionChain(property, null, false);

            if (compositionChain != null)
            {
                compositionChain.Remove(this);
            }
        }
コード例 #2
0
        /// <inheritdoc/>
        internal override bool IsActive(AnimationManager animationManager)
        {
            var property         = Property;
            var compositionChain = animationManager.GetCompositionChain(property, null, false);

            if (compositionChain != null && compositionChain.Contains(this))
            {
                return(true);
            }

            return(false);
        }
コード例 #3
0
        /// <inheritdoc/>
        internal override void AddToCompositionChains(AnimationManager animationManager, HandoffBehavior handoffBehavior, AnimationInstance previousInstance)
        {
            var property = Property;

            if (property == null)
            {
                return;
            }

            // Get (or create) the animation composition chain.
            var compositionChain = animationManager.GetCompositionChain(property, Animation.Traits, true);

            if (handoffBehavior == HandoffBehavior.SnapshotAndReplace)
            {
                // Make a snapshot of the current animation value.
                compositionChain.TakeSnapshot();
            }

            if (handoffBehavior == HandoffBehavior.Replace || handoffBehavior == HandoffBehavior.SnapshotAndReplace)
            {
                // Remove all previous animations.
                if (compositionChain.Count > 0)
                {
                    var rootInstance = this.GetRoot();
                    for (int i = compositionChain.Count - 1; i >= 0; i--)
                    {
                        var animationInstance = compositionChain[i];

                        // Do not remove animation instances of the same animation tree!
                        if (animationInstance.GetRoot() != rootInstance)
                        {
                            compositionChain.RemoveAt(i);
                        }
                    }
                }
            }

            AnimationInstance <T> referenceInstance = null;

            if (previousInstance != null)
            {
                // previousInstance is either a single animation instance or an animation tree that
                // should be replaced. Find the instance that is assigned to the current property.
                referenceInstance = previousInstance.GetAssignedInstance(Property) as AnimationInstance <T>;
            }

            if (referenceInstance == null)
            {
                // Add at the end of the animation composition chain.
                compositionChain.Add(this);
            }
            else
            {
                // Insert in animation composition chain at a certain index.
                int index = compositionChain.IndexOf(referenceInstance);
                if (index == -1)
                {
                    // The referenceInstance has not been applied to the current property.
                    compositionChain.Add(this);
                }
                else
                {
                    // Insert after referenceInstance.
                    index++;

                    // Other animation instances of the same animation tree might have already been
                    // inserted after referenceInstance. To maintain the correct order we need to add
                    // this instance after the other instances of the same tree.
                    var rootInstance      = this.GetRoot();
                    var numberOfInstances = compositionChain.Count;
                    while (index < numberOfInstances && compositionChain[index].GetRoot() == rootInstance)
                    {
                        index++;
                    }

                    compositionChain.Insert(index, this);
                }
            }
        }