예제 #1
0
        public static EasingFunctionBase GetEasingFunction()
        {
            EasingFunctionBase result = null;
            switch (random.Next(5))
            {
                case 0:
                    result = new BackEase() { EasingMode = EasingMode.EaseInOut, Amplitude = 0.8 };
                    break;
                case 1:
                    result = new BounceEase() { EasingMode = EasingMode.EaseOut, Bounces = 3, Bounciness = 8 };
                    break;
                case 2:
                    result = new CircleEase() { EasingMode = EasingMode.EaseInOut };
                    break;
                case 3:
                    result = new CubicEase() { EasingMode = EasingMode.EaseIn };
                    break;
                case 4:
                    result = new ElasticEase() { EasingMode = EasingMode.EaseOut, Oscillations = 3, Springiness = 4 };
                    break;
                case 5:
                    result = new SineEase() { EasingMode = EasingMode.EaseInOut };
                    break;
                default:
                    result = new BackEase() { EasingMode = EasingMode.EaseInOut, Amplitude = 0.8 };
                    break;
            }

            return result;
        }
예제 #2
0
        private void AvatarBounce()
        {

            var bounce = new BounceEase { Bounces = 3, Bounciness = 10 };
            var a = new ThicknessAnimation(new Thickness(10, -800, 0, 810), new Thickness(10, 10, 0, 0),
                                           new Duration(new TimeSpan(0, 0, 1))) {EasingFunction = bounce};
            Avi.BeginAnimation(MarginProperty, a);
        }
예제 #3
0
        private IEasingFunction ObterFuncaoDaAnimacao()
        {
            EasingFunctionBase funcaoDaAnimacao = null;
            
            switch (FuncaoDaAnimacao.SelectedValue.ToString())
            {
                case "BackEase":
                    funcaoDaAnimacao =  new BackEase();
                    break;
                case "BounceEase":
                    funcaoDaAnimacao = new BounceEase();
                    break;
                case "CircleEase":
                    funcaoDaAnimacao = new CircleEase();
                    break;
                case "CubicEase":
                    funcaoDaAnimacao = new CubicEase();
                    break;
                case "ElasticEase":
                    funcaoDaAnimacao = new ElasticEase();
                    break;
                case "ExponentialEase":
                    funcaoDaAnimacao = new ExponentialEase();
                    break;
                case "PowerEase":
                    funcaoDaAnimacao = new PowerEase();
                    break;
                case "QuadraticEase":
                    funcaoDaAnimacao = new QuadraticEase();
                    break;
                case "QuarticEase":
                    funcaoDaAnimacao = new QuarticEase();
                    break;
                case "QuinticEase":
                    funcaoDaAnimacao = new QuinticEase();
                    break;
                case "SineEase":
                    funcaoDaAnimacao = new SineEase();
                    break;
            }

            funcaoDaAnimacao.EasingMode = ObterModoDaAnimacao();
            return funcaoDaAnimacao;
        }
        private void setupAnimation()
        {
            DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromSeconds(3)));
            da.AutoReverse = true;

            BounceEase bounce = new BounceEase();
            bounce.Bounces = 4;
            bounce.Bounciness = 2;
            bounce.EasingMode = EasingMode.EaseOut;
            da.EasingFunction = bounce;

            TranslateTransform rt = new TranslateTransform();

            faceGrid[0, 0].ParentGrid.RenderTransform = rt;
            faceGrid[0, 0].ParentGrid.RenderTransformOrigin = new Point(0.5, 0.5);

            for (int i = 0; i < IMAGE_MATRIX_WIDTH; i++)
                for (int j = 0; j < IMAGE_MATRIX_HEIGHT; j++)
                {
                    faceGrid[i, j].ParentGrid.RenderTransform = rt;
                    faceGrid[i, j].ParentGrid.RenderTransformOrigin = new Point(0.5, 0.5);
                }


            da.RepeatBehavior = RepeatBehavior.Forever;
            rt.BeginAnimation(TranslateTransform.XProperty, da);

        }
 /*
 public static void Animation_Translate_Frame(this UIElement E, double toX, double toY, double minisecond = 500, bool AutoReverse=false)
 {
     BounceEase BounceOrientation = new BounceEase();
     BounceOrientation.Bounces = 1;
     BounceOrientation.Bounciness = 1;
    // BounceOrientation.EasingMode = EasingMode.EaseInOut;
     if (!double.IsNaN(toX))
     {
         double fromX = E.getLeft();
         DoubleAnimation da = new DoubleAnimation(fromX, toX+fromX, TimeSpan.FromMilliseconds(minisecond)) { EasingFunction = BounceOrientation };
         da.AutoReverse = AutoReverse;
         E.BeginAnimation(Canvas.LeftProperty, da);
     }
     if (!double.IsNaN(toY))
     {
         double fromY = E.getTop();
         DoubleAnimation db = new DoubleAnimation(fromY, fromY + toY, TimeSpan.FromMilliseconds(minisecond)) { EasingFunction = BounceOrientation };
         db.AutoReverse = AutoReverse;
         E.BeginAnimation(Canvas.TopProperty, db);
     }
 }
  * */
 public static void Animation_Goto(this UIElement E, double toX, double toY, double minisecond = 500, bool AutoReverse = false)
 {
     BounceEase BounceOrientation = new BounceEase();
     BounceOrientation.Bounces = 1;
     BounceOrientation.Bounciness = 1;
     // BounceOrientation.EasingMode = EasingMode.EaseInOut;
     if (!double.IsNaN(toX))
     {
         double fromX = E.getLeft();
         DoubleAnimation da = new DoubleAnimation(fromX, toX + fromX, TimeSpan.FromMilliseconds(minisecond)) { EasingFunction = BounceOrientation };
         da.AutoReverse = AutoReverse;
         E.BeginAnimation(Canvas.LeftProperty, da);
     }
     if (!double.IsNaN(toY))
     {
         double fromY = E.getTop();
         DoubleAnimation db = new DoubleAnimation(fromY, fromY + toY, TimeSpan.FromMilliseconds(minisecond)) { EasingFunction = BounceOrientation };
         db.AutoReverse = AutoReverse;
         E.BeginAnimation(Canvas.TopProperty, db);
     }
 }
