private void AnimateGraphic()
        {
            MapPoint userStartPoint  = _userInteractionLayer.Graphics[0].Geometry as MapPoint;
            MapPoint userFinishPoint = _userInteractionLayer.Graphics[1].Geometry as MapPoint;

            MapPoint startPoint  = GeometryEngine.NormalizeCentralMeridian(userStartPoint) as MapPoint;
            MapPoint finishPoint = GeometryEngine.NormalizeCentralMeridian(userFinishPoint) as MapPoint;

            var animatingGraphic = new Graphic(new MapPoint(startPoint.X, startPoint.Y));

            _animatingLayer.Graphics.Add(animatingGraphic);

            // Framework easing objects may be used to calculate progressive values
            // - i.e. QuinticEase, BackEase, BounceEase, ElasticEase, etc.
            var easing = new QuinticEase()
            {
                EasingMode = EasingMode.EaseInOut
            };

            var animateStartTime = DateTime.Now;
            var animationTimer   = new DispatcherTimer();

            animationTimer.Interval = TimeSpan.FromMilliseconds(33);
            animationTimer.Tick    += (s, ex) =>
            {
                double fraction = easing.Ease((DateTime.Now - animateStartTime).TotalMilliseconds / AnimationDuration);
                var    x        = (finishPoint.X - startPoint.X) * fraction + startPoint.X;
                var    y        = (finishPoint.Y - startPoint.Y) * fraction + startPoint.Y;
                animatingGraphic.Geometry = new MapPoint(x, y);
            };

            animationTimer.Start();
        }
Exemple #2
0
        private void playlistButton_Click(object sender, RoutedEventArgs e)
        {
            QuinticEase ease = new QuinticEase();

            DoubleAnimation animation = new DoubleAnimation();

            animation.EasingFunction = ease;


            if (openPlaylist == true)
            {
                animation.From = mainForm.Width;
                animation.To   = 900;
                openPlaylist   = false;
            }
            else if (openPlaylist == false)
            {
                animation.From = 900;
                animation.To   = 700;
                openPlaylist   = true;
            }

            animation.Duration = TimeSpan.FromSeconds(0.3);

            mainForm.BeginAnimation(Window.WidthProperty, animation);
        }
Exemple #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Subscribe();

            //Hide the n***a
            Opacity = 0;
            Hide();

            var quint = new QuinticEase();

            dopacity = new DoubleAnimation(1, TimeSpan.FromMilliseconds(350));
            dopacity.EasingFunction     = quint;
            topAnimation                = new DoubleAnimation(-Height, 0, TimeSpan.FromMilliseconds(450));
            topAnimation.EasingFunction = quint;
            dInvOpacity = new DoubleAnimation(0, TimeSpan.FromMilliseconds(350));
            dInvOpacity.EasingFunction     = quint;
            topRevAnimation                = new DoubleAnimation(0, -Height, TimeSpan.FromMilliseconds(450));
            topRevAnimation.EasingFunction = quint;

            dInvOpacity.Completed += DInvOpacity_Completed;

            ResolveJSONData();

            // show the assets
            RenderAssets();
        }
Exemple #4
0
        internal static EasingFunctionBase GetEase(this AnimationSettings settings)
        {
            EasingFunctionBase ease;

            switch (settings.Easing)
            {
            case EasingType.Back:
                ease = new BackEase();
                break;

            case EasingType.Bounce:
                ease = new BounceEase();
                break;

            case EasingType.Circle:
                ease = new CircleEase();
                break;

            case EasingType.Cubic:
                ease = new CubicEase();
                break;

            case EasingType.Elastic:
                ease = new ElasticEase();
                break;

            case EasingType.Linear:
                ease = null;
                break;

            case EasingType.Quadratic:
                ease = new QuadraticEase();
                break;

            case EasingType.Quartic:
                ease = new QuarticEase();
                break;

            case EasingType.Quintic:
                ease = new QuinticEase();
                break;

            case EasingType.Sine:
                ease = new SineEase();
                break;

            default:
                ease = new CubicEase();
                break;
            }

            if (ease != null)
            {
                ease.EasingMode = settings.EasingMode;
            }

            return(ease);
        }
