示例#1
0
        /// <summary>
        /// 在指定的属性上开始创建基于关键帧的动画。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="targetPropertyPath"></param>
        /// <returns></returns>
        public KeyFrameTransitionAnimationFluentContext <T> AnimateWithKeyFrame <T>(string targetPropertyPath)
        {
            AnimationTypes type = AnimationTypes.NotSupport;

            Enum.TryParse(typeof(T).Name, true, out type);

            AnimationFluentContext result;

            switch (type)
            {
            case AnimationTypes.Single:
                result = new ScalarKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateScalarKeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector2:
                result = new Vector2KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector2KeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector3:
                result = new Vector3KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector3KeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector4:
                result = new Vector4KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector4KeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Color:
                result = new ColorKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateColorKeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Quaternion:
                result = new QuaternionKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateQuaternionKeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.NotSupport:
            default:
                throw new InvalidOperationException("");
            }
        }
示例#2
0
        /// <summary>
        /// 在指定的属性上开始创建基于关键帧的动画。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="targetProperty"></param>
        /// <returns></returns>
        protected KeyFrameTransitionAnimationFluentContext <T> AnimateWithKeyFrame <T>(IAnimatableProperty <T> targetProperty)
        {
            AnimationFluentContext result;

            switch (targetProperty.AnimationType)
            {
            case AnimationTypes.Single:
                result = new ScalarKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateScalarKeyFrameAnimation(), targetProperty.PropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector2:
                result = new Vector2KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector2KeyFrameAnimation(), targetProperty.PropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector3:
                result = new Vector3KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector3KeyFrameAnimation(), targetProperty.PropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector4:
                result = new Vector4KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector4KeyFrameAnimation(), targetProperty.PropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Color:
                result = new ColorKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateColorKeyFrameAnimation(), targetProperty.PropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Quaternion:
                result = new QuaternionKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateQuaternionKeyFrameAnimation(), targetProperty.PropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.NotSupport:
            default:
                throw new InvalidOperationException("");
            }
        }