예제 #6
0
        public void AnimateOpen()
        {
            ReclalcFinalOrbPositions(false);

            var animationDurationInSecs = 0.8;
            var scaleFrom = 0.2;

            var centerX = (this.ActualWidth / 2.0);
            var centerY = (this.ActualHeight / 2.0);

            Storyboard sb = new Storyboard();

            string scaleXProp = "(UIElement.RenderTransform).(ScaleTransform.ScaleX)";
            string scaleYProp = "(UIElement.RenderTransform).(ScaleTransform.ScaleY)";

            BounceEase ease = new BounceEase() { Bounces = 3, Bounciness = 2.5, EasingMode = EasingMode.EaseOut };

            // position all orbs in Center and create animations
            foreach (var o in AllOrbs)
            {
                o.RenderTransform = new ScaleTransform(1.0, 1.0);

                var fromX = centerX - ((o.Width * scaleFrom) / 2.0);
                var fromY = centerY - ((o.Height * scaleFrom) / 2.0);

                var finalPnt = new Point(0, 0);

                if (o.Tag != null) finalPnt = (Point)o.Tag;

                Canvas.SetZIndex(o, 999);
                CanvasEx.SetPosition(o, fromX, fromY);
                o.Visibility = System.Windows.Visibility.Visible;

                var animX = Util.CreateDoubleAnimationUsingKeyFrames(Canvas.LeftProperty, 0, new AnimationKeyFrame(fromX, 0), new AnimationKeyFrame(finalPnt.X, animationDurationInSecs, ease));
                var animY = Util.CreateDoubleAnimationUsingKeyFrames(Canvas.TopProperty, 0, new AnimationKeyFrame(fromY, 0), new AnimationKeyFrame(finalPnt.Y, animationDurationInSecs, ease));

                var scaleX = Util.CreateDoubleAnimationUsingKeyFrames(scaleXProp, 0, new AnimationKeyFrame(scaleFrom, 0), new AnimationKeyFrame(1.0, animationDurationInSecs, ease));
                var scaleY = Util.CreateDoubleAnimationUsingKeyFrames(scaleYProp, 0, new AnimationKeyFrame(scaleFrom, 0), new AnimationKeyFrame(1.0, animationDurationInSecs, ease));

                Storyboard.SetTarget(animX, o);
                Storyboard.SetTarget(animY, o);
                Storyboard.SetTarget(scaleX, o);
                Storyboard.SetTarget(scaleY, o);

                sb.Children.Add(animX);
                sb.Children.Add(animY);
                sb.Children.Add(scaleX);
                sb.Children.Add(scaleY);
            }

            sb.FillBehavior = FillBehavior.Stop;

            sb.Completed += (s, e) => { ReclalcFinalOrbPositions(true); };

            sb.Begin(this);

            balltop.Visibility = System.Windows.Visibility.Visible;
        }