Exemple #5
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);
        }
Exemple #6
0
        private void OnOpened(object sender, EventArgs e)
        {
            QuinticEase ease = new QuinticEase
            {
                EasingMode = EasingMode.EaseOut
            };

            int             modifier = taskbarEdge == Edge.Right || taskbarEdge == Edge.Bottom ? 1 : -1;
            DoubleAnimation outer    = new DoubleAnimation(modifier * 150, 0, TimeSpan.FromSeconds(0.4))
            {
                EasingFunction = ease
            };
            DependencyProperty outerProp = taskbarEdge == Edge.Bottom || taskbarEdge == Edge.Top ? TranslateTransform.YProperty : TranslateTransform.XProperty;

            translateTransform.BeginAnimation(outerProp, outer);

            DoubleAnimation opacity = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(0.4))
            {
                EasingFunction = ease
            };

            border.BeginAnimation(OpacityProperty, opacity);

            ThicknessAnimation inner = new ThicknessAnimation(new Thickness(0), TimeSpan.FromSeconds(0.8))
            {
                EasingFunction = ease
            };

            if (taskbarEdge == Edge.Top)
            {
                inner.From = new Thickness(0, -50, 0, 50);
            }
            else if (taskbarEdge == Edge.Right)
            {
                inner.From = new Thickness(50, 0, -50, 0);
            }
            else if (taskbarEdge == Edge.Bottom)
            {
                inner.From = new Thickness(0, 50, 0, -50);
            }
            else if (taskbarEdge == Edge.Left)
            {
                inner.From = new Thickness(-50, 0, 50, 0);
            }
            searchResultsView.searchResultsViewGrid.BeginAnimation(MarginProperty, inner);
        }
Exemple #7
0
        public static void OpacityControl(Control control, double From, double To, double TimeSecond, double TimeMillisecond = 0)
        {
            QuinticEase EP = new QuinticEase();

            EP.EasingMode = EasingMode.EaseOut;

            var Dir = new DoubleAnimation
            {
                Duration       = new Duration(TimeSpan.FromSeconds(TimeSecond)),
                From           = From,
                To             = To,
                BeginTime      = TimeSpan.FromMilliseconds(TimeMillisecond),
                EasingFunction = EP,
                AutoReverse    = false
            };

            control.BeginAnimation(UIElement.OpacityProperty, Dir);
        }
Exemple #8
0
        private void StartMotion()
        {
            const float Duration = 400;

            QuinticEase ease = new QuinticEase()
            {
                EasingMode = EasingMode.EaseOut,
            };
            DoubleAnimation alphaAnim = new DoubleAnimation(0.3f, 0f, new Duration(TimeSpan.FromMilliseconds(Duration)));
            DoubleAnimation scaleAnim = new DoubleAnimation(0.8f, 1f, new Duration(TimeSpan.FromMilliseconds(Duration)));

            scaleAnim.Completed     += Anim_Completed;
            alphaAnim.EasingFunction = ease;
            scaleAnim.EasingFunction = ease;

            FxGroup.RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnim);
            FxGroup.BeginAnimation(Canvas.OpacityProperty, alphaAnim);
        }
