Ejemplo n.º 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;
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        private void CreateAnimation()
        {
            CircleEase _CircleEase = new CircleEase() { EasingMode = EasingMode.EaseInOut };

            DoubleAnimationUsingKeyFrames compositeTransformIn = new DoubleAnimationUsingKeyFrames();
            compositeTransformIn.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.Zero, Value = 45 });
            compositeTransformIn.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromMilliseconds(600), Value = 0, EasingFunction = _CircleEase });

            Storyboard.SetTargetProperty(compositeTransformIn, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
            Storyboard.SetTarget(compositeTransformIn, splash);

            DoubleAnimation opacityAnimationAfterIn = new DoubleAnimation() { Duration = TimeSpan.FromMilliseconds(200), From = 1, To = 0 };
            Storyboard.SetTargetProperty(opacityAnimationAfterIn, new PropertyPath("Opacity"));
            Storyboard.SetTarget(opacityAnimationAfterIn, splash);

            _StoryboardIn = new Storyboard();
            _storyboardAfterIn = new Storyboard();

            _StoryboardIn.Children.Add(compositeTransformIn);
            _storyboardAfterIn.Children.Add(opacityAnimationAfterIn);

            _StoryboardIn.Completed += (o, t) =>
            {
                container.Opacity = 1;
                closeButton.Opacity = 1;
                _storyboardAfterIn.Begin();
            };

            _storyboardAfterIn.Completed += (o, t) =>
            {
                this.splash.Visibility = System.Windows.Visibility.Collapsed;
            };
        }
Ejemplo n.º 4
0
        private void animateMenu(bool up = true, int count = 1)
        {
            Canvas.SetTop(kinectGuideCanvas, 60 * menuPosition);

            DoubleAnimation animation = new DoubleAnimation();

            animation.Duration = TimeSpan.FromMilliseconds(200);
            animation.From = 0;

            if (up)
            {
                MainWindow.SFXUpTick.Play();
                menuPosition++;
                //Selection going up, move menu down
                animation.By = animation.From + (60 * count);
            }
            else
            {
                MainWindow.SFXDownTick.Play();
                menuPosition--;
                //Selection going down, move menu up
                animation.By = animation.From + (-60 * count);
            }

            TranslateTransform tt = new TranslateTransform();
            kinectGuideCanvas.RenderTransform = tt;

            CircleEase ease = new CircleEase();
            ease.EasingMode = EasingMode.EaseOut;
            animation.EasingFunction = ease;

            tt.BeginAnimation(TranslateTransform.YProperty, animation);
            Console.WriteLine(menuPosition);
        }
Ejemplo n.º 5
0
        public static void animateSlide(FrameworkElement item, bool reverse = false, bool vertical = true, double movement = 10, double duration = 1)
        {
            DoubleAnimation daOpacity = new DoubleAnimation();
            DoubleAnimation daMovement = new DoubleAnimation();

            if (!reverse)
            {
                daOpacity.From = 0;
                daOpacity.To = 1;
                daMovement.From = movement;
                daMovement.To = 0;
            }
            else
            {
                daOpacity.From = 1;
                daOpacity.To = 0;
                daMovement.From = 0;
                daMovement.To = movement;
            }

            daOpacity.Duration = TimeSpan.FromSeconds(duration);

            daMovement.Duration = TimeSpan.FromSeconds(duration);

            TranslateTransform tt = new TranslateTransform();
            item.RenderTransform = tt;

            CircleEase ease = new CircleEase();
            ease.EasingMode = EasingMode.EaseOut;
            daOpacity.EasingFunction = ease;
            daMovement.EasingFunction = ease;

            item.BeginAnimation(FrameworkElement.OpacityProperty, daOpacity);
            if (vertical)
            {
                tt.BeginAnimation(TranslateTransform.YProperty, daMovement);
            }
            else
            {
                tt.BeginAnimation(TranslateTransform.XProperty, daMovement);
            }
        }
