Beispiel #1
0
        /// <summary>
        /// 创建Double值之间的线性动画
        /// </summary>
        public static DoubleAnimation BuildDoubleAnimation(DoubleModel Model)
        {
            (Model.Target as UIElement).RenderTransform = TransitionHelper.GetTransformGroup(Model.Target);

            DoubleAnimation _doubleAnimation = new DoubleAnimation();

            _doubleAnimation.From           = Model.From;
            _doubleAnimation.To             = Model.To;
            _doubleAnimation.Duration       = new Duration(TimeSpan.FromSeconds(Model.Duration));
            _doubleAnimation.AutoReverse    = Model.AutoReverse;
            _doubleAnimation.BeginTime      = TimeSpan.FromSeconds(Model.BeginTime);
            _doubleAnimation.By             = Model.By;
            _doubleAnimation.FillBehavior   = Model.FillBehavior;
            _doubleAnimation.RepeatBehavior = Model.RepeatBehavior;
            _doubleAnimation.SpeedRatio     = Model.SpeedRatio;

            if (Model.EasingFunction != null)
            {
                _doubleAnimation.EasingFunction = Model.EasingFunction;
            }


            Storyboard.SetTarget(_doubleAnimation, Model.Target);
            Storyboard.SetTargetProperty(_doubleAnimation, new PropertyPath(Model.PropertyPath));
            return(_doubleAnimation);
        }