Exemple #9
0
        /// <summary>
        /// Use this method to make an animation for a control in X axis
        /// </summary>
        /// <param name="cntrl">The targhetting Control</param>
        /// <param name="XPos">Here the position to add</param>
        /// <param name="TimeSecond">The duration of the animation</param>
        /// <param name="TimeMillisecond">The delay of the animation</param>
        public static void MoveToTargetX(Control control, double From, double To, double TimeSecond, double TimeMillisecond = 0)
        {
            control.Margin = new Thickness(control.Margin.Left - To, control.Margin.Top, control.Margin.Right + To, control.Margin.Bottom);
            QuinticEase EP = new QuinticEase();

            EP.EasingMode = EasingMode.EaseOut;

            var DirX = new DoubleAnimation
            {
                Duration       = new Duration(TimeSpan.FromSeconds(TimeSecond)),
                From           = From,
                To             = To,
                BeginTime      = TimeSpan.FromMilliseconds(TimeMillisecond),
                EasingFunction = EP,
                AutoReverse    = false
            };

            control.RenderTransform = new TranslateTransform();
            control.RenderTransform.BeginAnimation(TranslateTransform.XProperty, DirX);
        }
        private void EasingChanged()
        {
            if (cboEasingFunction.SelectedIndex == -1 || cboEasingMode.SelectedIndex == -1)
            {
                return;
            }

            storyboard.Stop();

            EasingFunctionBase easingFunction = null;

            // 确定 Easing Function
            switch ((cboEasingFunction.SelectedItem as ComboBoxItem).Content.ToString())
            {
            case "BackEase":
                // Amplitude - 幅度,必须大于等于 0,默认值 1
                easingFunction = new BackEase()
                {
                    Amplitude = 1
                };
                break;

            case "BounceEase":
                // Bounces - 弹跳次数,必须大于等于 0,默认值 3
                // Bounciness - 弹跳程度,必须是正数,默认值 2
                easingFunction = new BounceEase()
                {
                    Bounces = 3, Bounciness = 2
                };
                break;

            case "CircleEase":
                easingFunction = new CircleEase();
                break;

            case "CubicEase":
                easingFunction = new CubicEase();
                break;

            case "ElasticEase":
                // Oscillations - 来回滑动的次数,必须大于等于 0,默认值 3
                // Springiness - 弹簧的弹度,必须是正数,默认值 3
                easingFunction = new ElasticEase()
                {
                    Oscillations = 3, Springiness = 3
                };
                break;

            case "ExponentialEase":
                easingFunction = new ExponentialEase();
                break;

            case "PowerEase":
                easingFunction = new PowerEase();
                break;

            case "QuadraticEase":
                easingFunction = new QuadraticEase();
                break;

            case "QuarticEase":
                easingFunction = new QuarticEase();
                break;

            case "QuinticEase":
                easingFunction = new QuinticEase();
                break;

            case "SineEase":
                easingFunction = new SineEase();
                break;

            default:
                break;
            }

            // 确定 Easing Mode
            switch ((cboEasingMode.SelectedItem as ComboBoxItem).Content.ToString())
            {
            case "EaseIn":     // 渐进
                easingFunction.EasingMode = EasingMode.EaseIn;
                break;

            case "EaseOut":     // 渐出(默认值)
                easingFunction.EasingMode = EasingMode.EaseOut;
                break;

            case "EaseInOut":     // 前半段渐进,后半段渐出
                easingFunction.EasingMode = EasingMode.EaseInOut;
                break;

            default:
                break;
            }

            // 用于演示缓动效果
            aniEasingDemo.EasingFunction = easingFunction;
            // 用于演示缓动轨迹
            aniBallY.EasingFunction = easingFunction;

            // 画出当前缓动的曲线图
            DrawEasingGraph(easingFunction);

            storyboard.Begin();
        }
Exemple #11
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);
        }
