Inheritance: EasingFunctionBase, IBackEase
Esempio n. 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            LastSelectedUser = SelectedUser;
            SelectedUser = sender as UserSelButtonControl;
            if (LastSelectedUser != null && SelectedUser.Equals(LastSelectedUser))
            {
                Constants.User = SelectedUser.user;
                Frame.Navigate(typeof(LoginDefault));
                return;
            }

            System.Diagnostics.Debug.WriteLine("tap on image in logintmp");

            SelectedUser.Margin = new Thickness(50, 0, 50, 0);

            TimeSpan span = new TimeSpan(0,0,0,0,200);
            Grid grid = SelectedUser.grid;
            DoubleAnimation scaleY = new DoubleAnimation();
            scaleY.To = 1.5;
            scaleY.Duration = new Duration(span);
            Storyboard.SetTargetProperty(scaleY, "(UIElement.RenderTransform). (CompositeTransform.ScaleY)");
            Storyboard.SetTarget(scaleY, grid);
            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(scaleY);
            DoubleAnimation scaleX = new DoubleAnimation();
            scaleX.To = 1.5;
            scaleX.Duration = new Duration(span);
            Storyboard.SetTargetProperty(scaleX, "(UIElement.RenderTransform). (CompositeTransform.ScaleX)");
            Storyboard.SetTarget(scaleX, grid);
            storyboard.Children.Add(scaleX);

            if (LastSelectedUser != null)
            {
                LastSelectedUser.Margin = new Thickness(5, 0, 0, 0);
                Grid gridOld = LastSelectedUser.grid;
                DoubleAnimation scaleYOld = new DoubleAnimation();
                scaleYOld.To = 1;
                scaleYOld.Duration = new Duration(span);
                Storyboard.SetTargetProperty(scaleYOld, "(UIElement.RenderTransform). (CompositeTransform.ScaleY)");
                Storyboard.SetTarget(scaleYOld, gridOld);
                storyboard.Children.Add(scaleYOld);
                DoubleAnimation scaleXOld = new DoubleAnimation();
                scaleXOld.To = 1;
                scaleXOld.Duration = new Duration(span);
                Storyboard.SetTargetProperty(scaleXOld, "(UIElement.RenderTransform). (CompositeTransform.ScaleX)");
                Storyboard.SetTarget(scaleXOld, gridOld);
                storyboard.Children.Add(scaleXOld);
            }

            Button each;
            for (int i = 0; i < UsersStack.Children.Count; i++)
            {
                each = UsersStack.Children[i] as Button; //如果类型不一致则返回null
                if (each != null)
                {
                    // doing......
                    if (each.Equals(SelectedUser))
                    {
                        DoubleAnimation transition = new DoubleAnimation();
                        transition.From = Canvas.GetLeft(UsersStack);
                        transition.To = 553 - i * (155);
                        transition.Duration = new Duration(new TimeSpan(0, 0, 0, 1));
                        BackEase ease = new BackEase();
                        ease.Amplitude = 1;
                        ease.EasingMode = EasingMode.EaseOut;
                        transition.EasingFunction = ease;
                        Storyboard.SetTargetProperty(transition, "(Canvas.Left)");
                        Storyboard.SetTarget(transition, UsersStack);
                        storyboard.Children.Add(transition);

                        storyboard.Begin();
                    }
                }
            }
        }
Esempio n. 2
0
 //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;
 }