Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the AnimationSequenceBuilder class.
        /// </summary>
        /// <param name="owner">The owner object.</param>
        /// <param name="animatedObject">The object which gets animated.</param>
        /// <exception cref="System.ArgumentException">Unable to cast target object of this AnimationSequenceBuilder to the generic type parameter!</exception>
        internal AnimationSequenceBuilder(AnimationHandler owner, TTargetType animatedObject)
        {
            _sequenceList = new List <IAnimation>();

            this.AnimationHandler = owner;
            this.TargetObject     = animatedObject;
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the AnimationSequenceBuilder class.
        /// </summary>
        /// <param name="owner">The owner object.</param>
        /// <exception cref="System.ArgumentException">Unable to cast target object of this AnimationSequenceBuilder to the generic type parameter!</exception>
        internal AnimationSequenceBuilder(AnimationHandler owner)
        {
            _sequenceList = new List <IAnimation>();

            this.AnimationHandler = owner;
            this.TargetObject     = (TTargetType)owner.Owner;
        }
        /// <summary>
        /// Builds a lazy animation object using the given child sequence.
        /// </summary>
        /// <param name="builder">The AnimationSequenceBuilder object.</param>
        /// <param name="childSequenceBuilder">A SequenceBuilder building a child sequence.</param>
        public static IAnimationSequenceBuilder <TObjectType> Lazy <TObjectType>(this IAnimationSequenceBuilder <TObjectType> builder, Action <IAnimationSequenceBuilder <TObjectType> > childSequenceBuilder)
            where TObjectType : class
        {
            return(builder.Lazy(() =>
            {
                var result = new AnimationHandler(builder.AnimationHandler.Owner);
                IAnimationSequenceBuilder <TObjectType> childBuilder = new AnimationSequenceBuilder <TObjectType>(result);
                childSequenceBuilder(childBuilder);

                if (childBuilder.ItemCount == 0 && !childBuilder.Applied)
                {
                    childBuilder.Apply();
                }

                if (!childBuilder.Applied)
                {
                    throw new InvalidOperationException("Child sequence was not correctly applied (call to Apply is missing!)");
                }

                return result;
            }));
        }