Exemple #12
0
        object IValueConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string          functionEase       = value as string;
            IEasingFunction returnFunctionEase = null;

            if (functionEase != null)
            {
                switch (functionEase)
                {
                case "ElasticEase":
                    returnFunctionEase = new ElasticEase();
                    ((ElasticEase)returnFunctionEase).Springiness  = 8;
                    ((ElasticEase)returnFunctionEase).Oscillations = 10;
                    break;

                case "BounceEase":
                    returnFunctionEase = new BounceEase();
                    ((BounceEase)returnFunctionEase).Bounces    = 8;
                    ((BounceEase)returnFunctionEase).Bounciness = 2;
                    break;

                case "BackEase":
                    returnFunctionEase = new BackEase();
                    ((BackEase)returnFunctionEase).Amplitude = 1;
                    break;

                case "CircleEase":
                    returnFunctionEase = new CircleEase();
                    break;

                case "CubicEase":
                    returnFunctionEase = new CubicEase();
                    break;

                case "ExponentialEase":
                    returnFunctionEase = new ExponentialEase();
                    ((ExponentialEase)returnFunctionEase).Exponent = 5;
                    break;

                case "PowerEase":
                    returnFunctionEase = new PowerEase();
                    ((PowerEase)returnFunctionEase).Power = 5;
                    break;

                case "QuadraticEase":
                    returnFunctionEase = new QuadraticEase();
                    break;

                case "QuarticEase":
                    returnFunctionEase = new QuarticEase();
                    break;

                case "QuinticEase":
                    returnFunctionEase = new QuinticEase();
                    break;

                case "SineEase":
                    returnFunctionEase = new SineEase();
                    break;
                }
            }
            return(returnFunctionEase);
        }
        private EasingFunctionBase createEasingFunction(EasingType easingType, EasingMode easingMode, double?param1 = null, int?param2 = null)
        {
            EasingFunctionBase easingFunctionBase = null;

            switch (easingType)
            {
            case EasingType.Sine:
                easingFunctionBase = new SineEase();
                break;

            case EasingType.Cubic:
                easingFunctionBase = new CubicEase();
                break;

            case EasingType.Quint:
                easingFunctionBase = new QuinticEase();
                break;

            case EasingType.Circ:
                easingFunctionBase = new CircleEase();
                break;

            case EasingType.Quad:
                easingFunctionBase = new QuadraticEase();
                break;

            case EasingType.Quart:
                easingFunctionBase = new QuarticEase();
                break;

            case EasingType.Elastic:
                easingFunctionBase = new ElasticEase
                {
                    Springiness  = param1.GetValueOrDefault(3.0),
                    Oscillations = param2.GetValueOrDefault(3)
                };
                break;

            case EasingType.Expo:
                easingFunctionBase = new ExponentialEase
                {
                    Exponent = param1.GetValueOrDefault(2.0)
                };
                break;

            case EasingType.Back:
                easingFunctionBase = new BackEase
                {
                    Amplitude = param1.GetValueOrDefault(1.0)
                };
                break;

            case EasingType.Bounce:
                easingFunctionBase = new BounceEase
                {
                    Bounciness = param1.GetValueOrDefault(2.0),
                    Bounces    = param2.GetValueOrDefault(3)
                };
                break;
            }
            if (easingFunctionBase != null)
            {
                easingFunctionBase.EasingMode = easingMode;
            }
            return(easingFunctionBase);
        }