예제 #7
0
        public static PlotElementAnimation CreateAnimation(AnimationTransform transform, AnimationOrigin origin, Easing easing, bool indexDelay)
        {
            var sb = new Storyboard();
              var duration = new Duration(TimeSpan.FromSeconds(0.5));

              var style = new Style();
              style.TargetType = typeof(PlotElement);
              style.Setters.Add(new Setter(PlotElement.OpacityProperty, 0.0));

              if (transform == AnimationTransform.Scale)
            style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new ScaleTransform() { ScaleX = 0, ScaleY = 0 }));
              else if (transform == AnimationTransform.Rotation)
            style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new RotateTransform() { Angle = 180 }));

              var point = new Point(0.5, 0.5);
              switch (origin)
              {
            case AnimationOrigin.Bottom:
              point = new Point(0.5, 2);
              break;
            case AnimationOrigin.Top:
              point = new Point(0.5, -2);
              break;
            case AnimationOrigin.Left:
              point = new Point(-2, 0.5);
              break;
            case AnimationOrigin.Right:
              point = new Point(2, 0.5);
              break;
            case AnimationOrigin.TopLeft:
              point = new Point(2, -2);
              break;
            case AnimationOrigin.TopRight:
              point = new Point(-2, -2);
              break;
            case AnimationOrigin.BottomLeft:
              point = new Point(2, 2);
              break;
            case AnimationOrigin.BottomRight:
              point = new Point(-2, 2);
              break;
            default:
              break;
              }

              style.Setters.Add(new Setter(PlotElement.RenderTransformOriginProperty, point));

              var da = new DoubleAnimation() { From = 0, To = 1, Duration = duration };
              Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));
              sb.Children.Add(da);

              if (transform == AnimationTransform.Scale)
              {
            var da2 = new DoubleAnimation() { From = 0, To = 1, Duration = duration };
            Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).ScaleX"));

            var da3 = new DoubleAnimation() { From = 0, To = 1, Duration = duration };
            Storyboard.SetTargetProperty(da3, new PropertyPath("(RenderTransform).ScaleY"));

            sb.Children.Add(da2);
            sb.Children.Add(da3);
              }
              else if (transform == AnimationTransform.Rotation)
              {
            var da2 = new DoubleAnimation() { To = 0, Duration = duration };
            Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).Angle"));
            sb.Children.Add(da2);
              }

              if (indexDelay)
              {
            foreach (var anim in sb.Children)
              PlotElementAnimation.SetIndexDelay(anim, 0.5);
              }

            #if CLR40
              if (easing != Easing.None)
              {
            IEasingFunction ef = null;

            switch (easing)
            {
              case Easing.BackEase:
            ef = new BackEase(); break;
              case Easing.BounceEase:
            ef = new BounceEase(); break;
              case Easing.CircleEase:
            ef = new CircleEase(); break;
              case Easing.CubicEase:
            ef = new CubicEase(); break;
              case Easing.ElasticEase:
            ef = new ElasticEase(); break;
              case Easing.ExponentialEase:
            ef = new ExponentialEase(); break;
              case Easing.PowerEase:
            ef = new PowerEase(); break;
              case Easing.QuadraticEase:
            ef = new QuadraticEase(); break;
              case Easing.QuarticEase:
            ef = new QuarticEase(); break;
              case Easing.QuinticEase:
            ef = new QuinticEase(); break;
              case Easing.SineEase:
            ef = new SineEase(); break;

              default:
            break;
            }

            foreach (DoubleAnimation anim in sb.Children)
              anim.EasingFunction = ef;
              }
            #endif

              return new PlotElementAnimation() { Storyboard = sb, SymbolStyle = style };
        }
        // TODO:움직이기 전 최초 좌표를 설정해줘야함. 지금은 임의로 -500값으로 진행중.
        // 위쪽에서 등장
        private void BoundsTTB(FrameworkElement shape)
        {
            double x = shape.Margin.Left;
            double y = shape.Margin.Top;
            double yMove = 500;

            ThicknessAnimation bounceAnimation = new ThicknessAnimation();
            BounceEase BounceOrientation = new BounceEase();
            BounceOrientation.Bounces = 4;
            BounceOrientation.Bounciness = 2;
            bounceAnimation.From = new Thickness(143, 0, 0, 0);
            bounceAnimation.From = new Thickness(x, y - yMove, 0, 0);

            bounceAnimation.To = new Thickness(x, y, 0, 0);
            bounceAnimation.EasingFunction = BounceOrientation;

            shape.BeginAnimation(MarginProperty, bounceAnimation);
        }