Пример #1
0
        public void Animate(Control control, Point motion, int duration)
        {
            if (motion == Point.Empty)
            {
                return;
            }

            ControlAnimation anim = new ControlAnimation(control, control.Location, motion, duration);

            anim.StartTime = DateTime.Now;
            animations.Add(anim);
            if (!timer.Enabled)
            {
                timer.Enabled = true;
            }
        }
Пример #2
0
        private bool AnimateControl(ControlAnimation anim)
        {
            double span         = (DateTime.Now - anim.StartTime).TotalMilliseconds;
            double timePosition = span / anim.Duration;

            if (timePosition > 1.0)
            {
                timePosition = 1.0;
            }

            // Quartic easing in.
            double factor = timePosition * timePosition * timePosition * timePosition;

            Point shift = anim.Motion.Scale(factor, factor);

            anim.Control.Location = anim.Start.Translate(shift.X, shift.Y);

            return(timePosition < 1.0);
        }