Exemple #14
0
        private void RenderUI()
        {
            // get the layoutroot
            _layoutRoot = (Grid)this.GetTemplateChild("LayoutRoot");
            if (null == _layoutRoot)
            {
                return;
            }

            // clear any children
            _layoutRoot.Children.Clear();

            // get ellipse size
            double ellipseSize = StyleHelper.GetApplicationDouble(LayoutSizes.SwipeLeftEllipseRadius);

            // set up grid
            _layoutRoot.Width      = WIDTH_CONTROL;
            _layoutRoot.RowSpacing = StyleHelper.GetApplicationDouble(LayoutSizes.SwipeLeftSpacer);
            _layoutRoot.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(ellipseSize)
            });
            _layoutRoot.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1.0, GridUnitType.Auto)
            });
            _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1.0, GridUnitType.Star)
            });

            // test
            //TestHelper.AddGridCellBorders(_layoutRoot, 2, 1, Colors.DeepSkyBlue);

            // create textblock
            _textSwipe = new TextBlockEx()
            {
                Name                = "SwipeText",
                TextStyle           = TextStyles.Swipe,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };
            _textSwipe.SetBinding(TextBlockEx.TextProperty,
                                  new Binding()
            {
                Source = this, Path = new PropertyPath("SwipeText"), Mode = BindingMode.OneWay
            });
            Grid.SetRow(_textSwipe, 1);
            Grid.SetColumn(_textSwipe, 0);
            _layoutRoot.Children.Add(_textSwipe);

            // create the ellipse
            _ellipseSwipe = new Ellipse()
            {
                Width  = ellipseSize,
                Height = ellipseSize,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Center,
                Stroke  = new SolidColorBrush(Colors.White),
                Fill    = new SolidColorBrush(Colors.White),
                Opacity = 0.0
            };
            Grid.SetRow(_ellipseSwipe, 0);
            Grid.SetColumn(_ellipseSwipe, 0);
            _layoutRoot.Children.Add(_ellipseSwipe);

            // add a translate transform to the ellipse
            _translateEllipse = new TranslateTransform()
            {
                X = 0
            };
            _ellipseSwipe.RenderTransform = _translateEllipse;

            // set up control fades
            _storyboardFadeIn  = AnimationHelper.CreateEasingAnimation(_layoutRoot, "Opacity", 0.0, 0.0, 1.0, this.DurationInMilliseconds, this.StaggerDelayInMilliseconds + ANIM_STAGGER_TEXT_FADEIN, false, false, new RepeatBehavior(1));
            _storyboardFadeOut = AnimationHelper.CreateEasingAnimation(_layoutRoot, "Opacity", 0.0, 1.0, 0.0, this.DurationInMilliseconds, this.StaggerDelayInMilliseconds + ANIM_STAGGER_TEXT_FADEOUT, false, false, new RepeatBehavior(1));

            // set up ellipse fades
            _storyboardEllipseFadeIn  = AnimationHelper.CreateEasingAnimationWithNotify(_ellipseSwipe, this.FadeIn_Complete, "Opacity", 0.0, 0.0, 1.0, null, null, ANIM_DURATION_ELLIPSE_FADE, this.StaggerDelayInMilliseconds + ANIM_STAGGER_ELLIPSE_FADEIN, false, false, new RepeatBehavior(1));
            _storyboardEllipseFadeOut = AnimationHelper.CreateEasingAnimation(_ellipseSwipe, "Opacity", 0.0, 1.0, 0.0, ANIM_DURATION_ELLIPSE_FADE, 0d, false, false, new RepeatBehavior(1));
            // fade out original stagger:  this.StaggerDelayInMilliseconds + ANIM_STAGGER_ELLIPSE_FADEOUT

            QuinticEase quinticEase = new QuinticEase()
            {
                EasingMode = EasingMode.EaseInOut
            };

            // set up ellipse move
            _storyboardEllipseMove = AnimationHelper.CreateEasingAnimationWithNotify(_ellipseSwipe, this.Move_Complete, "(Ellipse.RenderTransform).(TranslateTransform.X)", 0.0, 0.0, -1 * WIDTH_CONTROL + ellipseSize, quinticEase, quinticEase, ANIM_DURATION_ELLIPSE_MOVE, 0d, false, false, new RepeatBehavior(1));
            // move original stagger: this.StaggerDelayInMilliseconds + ANIM_STAGGER_ELLIPSE_MOVE
        }
