private void AnimateGraphic() { MapPoint userStartPoint = _userInteractionLayer.Graphics[0].Geometry as MapPoint; MapPoint userFinishPoint = _userInteractionLayer.Graphics[1].Geometry as MapPoint; MapPoint startPoint = GeometryEngine.NormalizeCentralMeridian(userStartPoint) as MapPoint; MapPoint finishPoint = GeometryEngine.NormalizeCentralMeridian(userFinishPoint) as MapPoint; var animatingGraphic = new Graphic(new MapPoint(startPoint.X, startPoint.Y)); _animatingLayer.Graphics.Add(animatingGraphic); // Framework easing objects may be used to calculate progressive values // - i.e. QuinticEase, BackEase, BounceEase, ElasticEase, etc. var easing = new QuinticEase() { EasingMode = EasingMode.EaseInOut }; var animateStartTime = DateTime.Now; var animationTimer = new DispatcherTimer(); animationTimer.Interval = TimeSpan.FromMilliseconds(33); animationTimer.Tick += (s, ex) => { double fraction = easing.Ease((DateTime.Now - animateStartTime).TotalMilliseconds / AnimationDuration); var x = (finishPoint.X - startPoint.X) * fraction + startPoint.X; var y = (finishPoint.Y - startPoint.Y) * fraction + startPoint.Y; animatingGraphic.Geometry = new MapPoint(x, y); }; animationTimer.Start(); }
void inititemanimations() { _translatestory = new Windows.UI.Xaml.Media.Animation.Storyboard(); _translateXanimation = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _translateXanimation.Duration = TimeSpan.FromMilliseconds(350); _translatestory.Children.Add(_translateXanimation); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_translateXanimation, _transform); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_translateXanimation, "TranslateX"); Windows.UI.Xaml.Media.Animation.QuinticEase ease1 = new Windows.UI.Xaml.Media.Animation.QuinticEase(); ease1.EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseOut; _translateXanimation.EasingFunction = ease1; _rotatestory = new Windows.UI.Xaml.Media.Animation.Storyboard(); _rotateanimation = new Windows.UI.Xaml.Media.Animation.DoubleAnimation();; _rotateanimation.Duration = TimeSpan.FromMilliseconds(350); _rotatestory.Children.Add(_rotateanimation); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_rotateanimation, _transform); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_rotateanimation, "Rotation"); _translatestory.Completed += StackItem_StoryboardCompleted; _translatestory1 = new Windows.UI.Xaml.Media.Animation.Storyboard(); _translatexanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _translatexanimation1.Duration = TimeSpan.FromMilliseconds(400); _translatestory1.Children.Add(_translatexanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_translatexanimation1, "TranslateX"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_translatexanimation1, _transform); _translateyanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _translateyanimation1.Duration = TimeSpan.FromMilliseconds(400); _translatestory1.Children.Add(_translateyanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_translateyanimation1, "TranslateY"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_translateyanimation1, _transform); _scalestory1 = new Windows.UI.Xaml.Media.Animation.Storyboard(); _scalexanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _scalexanimation1.Duration = TimeSpan.FromMilliseconds(400); _scalestory1.Children.Add(_scalexanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_scalexanimation1, "ScaleX"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_scalexanimation1, _transform); Windows.UI.Xaml.Media.Animation.QuinticEase easex = new Windows.UI.Xaml.Media.Animation.QuinticEase(); easex.EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseInOut; //_scalexanimation1.EasingFunction = easex ; _scaleyanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _scaleyanimation1.Duration = TimeSpan.FromMilliseconds(400); _scalestory1.Children.Add(_scaleyanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_scaleyanimation1, "ScaleY"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_scaleyanimation1, _transform); Windows.UI.Xaml.Media.Animation.QuinticEase easey = new Windows.UI.Xaml.Media.Animation.QuinticEase(); easey.EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseInOut; //_scaleyanimation1.EasingFunction = easey ; _rotatestory1 = new Windows.UI.Xaml.Media.Animation.Storyboard(); _rotateanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _rotateanimation1.Duration = TimeSpan.FromMilliseconds(400); _rotatestory1.Children.Add(_rotateanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_rotateanimation1, "Rotation"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_rotateanimation1, _transform); _scalestory1.Completed += StackItem_StoryboardFullCompleted; }
void inititemanimations() { _translatestory = new Windows.UI.Xaml.Media.Animation.Storyboard(); _translateXanimation = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _translateXanimation.Duration = TimeSpan.FromMilliseconds(350); _translatestory.Children.Add(_translateXanimation); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_translateXanimation, _transform); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_translateXanimation, "TranslateX"); Windows.UI.Xaml.Media.Animation.QuinticEase ease1 = new Windows.UI.Xaml.Media.Animation.QuinticEase(); ease1.EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseOut; _translateXanimation.EasingFunction = ease1; _rotatestory = new Windows.UI.Xaml.Media.Animation.Storyboard(); _rotateanimation = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); ; _rotateanimation.Duration = TimeSpan.FromMilliseconds(350); _rotatestory.Children.Add(_rotateanimation); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_rotateanimation, _transform); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_rotateanimation, "Rotation"); _translatestory.Completed += StackItem_StoryboardCompleted; _translatestory1 = new Windows.UI.Xaml.Media.Animation.Storyboard(); _translatexanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _translatexanimation1.Duration = TimeSpan.FromMilliseconds(400); _translatestory1.Children.Add(_translatexanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_translatexanimation1, "TranslateX"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_translatexanimation1, _transform); _translateyanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _translateyanimation1.Duration = TimeSpan.FromMilliseconds(400); _translatestory1.Children.Add(_translateyanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_translateyanimation1, "TranslateY"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_translateyanimation1, _transform); _scalestory1 = new Windows.UI.Xaml.Media.Animation.Storyboard(); _scalexanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _scalexanimation1.Duration = TimeSpan.FromMilliseconds(400); _scalestory1.Children.Add(_scalexanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_scalexanimation1, "ScaleX"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_scalexanimation1, _transform); Windows.UI.Xaml.Media.Animation.QuinticEase easex = new Windows.UI.Xaml.Media.Animation.QuinticEase(); easex.EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseInOut; //_scalexanimation1.EasingFunction = easex ; _scaleyanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _scaleyanimation1.Duration = TimeSpan.FromMilliseconds(400); _scalestory1.Children.Add(_scaleyanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_scaleyanimation1, "ScaleY"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_scaleyanimation1, _transform); Windows.UI.Xaml.Media.Animation.QuinticEase easey = new Windows.UI.Xaml.Media.Animation.QuinticEase(); easey.EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseInOut; //_scaleyanimation1.EasingFunction = easey ; _rotatestory1 = new Windows.UI.Xaml.Media.Animation.Storyboard(); _rotateanimation1 = new Windows.UI.Xaml.Media.Animation.DoubleAnimation(); _rotateanimation1.Duration = TimeSpan.FromMilliseconds(400); _rotatestory1.Children.Add(_rotateanimation1); Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(_rotateanimation1, "Rotation"); Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(_rotateanimation1, _transform); _scalestory1.Completed += StackItem_StoryboardFullCompleted; }
//Get Easing Function private EasingFunctionBase GetEasingFunction(Easing type) { EasingFunctionBase func = null; switch (type) { case Easing.EaseSineIn: case Easing.EaseSineOut: case Easing.EaseSineInOut: func = new SineEase(); break; case Easing.EaseCircleIn: case Easing.EaseCircleOut: case Easing.EaseCircleInOut: func = new CircleEase(); break; case Easing.EaseQuadraticIn: case Easing.EaseQuadraticOut: case Easing.EaseQuadraticInOut: func = new QuadraticEase(); break; case Easing.EaseCubicIn: case Easing.EaseCubicOut: case Easing.EaseCubicInOut: func = new CubicEase(); break; case Easing.EaseQuarticIn: case Easing.EaseQuarticOut: case Easing.EaseQuarticInOut: func = new QuarticEase(); break; case Easing.EaseQuinticIn: case Easing.EaseQuinticOut: case Easing.EaseQuinticInOut: func = new QuinticEase(); break; case Easing.EaseBackIn: case Easing.EaseBackOut: case Easing.EaseBackInOut: func = new BackEase(); break; case Easing.EaseBounceIn: case Easing.EaseBounceOut: case Easing.EaseBounceInOut: func = new BounceEase(); break; case Easing.EaseElasticIn: case Easing.EaseElasticOut: case Easing.EaseElasticInOut: func = new ElasticEase(); break; case Easing.EaseExpoIn: case Easing.EaseExpoOut: case Easing.EaseExpoInOut: func = new ExponentialEase(); break; case Easing.EasePowerIn: case Easing.EasePowerOut: case Easing.EasePowerInOut: func = new PowerEase(); break; default: break; } if (func != null) { switch ((int)type % 3) { case 0: func.EasingMode = EasingMode.EaseIn; break; case 1: func.EasingMode = EasingMode.EaseOut; break; default: func.EasingMode = EasingMode.EaseInOut; break; } } return func; }