//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; }
private void Scenario3EasingFunctionChanged(object sender, SelectionChangedEventArgs e) { // stop the storyboard Scenario3Storyboard.Stop(); EasingFunctionBase easingFunction = null; // select an easing function based on the user's selection ComboBoxItem selectedFunctionItem = Scenario3FunctionSelector.SelectedItem as ComboBoxItem; if (selectedFunctionItem != null) { switch (selectedFunctionItem.Content.ToString()) { case "BounceEase": easingFunction = new BounceEase(); break; case "CircleEase": easingFunction = new CircleEase(); break; case "ExponentialEase": easingFunction = new ExponentialEase(); break; case "PowerEase": easingFunction = new PowerEase() { Power = 0.5 }; break; default: break; } } // if no valid easing function was specified, let the storyboard stay stopped and do not continue if (easingFunction == null) return; ComboBoxItem selectedEasingModeItem = Scenario3EasingModeSelector.SelectedItem as ComboBoxItem; // select an easing mode based on the user's selection, defaulting to EaseIn if no selection was given if (selectedEasingModeItem != null) { switch (selectedEasingModeItem.Content.ToString()) { case "EaseOut": easingFunction.EasingMode = EasingMode.EaseOut; break; case "EaseInOut": easingFunction.EasingMode = EasingMode.EaseInOut; break; default: easingFunction.EasingMode = EasingMode.EaseIn; break; } } // plot a graph of the easing function PlotEasingFunctionGraph(easingFunction, 0.005); RectanglePositionAnimation.EasingFunction = easingFunction; GraphPositionMarkerYAnimation.EasingFunction = easingFunction; // start the storyboard Scenario3Storyboard.Begin(); }
private void AnimateSideMenu(bool isSideMenuOpen) { if (isSideMenuOpen) { DoubleAnimation animation = new DoubleAnimation(); animation.To = 0; animation.Duration = TimeSpan.FromMilliseconds(300); QuadraticEase ease = new QuadraticEase(); ease.EasingMode = EasingMode.EaseIn; animation.EasingFunction = ease; Storyboard storyboard = new Storyboard(); Storyboard.SetTarget(animation, sideMenuTransform); Storyboard.SetTargetProperty(animation, "Y"); storyboard.Children.Add(animation); storyboard.Begin(); } else { DoubleAnimation animation = new DoubleAnimation(); animation.To = sideMenuMaxY; animation.Duration = TimeSpan.FromMilliseconds(400); BounceEase ease = new BounceEase(); ease.Bounces = 4; ease.Bounciness = 4; ease.EasingMode = EasingMode.EaseOut; animation.EasingFunction = ease; Storyboard storyboard = new Storyboard(); Storyboard.SetTarget(animation, sideMenuTransform); Storyboard.SetTargetProperty(animation, "Y"); storyboard.Children.Add(animation); storyboard.Begin(); } }