Exemple #15
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            EasingFunctionBase easingFunctionBase = null;

            switch (EasingType)
            {
            case EasingType.Sine:
                easingFunctionBase = new SineEase();
                break;

            case EasingType.Cubic:
                easingFunctionBase = new CubicEase();
                break;

            case EasingType.Quint:
                easingFunctionBase = new QuinticEase();
                break;

            case EasingType.Circ:
                easingFunctionBase = new CircleEase();
                break;

            case EasingType.Quad:
                easingFunctionBase = new QuadraticEase();
                break;

            case EasingType.Quart:
                easingFunctionBase = new QuarticEase();
                break;

            case EasingType.Elastic:
                easingFunctionBase = new ElasticEase
                {
                    Springiness  = Param1.GetValueOrDefault(3.0),
                    Oscillations = Param2.GetValueOrDefault(3)
                };
                break;

            case EasingType.Expo:
                easingFunctionBase = new ExponentialEase
                {
                    Exponent = Param1.GetValueOrDefault(2.0)
                };
                break;

            case EasingType.Back:
                easingFunctionBase = new BackEase
                {
                    Amplitude = Param1.GetValueOrDefault(1.0)
                };
                break;

            case EasingType.Bounce:
                easingFunctionBase = new BounceEase
                {
                    Bounciness = Param1.GetValueOrDefault(2.0),
                    Bounces    = Param2.GetValueOrDefault(3)
                };
                break;
            }
            if (easingFunctionBase != null)
            {
                easingFunctionBase.EasingMode = EasingMode;
            }
            return(easingFunctionBase);
        }
Exemple #16
0
        private void OnOpened(object sender, EventArgs e)
        {
            Keyboard.Focus(SearchBox);

            switch (taskbarEdge)
            {
            case Edge.Top:
                Placement = PlacementMode.Bottom;
                PopupBorder.BorderThickness = new Thickness(1);
                PopupMarginBorder.Margin    = new Thickness(10, 0, 10, 10);
                break;

            case Edge.Left:
                Placement = PlacementMode.Right;
                PopupBorder.BorderThickness = new Thickness(1);
                PopupMarginBorder.Margin    = new Thickness(0, 10, 10, 10);
                break;

            case Edge.Right:
                Placement = PlacementMode.Left;
                PopupBorder.BorderThickness = new Thickness(1);
                PopupMarginBorder.Margin    = new Thickness(10, 10, 0, 10);
                break;

            case Edge.Bottom:
                Placement = PlacementMode.Top;
                PopupBorder.BorderThickness = new Thickness(1, 1, 1, 0);
                PopupMarginBorder.Margin    = new Thickness(10, 10, 10, 0);
                break;
            }

            Height = Properties.Settings.Default.popupSize.Height;
            Width  = Properties.Settings.Default.popupSize.Width;

            QuinticEase ease = new QuinticEase
            {
                EasingMode = EasingMode.EaseOut
            };

            int             modifier = taskbarEdge == Edge.Right || taskbarEdge == Edge.Bottom ? 1 : -1;
            Duration        duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.4);
            DoubleAnimation outer    = new DoubleAnimation(modifier * 150, 0, duration)
            {
                EasingFunction = ease
            };
            DependencyProperty outerProp = taskbarEdge == Edge.Bottom || taskbarEdge == Edge.Top ? TranslateTransform.YProperty : TranslateTransform.XProperty;

            translateTransform?.BeginAnimation(outerProp, outer);

            DoubleAnimation opacity = new DoubleAnimation(0, 1, duration)
            {
                EasingFunction = ease
            };

            PopupBorder?.BeginAnimation(OpacityProperty, opacity);

            duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.8);
            ThicknessAnimation inner = new ThicknessAnimation(new Thickness(0), duration)
            {
                EasingFunction = ease
            };

            if (taskbarEdge == Edge.Top)
            {
                inner.From = new Thickness(0, -50, 0, 50);
            }
            else if (taskbarEdge == Edge.Right)
            {
                inner.From = new Thickness(50, 0, -50, 0);
            }
            else if (taskbarEdge == Edge.Bottom)
            {
                inner.From = new Thickness(0, 50, 0, -50);
            }
            else if (taskbarEdge == Edge.Left)
            {
                inner.From = new Thickness(-50, 0, 50, 0);
            }
            ContentGrid?.BeginAnimation(MarginProperty, inner);
        }
Exemple #17
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
            });
        }