Inheritance: EasingFunctionBase, ICircleEase
コード例 #1
0
        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double from, Double to, EasingMode em)
        {
        //<Storyboard x:Name="Storyboard1">
        //    <DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="border">
        //        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
        //    </DoubleAnimationUsingKeyFrames>
        //</Storyboard>
            DoubleAnimationUsingKeyFrames daKeyFrame = new DoubleAnimationUsingKeyFrames();
            EasingDoubleKeyFrame edKeyFrame = new EasingDoubleKeyFrame();
            edKeyFrame.KeyTime = TimeSpan.FromSeconds(secondTime);
            edKeyFrame.Value = to;
            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            edKeyFrame.EasingFunction = ce;

            daKeyFrame.KeyFrames.Add(edKeyFrame);
            daKeyFrame.EnableDependentAnimation = true;

            Storyboard.SetTarget(daKeyFrame, dpnObj);
            Storyboard.SetTargetProperty(daKeyFrame, property);
            Storyboard sb = new Storyboard();

            sb.Children.Add(daKeyFrame);
            return sb;
        }
コード例 #2
0
        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double to, EasingMode em)
        {
            DoubleAnimation ca = new DoubleAnimation();
            ca.EnableDependentAnimation = true;
            ca.Duration = TimeSpan.FromSeconds(secondTime);
            ca.To = to;

            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            ca.EasingFunction = ce;

            Storyboard.SetTarget(ca, dpnObj);
            Storyboard.SetTargetProperty(ca, property);
            Storyboard sb = new Storyboard();

            sb.Children.Add(ca);
            return sb;
        }
コード例 #3
0
ファイル: AnimationFactory.cs プロジェクト: wpdu/ControlTest
        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double from, Double to, EasingMode em, EventHandler<object> complete)
        {
            DoubleAnimation ca = new DoubleAnimation();
            ca.EnableDependentAnimation = true;
            ca.Duration = TimeSpan.FromSeconds(secondTime);
            ca.From = from;
            ca.To = to;

            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            ca.EasingFunction = ce;

            Storyboard.SetTarget(ca, dpnObj);
            Storyboard.SetTargetProperty(ca, property);
            Storyboard sb = new Storyboard();
            sb.Completed += complete;
            sb.Children.Add(ca);
            return sb;


            //DoubleAnimationUsingKeyFrames daKeyFrame = new DoubleAnimationUsingKeyFrames();
            //EasingDoubleKeyFrame edKeyFrame = new EasingDoubleKeyFrame();
            //edKeyFrame.KeyTime = TimeSpan.FromSeconds(secondTime);
            //edKeyFrame.Value = to;
            //CircleEase ce = new CircleEase();
            //ce.EasingMode = em;
            //edKeyFrame.EasingFunction = ce;

            //daKeyFrame.KeyFrames.Add(edKeyFrame);
            //daKeyFrame.EnableDependentAnimation = true;

            //Storyboard.SetTarget(daKeyFrame, dpnObj);
            //Storyboard.SetTargetProperty(daKeyFrame, property);
            //Storyboard sb = new Storyboard();
            //sb.Completed += complete;

            //sb.Children.Add(daKeyFrame);
            //return sb;
        }
コード例 #4
0
ファイル: Scenario3.xaml.cs プロジェクト: mbin/Win81App
        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();
        }
コード例 #5
0
ファイル: AppShell.xaml.cs プロジェクト: Mimetis/NextMeeting
        public void SetTitle(String text)
        {
            TitleTextBlock.Opacity = 0;
            TitleTextBlock.Text = text;
            CompositeTransform transform = TitleTextBlock.RenderTransform as CompositeTransform;

            DoubleAnimation animationTranslation = new DoubleAnimation();
            animationTranslation.To = 0;
            animationTranslation.From = 20;
            var easing = new CircleEase();
            easing.EasingMode = EasingMode.EaseOut;
            animationTranslation.EasingFunction = easing;
            Storyboard.SetTarget(animationTranslation, transform);
            Storyboard.SetTargetProperty(animationTranslation, "TranslateX");

            DoubleAnimation animationOpacity = new DoubleAnimation();
            animationOpacity.To = 1.0;
            animationOpacity.From = 0.0;
            Storyboard.SetTarget(animationOpacity, TitleTextBlock);
            Storyboard.SetTargetProperty(animationOpacity, "Opacity");

            Storyboard sb = new Storyboard();
            sb.Children.Add(animationTranslation);
            sb.Children.Add(animationOpacity);

            sb.Duration = animationOpacity.Duration = animationTranslation.Duration = TimeSpan.FromMilliseconds(300);

            sb.Begin();

        }
コード例 #6
0
ファイル: XTween.cs プロジェクト: xlune/XTween
 //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;
 }