Ejemplo n.º 6
0
        private static Storyboard createDoubleAnimation(DependencyObject p, bool expanded)
        {
            DoubleAnimation a = new DoubleAnimation();
            a.Duration = new TimeSpan(0, 0, 0, 0, 200);
            Storyboard.SetTargetProperty(a, new PropertyPath(HeightProperty));

            CircleEase b = new CircleEase();
            b.EasingMode = EasingMode.EaseOut;
            a.EasingFunction = b;

            if (expanded)
            {
                a.From = (double)p.GetValue(CRMAppBar.ClosedHeightProperty);
                a.To = (double)p.GetValue(CRMAppBar.PanelHeightProperty);                
            }
            else
            {
                a.From = (double)p.GetValue(CRMAppBar.PanelHeightProperty);
                a.To = (double)p.GetValue(CRMAppBar.ClosedHeightProperty);
            }

            Storyboard sb = new Storyboard();
            sb.SetValue(Storyboard.TargetProperty, p);
            sb.Children.Add(a);
            return sb;
        }
Ejemplo n.º 7
0
        private static Timeline doubleAnimation(double from, double to, bool expanded, DependencyProperty property)
        {
            DoubleAnimation a = new DoubleAnimation();
            a.Duration = new TimeSpan(0, 0, 0, 0, 200);
            Storyboard.SetTargetProperty(a, new PropertyPath(property));

            CircleEase b = new CircleEase();
            b.EasingMode = EasingMode.EaseOut;
            a.EasingFunction = b;
            
            if (expanded)
            {
                a.From = from;
                a.To = to;                
            }
            else
            {
                a.From = to;
                a.To = from;                
            }

            return a;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes palette instance.
        /// </summary>
        /// <param name="info"> Palette info. </param>
        /// <exception cref="System.ArgumentNullException"> The Palette Info. </exception>
        /// <exception cref="ArgumentNullException">Thrown if palette info is null.</exception>
        public void Init(IPaletteInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            var duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
            var story = new Storyboard { Duration = duration };

            IEasingFunction easing = new CircleEase { EasingMode = EasingMode.EaseOut };
            Id = info.Id;
            Name = info.Name;

            InitColor(MainBackColor, info.MainBackColor.ToColor(), easing, duration, story, MainBackColorProperty);
            InitColor(MainFrontColor, info.MainFrontColor.ToColor(), easing, duration, story, MainFrontColorProperty);
            InitColor(CalmBackColor, info.CalmBackColor.ToColor(), easing, duration, story, CalmBackColorProperty);
            InitColor(CalmFrontColor, info.CalmFrontColor.ToColor(), easing, duration, story, CalmFrontColorProperty);
            InitColor(StrongBackColor, info.StrongBackColor.ToColor(), easing, duration, story, StrongBackColorProperty);
            InitColor(StrongFrontColor, info.StrongFrontColor.ToColor(), easing, duration, story, StrongFrontColorProperty);

            BindingOperations.SetBinding(this, DashboardBackgroundProperty, new Binding("MainBackColor") { Source = this, Mode = BindingMode.OneWay });

            BindingOperations.SetBinding(
                Windows8Palette.Palette,
                Windows8Palette.AccentColorProperty,
                new Binding("CalmFrontColor") { Source = this, Mode = BindingMode.OneWay, Converter = new ChangeColorBrightnessConverter() });

            BindingOperations.SetBinding(
                Windows8Palette.Palette,
                Windows8Palette.MainColorProperty,
                new Binding("CalmBackColor") { Source = this, Mode = BindingMode.OneWay });

            BindingOperations.SetBinding(
                Windows8Palette.Palette,
                Windows8Palette.BasicColorProperty,
                new Binding("StrongBackColor") { Source = this, Mode = BindingMode.OneWay });

            BindingOperations.SetBinding(
                Windows8Palette.Palette,
                Windows8Palette.StrongColorProperty,
                new Binding("CalmFrontColor") { Source = this, Mode = BindingMode.OneWay, Converter = new ChangeColorBrightnessConverter() });

            BindingOperations.SetBinding(
                Windows8Palette.Palette,
                Windows8Palette.MarkerColorProperty,
                new Binding("CalmFrontColor") { Source = this, Mode = BindingMode.OneWay });

            //Windows8Palette.Palette.MarkerColor = (Color)new ChangeColorBrightnessConverter().Convert(info.CalmFrontColor.ToColor(), typeof(Color), null, CultureInfo.InvariantCulture);

            _colorAnimation = story;
            _colorAnimation.Begin();
        }
        private void SlideUp()
        {
            Storyboard storyBoard = new Storyboard();

            MainCanvas.Children.Clear();
            MainCanvas.Background = ColorHelper.GetBrushFromString(_message.BackgroundColor);

            string text = _message.Text;

            string[] words = text.Split(' ');
            for (var i = 0; i <= words.Length - 1; i++)
            {
                Border b = new Border();
                b.BorderThickness = new Thickness(0);
                b.Width = 800;
                b.Height = 480;

                TextBlock tb = getTextBlock();
                tb.Text = words[i];
                tb.FontSize = getFontSize();
                tb.Foreground = ColorHelper.GetBrushFromString(_message.ForegroundColor);
                while (tb.ActualWidth > 800)
                {
                    tb.FontSize -= 1;
                    System.Diagnostics.Debug.WriteLine("FontSize: " + tb.FontSize);
                }
                tb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

                b.Child = tb;
                b.SetValue(Canvas.TopProperty, Convert.ToDouble(480));

                MainCanvas.Children.Add(b);

                double seconds = ((MAX_SPEED - _message.Speed) + 1) * SPEED_INTERVAL;

                double startingTime = (i * 2) * seconds;

                EasingDoubleKeyFrame edkf;

                // Hide elements during repeat

                DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();

                CircleEase ce = new CircleEase();
                ce.EasingMode = EasingMode.EaseOut;

                edkf = new EasingDoubleKeyFrame();
                edkf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startingTime));
                edkf.Value = 480;
                edkf.EasingFunction = ce;
                animation.KeyFrames.Add(edkf);

                edkf = new EasingDoubleKeyFrame();
                edkf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startingTime + seconds));
                edkf.Value = 0;
                edkf.EasingFunction = ce;
                animation.KeyFrames.Add(edkf);

                edkf = new EasingDoubleKeyFrame();
                edkf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startingTime + (seconds * 2)));
                edkf.Value = 0;
                edkf.EasingFunction = ce;
                animation.KeyFrames.Add(edkf);

                edkf = new EasingDoubleKeyFrame();
                edkf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startingTime + (seconds * 3)));
                edkf.Value = -480;
                edkf.EasingFunction = ce;
                animation.KeyFrames.Add(edkf);

                Storyboard.SetTarget(animation, b);
                Storyboard.SetTargetProperty(animation, new PropertyPath("(Canvas.Top)"));

                storyBoard.Children.Add(animation);

            }

            if (storyBoard.Children.Count > 0)
            {
                storyBoard.RepeatBehavior = RepeatBehavior.Forever;
                storyBoard.Begin();
            }
        }
Ejemplo n.º 10
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 };
        }
Ejemplo n.º 11
0
        private void UpdatePosition(bool useTransitions)
        {
            if (_ya != null)
            {
                IEasingFunction ease = new CircleEase(); // ExponentialEase { Exponent = 1 };

                Duration d = new Duration(TimeSpan.Zero);
                if (useTransitions)
                {
                    double random = Random.NextDouble();
                    double min = 1.0;
                    double extra = random * 2.5;
                    d = new Duration(TimeSpan.FromSeconds(min + extra));
                }

                var loc = 0.0;

                switch (_currentState)
                {
                    case TileState.Text:
                        loc = 0.0;
                        break;

                    case TileState.Partial:
                        loc = NegativeHalfTileSize;
                        break;

                    case TileState.Image:
                        loc = NegativeTileSize;
                        break;
                }

                _ya.GoTo(loc, d, ease);
            }
        }