Exemplo n.º 1
0
        public static AnimationHandle AnimatePointTo(Graphic graphic, MapPoint newLocation, TimeSpan duration, GraphicsOverlay animationLayer = null)
        {
            if (!(graphic.Geometry is MapPoint))
            {
                throw new ArgumentException("Graphic must have a point geometry");
            }

            var start = graphic.Geometry as MapPoint;

            if (start.SpatialReference != null && newLocation.SpatialReference != null && !start.SpatialReference.IsEqual(newLocation.SpatialReference))
            {
                start = GeometryEngine.Project(start, newLocation.SpatialReference) as MapPoint;
            }
            return(AnimationHandle.StartAnimation(
                       duration: duration,
                       onPulse: (normalizedTime) =>
            {
                double x = (newLocation.X - start.X) * normalizedTime + start.X;
                double y = (newLocation.Y - start.Y) * normalizedTime + start.Y;
                double z = double.NaN;
                bool animateZ = newLocation.HasZ && start.HasZ;
                if (animateZ)
                {
                    z = (newLocation.Z - start.Z) * normalizedTime + start.Z;
                }
                graphic.Geometry = animateZ ? new MapPoint(x, y, z, start.SpatialReference) : new MapPoint(x, y, start.SpatialReference);
            },
                       onStart: null,
                       onEnd: () => graphic.Geometry = newLocation,
                       repeat: false,
                       easing: null // new QuadraticEase() { EasingMode = EasingMode.EaseInOut }
                       ));
        }
        public static AnimationHandle StartAnimation(TimeSpan duration, Action <double> onPulse, Action onStart = null, Action onEnd = null, bool repeat = false, EasingFunctionBase easing = null)
        {
            var handle = new AnimationHandle(duration, onPulse, onStart, onEnd, repeat, easing);

            AnimatorHelper.QueueAnimation(handle);
            return(handle);
        }
Exemplo n.º 3
0
        internal static void QueueAnimation(AnimationHandle handle)
        {
            int count = 0;

            lock (animationsLock)
            {
                animations.Add(handle);
                count = animations.Count;
            }

            if (count == 1)
            {
                StartAnimationLoop();
            }
        }