Esempio n. 1
0
        private void button4_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //定义多关键帧动画
            DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();

            sb4 = new Storyboard();
            this.sb4.Completed    += new System.EventHandler(Storyboard_Completed);
            this.button1.IsEnabled = false;
            this.button2.IsEnabled = false;
            this.button3.IsEnabled = false;
            this.button4.IsEnabled = false;
            sb4.Children.Add(daukf);
            //动画影响属性:元素的三维旋转(以Y轴为旋转轴)
            Storyboard.SetTargetProperty(daukf, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
            Storyboard.SetTarget(daukf, image);
            //定义第1个可插入的关键帧(可以和Silverlight目前提供的11种缓动函数关联)
            //(缓动函数设置了关键帧之间的动画过渡状态)
            EasingDoubleKeyFrame kf1 = new EasingDoubleKeyFrame();

            kf1.Value   = 80;                       //设置此关键帧的目标值(旋转度数)
            kf1.KeyTime = new TimeSpan(0, 0, 0, 3); //设置达到目标值的时间(日,小时,分,秒)
            BackEase kf1be = new BackEase();        //定义具有收回效果的缓动函数对象

            //EasingMode有3种选择:EaseIn、EaseOut和EaseInOut
            kf1be.EasingMode   = EasingMode.EaseOut; //EaseOut方式
            kf1.EasingFunction = kf1be;              //第1帧使用缓动函数BackEase的EaseOut方式过渡
            //定义第2个可插入的关键帧
            EasingDoubleKeyFrame kf2 = new EasingDoubleKeyFrame();

            kf2.Value   = 0;
            kf2.KeyTime = new TimeSpan(0, 0, 0, 6); //第2帧达到第6秒
            BounceEase kf2be = new BounceEase();    //定义具有反弹效果的缓动函数对象

            kf2be.EasingMode   = EasingMode.EaseIn; //EaseIn方式
            kf2be.Bounces      = 3;                 //反弹3次
            kf2.EasingFunction = kf2be;             //第2帧使用缓动函数BounceEase的EaseIn方式过渡
            //定义第3个可插入的关键帧
            EasingDoubleKeyFrame kf3 = new EasingDoubleKeyFrame();

            kf3.Value   = -80;
            kf3.KeyTime = new TimeSpan(0, 0, 0, 9);    //第3帧达到第9秒
            ElasticEase kf3ee = new ElasticEase();     //定义具有衰减振荡效果的缓动函数对象

            kf3ee.EasingMode   = EasingMode.EaseInOut; //EaseInOut方式
            kf3ee.Oscillations = 4;                    //振荡次数
            kf3ee.Ease(4);                             //衰减振荡持续时间
            kf3.EasingFunction = kf3ee;                //第3帧使用缓动函数ElasticEase的EaseInOut方式过渡
            //定义第4个可插入的关键帧
            EasingDoubleKeyFrame kf4 = new EasingDoubleKeyFrame();

            kf4.Value   = 0;
            kf4.KeyTime = new TimeSpan(0, 0, 0, 12); //第4帧达到第12秒
            daukf.KeyFrames.Add(kf1);                //添加关键帧
            daukf.KeyFrames.Add(kf2);
            daukf.KeyFrames.Add(kf3);
            daukf.KeyFrames.Add(kf4);
            daukf.AutoReverse    = true;                  //允许翻转
            daukf.RepeatBehavior = new RepeatBehavior(1); //反复1次
            sb4.Begin();
        }
    public void AnimateToPoint(Point point, int durationInMilliseconds = 300)
    {
        var duration = new Duration(TimeSpan.FromMilliseconds(durationInMilliseconds));
        var easing   = new BackEase
        {
            Amplitude = .3
        };
        var sb = new Storyboard
        {
            Duration = duration
        };
        var animateLeft = new DoubleAnimation
        {
            From           = Canvas.GetLeft(_element),
            To             = point.X,
            Duration       = duration,
            EasingFunction = easing,
        };
        var animateTop = new DoubleAnimation
        {
            From           = Canvas.GetTop(_element),
            To             = point.Y,
            Duration       = duration,
            EasingFunction = easing,
        };

        Storyboard.SetTargetProperty(animateLeft, "(Canvas.Left)");
        Storyboard.SetTarget(animateLeft, _element);
        Storyboard.SetTargetProperty(animateTop, "(Canvas.Top)");
        Storyboard.SetTarget(animateTop, _element);
        sb.Children.Add(animateLeft);
        sb.Children.Add(animateTop);
        sb.Begin();
    }
Esempio n. 3
0
        private void AnimateEntry(Size targetSize)
        {
            var svi = GuiHelpers.GetParentObject <ScatterViewItem>(this, false);

            if (svi != null)
            {
                // Easing function provide a more natural animation
                IEasingFunction ease = new BackEase {
                    EasingMode = EasingMode.EaseOut, Amplitude = 0.3
                };
                var duration = new Duration(TimeSpan.FromMilliseconds(500));
                var w        = new DoubleAnimation(0.0, targetSize.Width, duration)
                {
                    EasingFunction = ease
                };
                var h = new DoubleAnimation(0.0, targetSize.Height, duration)
                {
                    EasingFunction = ease
                };
                var o = new DoubleAnimation(0.0, 1.0, duration);

                // Remove the animation after it has completed so that its possible to manually resize the scatterviewitem
                w.Completed += (s, e) => svi.BeginAnimation(ScatterViewItem.WidthProperty, null);
                h.Completed += (s, e) => svi.BeginAnimation(ScatterViewItem.HeightProperty, null);
                // Set the size manually, otherwise once the animation is removed the size will revert back to the minimum size
                // Since animation has higher priority for DP's, this setting won't have effect until the animation is removed
                svi.Width  = targetSize.Width;
                svi.Height = targetSize.Height;

                svi.BeginAnimation(ScatterViewItem.WidthProperty, w);
                svi.BeginAnimation(ScatterViewItem.HeightProperty, h);
                svi.BeginAnimation(ScatterViewItem.OpacityProperty, o);
            }
        }
Esempio n. 4
0
        public void ShowFreshNews()
        {
            if (this._freshNewsState == FreshNewsState.NoNews || this._isAnimating || this._isFreshNewsShowed)
            {
                return;
            }
            this._isAnimating = true;
            TranslateTransform target = this._translateFreshNews;
            double             y      = this._translateFreshNews.Y;
            double             freshNewsTranslateY = this.GetMaxFreshNewsTranslateY();
            DependencyProperty dependencyProperty  = TranslateTransform.YProperty;
            int      duration  = 350;
            int?     startTime = new int?(0);
            BackEase backEase  = new BackEase();
            int      num1      = 0;

            backEase.EasingMode = (EasingMode)num1;
            double num2 = 0.5;

            backEase.Amplitude = num2;
            Action completed = (Action)(() =>
            {
                this._isAnimating = false;
                this._isFreshNewsShowed = true;
            });
            int num3 = 0;

            target.Animate(y, freshNewsTranslateY, (object)dependencyProperty, duration, startTime, (IEasingFunction)backEase, completed, num3 != 0);
        }
        private static void OnTimerTick(RadCartesianChart chart)
        {
            CameraInfo cameraInfo = GetOrCreateCameraInfo(chart);

            double durationInSeconds = 1.5;
            Point  targetOffset      = new Point(100, -75);

            TimeSpan timeSpan = DateTime.Now - cameraInfo.initialAnimationDateTime;

            if (durationInSeconds < timeSpan.TotalSeconds)
            {
                cameraInfo.initialAnimationTimer.Stop();
                cameraInfo.initialAnimationTimer = null;
                return;
            }

            double progress = timeSpan.TotalSeconds / durationInSeconds;

            EasingFunctionBase ease = new BackEase {
                EasingMode = EasingMode.EaseIn
            };
            double easedProgress = ease.Ease(progress);
            double hOffset       = easedProgress * targetOffset.X;

            ease = new CubicEase {
                EasingMode = EasingMode.EaseInOut
            };
            easedProgress = ease.Ease(progress);
            double vOffset = easedProgress * targetOffset.Y;

            MoveCamera(chart, new Point(hOffset, vOffset));
        }
        public void Move(Point translation)
        {
            // Easing function provide a more natural animation
            BackEase ease = new BackEase {
                EasingMode = EasingMode.EaseOut, Amplitude = 0.3
            };
            var duration = new Duration(TimeSpan.FromMilliseconds(500));
            var x        = new DoubleAnimation()
            {
                From = _deltaTransform.TranslateX, To = translation.X, Duration = duration, EasingFunction = ease
            };
            var y = new DoubleAnimation()
            {
                From = _deltaTransform.TranslateY, To = translation.Y, Duration = duration, EasingFunction = ease
            };

            Storyboard stb = new Storyboard();

            stb.Children.Add(x);
            stb.Children.Add(y);
            Storyboard.SetTarget(x, _target);
            Storyboard.SetTarget(y, _target);
            Storyboard.SetTargetProperty(x, "(UIElement.RenderTransform).(TransformGroup.Children)[1].(CompositeTransform.TranslateX)");
            Storyboard.SetTargetProperty(y, "(UIElement.RenderTransform).(TransformGroup.Children)[1].(CompositeTransform.TranslateY)");
            stb.Begin();
        }
Esempio n. 7
0
        private void Element_Search_Box_Animation(double from, double to, double time, double amplitude = 0, EasingMode mode = EasingMode.EaseOut, IEasingFunction ea = null)
        {
            DoubleAnimation da = new DoubleAnimation();

            da.From     = from;
            da.To       = to;
            da.Duration = new Duration(TimeSpan.FromSeconds(time));

            if (ea != null)
            {
                da.EasingFunction = ea;
            }
            else
            {
                BackEase b = new BackEase();
                b.Amplitude       = amplitude;
                b.EasingMode      = mode;
                da.EasingFunction = b;
            }

            TranslateTransform t = null;

            switch (Pivot_Current)
            {
            case "Routes":
                t = Routes_Search_Box_Transform;
                break;

            case "Stops":
                t = Stops_Search_Box_Transform;
                break;
            }

            Util.DoubleAnimation(t, new PropertyPath("(TranslateTransform.Y)"), da);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        private static DoubleAnimation CreateFadeOutAnimation()
        {
            DoubleAnimation da       = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(200).Duration());
            BackEase        backEase = new BackEase();

            backEase.EasingMode = EasingMode.EaseIn;
            backEase.Amplitude  = 0.5;
            da.EasingFunction   = backEase;
            return(da);
        }
Esempio n. 11
0
        /// <summary>
        ///		Obtiene una función Back
        /// </summary>
        private BackEase GetBackEase(BackEaseModel backEase)
        {
            BackEase ease = new BackEase();

            // Asigna las propiedades
            ease.Amplitude  = backEase.Amplitude;
            ease.EasingMode = ConvertEaseMode(backEase.EaseMode);
            // Devuelve la función
            return(ease);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public void NavigateToPage(int index, bool isAnimated)
        {
            OnPageNavigating();
            _isAnimating = isAnimated;
            int    currentChildIndex     = 0;
            double animationDelaySeconds = NavigationAnimationDuration.TimeSpan.TotalSeconds * 0.008;

            foreach (var page in _pages)
            {
                TimeSpan animationDelay = TimeSpan.FromSeconds(0);
                foreach (var row in page.Rows)
                {
                    foreach (var child in row.Children)
                    {
                        bool isDragMoving = AllowDragMoveChild && _isMouseDownOnChild && child.Equals(_mouseClickedChild);
                        if (isDragMoving)
                        {
                            ++currentChildIndex;
                            continue;
                        }
                        TranslateTransform tt = child.RenderTransform as TranslateTransform;
                        if (isAnimated)
                        {
                            DoubleAnimation d     = new DoubleAnimation();
                            BackEase        bEase = new BackEase();
                            bEase.EasingMode = EasingMode.EaseOut;
                            bEase.Amplitude  = 0.3;
                            d.EasingFunction = bEase;
                            d.Duration       = NavigationAnimationDuration;
                            d.From           = tt.X;
                            d.To             = -index * Width;
                            d.BeginTime      = animationDelay;
                            d.Completed     += (s, e) =>
                            {
                                if (++currentChildIndex == InternalChildren.Count)
                                {
                                    _isAnimating = false;
                                    OnPageNavigated();
                                }
                            };
                            tt.BeginAnimation(TranslateTransform.XProperty, d);
                            animationDelay += TimeSpan.FromSeconds(animationDelaySeconds);
                        }
                        else
                        {
                            tt.X = -index * Width;
                        }
                        _currentPageIndex = index;
                    }
                }
            }
            _dragMovedElements.Clear();
        }
Esempio n. 14
0
        private void L2R()
        {
            try
            {
                Storyboard storyboard = new Storyboard();
                storyboard.Completed += Storyboard_Completed;

                foreach (Image img in gd_Images.Children)
                {
                    TranslateTransform transform = ((img.RenderTransform as TransformGroup).Children[0] as TranslateTransform);

                    DoubleAnimationUsingKeyFrames keyFrames = new DoubleAnimationUsingKeyFrames();
                    Storyboard.SetTarget(keyFrames, img);
                    Storyboard.SetTargetProperty(keyFrames, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)"));

                    BackEase backEase = new BackEase
                    {
                        EasingMode = EasingMode.EaseOut
                    };

                    EasingDoubleKeyFrame keyFrame1 = new EasingDoubleKeyFrame()
                    {
                        KeyTime        = TimeSpan.FromSeconds(0),
                        Value          = transform.X,
                        EasingFunction = backEase
                    };
                    keyFrames.KeyFrames.Add(keyFrame1);

                    EasingDoubleKeyFrame keyFrame2 = new EasingDoubleKeyFrame()
                    {
                        KeyTime        = TimeSpan.FromSeconds(0.5),
                        Value          = transform.X + gd_Images.ActualWidth,
                        EasingFunction = backEase
                    };
                    keyFrames.KeyFrames.Add(keyFrame2);
                    storyboard.Children.Add(keyFrames);
                }

                storyboard.Begin();

                foreach (Ellipse e in gd_Points.Children)
                {
                    e.Fill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                }
                (gd_Points.Children[m_ImageIndex - 2] as Ellipse).Fill = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
        }
        /// <summary>
        /// Moves the hover border to the specified X offset.
        /// </summary>
        /// <param name="xPosition">The X offset.</param>
        private void MoveBorder(double xPosition)
        {
            var to = xPosition;
            TranslateTransform trans = new TranslateTransform();

            canBorder.RenderTransform = trans;
            var             be  = new BackEase();
            DoubleAnimation da1 = new DoubleAnimation(from, to, TimeSpan.FromMilliseconds(300))
            {
                AccelerationRatio = 1
            };

            trans.BeginAnimation(TranslateTransform.XProperty, da1);
            from = to;
        }
Esempio n. 16
0
        private void FadeIn()
        {
            DoubleAnimation da       = new DoubleAnimation(0.8, 1, TimeSpan.FromMilliseconds(400).Duration());
            BackEase        backEase = new BackEase();

            backEase.Amplitude = 0.5;
            da.EasingFunction  = backEase;
            ScaleTransform st = new ScaleTransform();

            st.CenterX = ActualWidth / 2;
            st.CenterY = ActualHeight / 2;
            st.BeginAnimation(ScaleTransform.ScaleXProperty, da);
            st.BeginAnimation(ScaleTransform.ScaleYProperty, da);
            this.RenderTransform = st;
        }
        private AnimationTimeline CreateAnimation(double from, double to, EventHandler whenDone = null)
        {
            IEasingFunction ease = new BackEase {
                Amplitude = 0.5, EasingMode = EasingMode.EaseOut
            };
            var duration = new Duration(TimeSpan.FromSeconds(0.5));
            var anim     = new DoubleAnimation(from, to, duration); //{ EasingFunction = ease };

            if (whenDone != null)
            {
                anim.Completed += whenDone;
            }
            anim.Freeze();
            return(anim);
        }
Esempio n. 18
0
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.RemovedItems.Count < 1 || !(e.RemovedItems[0] is FrameworkElement))
            {
                return;
            }
            if (!RunAnimations)
            {
                return;
            }
            var oldControl = (FrameworkElement)((TabItem)e.RemovedItems[0]).Content;
            var control    = (TabControl)sender;
            var tempArea   = (System.Windows.Shapes.Shape)control.Template.FindName("PART_TempArea", (FrameworkElement)sender);
            var presenter  = (ContentPresenter)control.Template.FindName("PART_Presenter", (FrameworkElement)sender);
            var target     = new RenderTargetBitmap((int)control.ActualWidth, (int)control.ActualHeight, 96, 96, PixelFormats.Pbgra32);

            target.Render(oldControl);
            tempArea.HorizontalAlignment = HorizontalAlignment.Stretch;
            tempArea.Fill             = new ImageBrush(target);
            tempArea.RenderTransform  = new TranslateTransform();
            presenter.RenderTransform = new TranslateTransform();
            presenter.RenderTransform.BeginAnimation(TranslateTransform.XProperty, CreateAnimation(control.ActualWidth, 0));
            tempArea.RenderTransform.BeginAnimation(TranslateTransform.XProperty, CreateAnimation(0, -control.ActualWidth, (x, y) => { tempArea.HorizontalAlignment = HorizontalAlignment.Left; }));
            tempArea.Fill.BeginAnimation(Brush.OpacityProperty, CreateAnimation(1, 0));


            AnimationTimeline CreateAnimation(double from, double to,
                                              EventHandler whenDone = null)
            {
                IEasingFunction ease = new BackEase
                {
                    Amplitude = 0.2, EasingMode = EasingMode.EaseOut
                };
                var duration = new Duration(TimeSpan.FromSeconds(0.2));
                var anim     = new DoubleAnimation(from, to, duration)
                {
                    EasingFunction = ease
                };

                if (whenDone != null)
                {
                    anim.Completed += whenDone;
                }
                anim.Freeze();
                return(anim);
            }
        }
Esempio n. 19
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!_isPlayCloseStoryboard)
            {
                //动画播放开始
                _isPlayCloseStoryboard = true;
                //播放动画
                e.Cancel = true;

                #region 创建关闭动画

                Storyboard _closeWindow = new Storyboard();

                DoubleAnimationUsingKeyFrames keyFrame3 = new DoubleAnimationUsingKeyFrames();
                EasingDoubleKeyFrame          ea        = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)));
                BackEase be = new BackEase();
                be.EasingMode     = EasingMode.EaseIn;
                ea.EasingFunction = be;
                keyFrame3.KeyFrames.Add(ea);
                Storyboard.SetTarget(keyFrame3, Win_Main);
                Storyboard.SetTargetProperty(keyFrame3, new PropertyPath("(UIElement.Opacity)"));
                _closeWindow.Children.Add(keyFrame3);

                DoubleAnimationUsingKeyFrames keyFrame5 = new DoubleAnimationUsingKeyFrames();
                ea                = new EasingDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.4)));
                ea                = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.6)));
                be                = new BackEase();
                be.EasingMode     = EasingMode.EaseIn;
                ea.EasingFunction = be;
                keyFrame5.KeyFrames.Add(ea);
                Storyboard.SetTarget(keyFrame5, this);
                Storyboard.SetTargetProperty(keyFrame5, new PropertyPath("(UIElement.Opacity)"));
                _closeWindow.Children.Add(keyFrame5);

                #endregion

                _closeWindow.Completed += _closeWindow_Completed;
                _closeWindow.Begin();
            }
            else
            {
                e.Cancel = !_isCloseStoryboardCompleted;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Führt die Animation für beide Contents aus
        /// </summary>
        private void _BeginAnimateContentReplacement()
        {
            OldContentTransform = new TranslateTransform();
            NewContentTransform = new TranslateTransform();

            _paintArea.Visibility        = Visibility.Visible;
            _paintArea.RenderTransform   = OldContentTransform;
            _mainContent.RenderTransform = NewContentTransform;

            IEasingFunction ease = new BackEase {
                Amplitude  = 0.5,
                EasingMode = EasingMode.EaseInOut
            };

            NewContentTransform.BeginAnimation(TranslateTransform.XProperty, AnimateLib.CreateAnimation(this.ActualWidth, 0, 0, 1, ease));
            OldContentTransform.BeginAnimation(TranslateTransform.XProperty, AnimateLib.CreateAnimation(0, -this.ActualWidth, 0, 1, ease, (s, e) => {
                _paintArea.Visibility = Visibility.Hidden;
            }));
        }
Esempio n. 21
0
        SolidColorBrush colorBrush = new SolidColorBrush(); //Слой анимации, который позже может быть привязана к любому элементу имеющее свойство Background
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            background_color.Background = colorBrush;   //Тут слой и привязывается к самому элементу(Border'у)

            //Переменные для хранения цветов отдельных каналов (красный, зеленый, синий) к которым анимация будет стремиться
            byte to_r;
            byte to_g;
            byte to_b;

            //Условие, привязывает к переменным значения к которым анимация должна стремиться.
            if (!currenttheme)
            {
                to_r         = 50;
                to_g         = 50;
                to_b         = 50;
                currenttheme = !currenttheme;
            }
            else
            {
                to_r         = 245;
                to_g         = 245;
                to_b         = 245;
                currenttheme = !currenttheme;
            }


            BackEase backEase = new BackEase() //Формула плавности с отскоком
            {
                Amplitude = 0.3                //Амплитуда, от этого значения зависит насколько сильно будет отскок.
            };

            backEase.EasingMode = EasingMode.EaseInOut;                                                                  //Когда функция будет действовать, In - в начале, Out - в конце, InOut - в начале и в конце

            ColorAnimation colorAnimation = new ColorAnimation(Color.FromRgb(to_r, to_g, to_b), TimeSpan.FromSeconds(2)) // Собственно сама анимация
            {
                EasingFunction = backEase                                                                                //Привязывается функция плавности к анимации.
            };

            colorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);   //Запуск анимации
        }
Esempio n. 22
0
        public static void addWipeDownAnnimation(UserControl control, double startingDistance)
        {
            ThicknessAnimation backAnimation   = new ThicknessAnimation();
            BackEase           backOrientation = new BackEase();
            double             topMargin       = (-1) * startingDistance;

            backOrientation.Amplitude  = .4;
            backOrientation.EasingMode = EasingMode.EaseIn;
            //double ab = backOrientation.Ease(.7);
            //App.logger.Info("Ease pace : " + ab);
            backAnimation.To             = new Thickness(0, 0, 0, 0);
            backAnimation.From           = new Thickness(0, topMargin, 0, startingDistance);
            backAnimation.EasingFunction = backOrientation;
            //            double ab = backAnimation.;
            //          App.logger.Info("Ease pace : " + ab);
            //backAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));
            //backAnimation.DecelerationRatio = .9;
            backAnimation.SpeedRatio = .3;
            backAnimation.Completed += BackAnimation_Completed;
            control.BeginAnimation(UserControl.MarginProperty, backAnimation);
            App.logger.Info("Deceletation Ration : " + backAnimation.DecelerationRatio);
            App.logger.Info("Acceletation Ration : " + backAnimation.AccelerationRatio);
        }
Esempio n. 23
0
        public static void addBounceAnnimation(UserControl control, Thickness targetThickness)
        {
            ThicknessAnimation bounceAnimation = new ThicknessAnimation();
            //BounceEase BounceOrientation = new BounceEase();
            //BounceOrientation.Bounces = 4;
            //BounceOrientation.Bounciness = 2;

            //bounceAnimation.To = new Thickness(0, 0, 0, 0);
            //bounceAnimation.From = new Thickness(0, targetThickness.Top, 0, targetThickness.Bottom);
            //bounceAnimation.EasingFunction = BounceOrientation;
            //test
            BackEase backOrientation = new BackEase();

            backOrientation.Amplitude = 2;
            backOrientation.Ease(0.3);
            backOrientation.EasingMode = EasingMode.EaseIn;

            bounceAnimation.To             = new Thickness(0, 0, 0, 0);
            bounceAnimation.From           = new Thickness(0, 0, 0, targetThickness.Bottom); //targetThickness.Top, 0, targetThickness.Bottom
            bounceAnimation.EasingFunction = backOrientation;

            control.BeginAnimation(UserControl.MarginProperty, bounceAnimation);
        }
Esempio n. 24
0
        public static AnimationTimeline CreateSlideAnimation(double from, double to, double easingAmplitude, double slideDuration, EventHandler whenDone = null)
        {
            IEasingFunction ease = new BackEase
            {
                Amplitude  = easingAmplitude,
                EasingMode = EasingMode.EaseOut
            };

            var duration = new Duration(TimeSpan.FromSeconds(slideDuration));
            var anim     = new DoubleAnimation(from, to, duration)
            {
                EasingFunction = ease
            };

            if (whenDone != null)
            {
                anim.Completed += whenDone;
            }

            anim.Freeze();

            return(anim);
        }
Esempio n. 25
0
        public void ShowFreshNews()
        {
            if (this._freshNewsState == FreshNewsState.NoNews || this._isAnimating || this._isFreshNewsShowed)
            {
                return;
            }
            this._isAnimating = true;
            TranslateTransform translateFreshNews = this._translateFreshNews;
            double             y = this._translateFreshNews.Y;
            double             freshNewsTranslateY = this.GetMaxFreshNewsTranslateY();

            int?     startTime = new int?(0);
            BackEase backEase  = new BackEase();

            backEase.EasingMode = ((EasingMode)0);
            backEase.Amplitude  = 0.5;
            Action completed = (Action)(() =>
            {
                this._isAnimating = false;
                this._isFreshNewsShowed = true;
            });

            translateFreshNews.Animate(y, freshNewsTranslateY, TranslateTransform.YProperty, 350, startTime, backEase, completed, false);
        }
Esempio n. 26
0
        private void AnimateExit()
        {
            var svi = GuiHelpers.GetParentObject <ScatterViewItem>(this, false);

            if (svi != null)
            {
                IEasingFunction ease = new BackEase {
                    EasingMode = EasingMode.EaseOut, Amplitude = 0.3
                };
                var duration = new Duration(TimeSpan.FromMilliseconds(500));
                var w        = new DoubleAnimation(0.0, duration)
                {
                    EasingFunction = ease
                };
                var h = new DoubleAnimation(0.0, duration)
                {
                    EasingFunction = ease
                };
                var o = new DoubleAnimation(0.0, duration);
                svi.BeginAnimation(ScatterViewItem.WidthProperty, w);
                svi.BeginAnimation(ScatterViewItem.HeightProperty, h);
                svi.BeginAnimation(ScatterViewItem.OpacityProperty, o);
            }
        }
Esempio n. 27
0
        /*
         * 加载所有动画效果
         *
         * @param currElement 当前控件
         *
         * @param currDControl  当前控件数据
         *
         * @param  list 动画列表
         */
        public static void loadAllAnimation(FrameworkElement currElement, DControl currDControl, List <DControlAnimation> list, Cfg cfg)
        {
            double         currOpacity = currDControl.opacity / 100.0;
            TransformGroup group       = (TransformGroup)currElement.RenderTransform;


            // group.Children.Clear();   多次加载动画需要归零
            foreach (DControlAnimation animation in list)
            {
                if (animation.type == 1001)
                {
                    //淡入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);
                    currElement.Opacity = 0;
                    IEasingFunction easingFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0, currOpacity, easingFunction);
                    currElement.BeginAnimation(UIElement.OpacityProperty, da);
                }
                else if (animation.type == 1002)
                {
                    //从左移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.left - currDControl.width, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1003)
                {
                    //从右移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenWidth - currDControl.left, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1004)
                {
                    //从上移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.top - currDControl.height, 0);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1005)
                {
                    //从下移入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenHeight - currDControl.top, 0);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }

                else if (animation.type == 1006)
                {
                    //放大
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 0.5, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1007)
                {
                    //缩小
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 1.5, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1101)
                {
                    //从左旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.width * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1102)
                {
                    //从右旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);

                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.width * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1103)
                {
                    //从上旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.height * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1104)
                {
                    //从下旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 180 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.height * 1, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1201)
                {
                    //从左弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform12 = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction       = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.left - currDControl.width, 0, easingFunction);
                    translateTransform12.BeginAnimation(TranslateTransform.XProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1202)
                {
                    //从右弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction     = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenWidth - currDControl.left, 0, easingFunction);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1203)
                {
                    //从上弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction     = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.top - currDControl.height, 0, easingFunction);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1204)
                {
                    //从下弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    IEasingFunction    easingFunction     = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, cfg.screenHeight - currDControl.top, 0, easingFunction);

                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1205)
                {
                    //中心弹入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0.5, 1.0, easingFunction);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1301)
                {
                    //从左斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 140, 180, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da1 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.width * 1, 0, easingFunction);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1302)
                {
                    //从右斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 40, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da1 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.width, 0, easingFunction);
                    translateTransform.BeginAnimation(TranslateTransform.XProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1303)
                {
                    //从上斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 0.1, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);



                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da1 = DoubleAnimationUtil.initDoubleAnimation(animation, 60, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da1);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, -currDControl.height, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1304)
                {
                    //从下斜入
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da             = DoubleAnimationUtil.initDoubleAnimation(animation, 0.1, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da1 = DoubleAnimationUtil.initDoubleAnimation(animation, 60, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da1);


                    TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group);
                    DoubleAnimation    da2 = DoubleAnimationUtil.initDoubleAnimation(animation, currDControl.height, 0);
                    translateTransform.BeginAnimation(TranslateTransform.YProperty, da2);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1401)
                {
                    //从左绕入

                    currElement.RenderTransformOrigin = new Point(0, 0);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 360 + currDControl.rotateAngle, 0 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1402)
                {
                    //从右绕入

                    currElement.RenderTransformOrigin = new Point(1, 1);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 360 + currDControl.rotateAngle, 0 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1403)
                {
                    //从上绕入


                    currElement.RenderTransformOrigin = new Point(1, 0);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 360 + currDControl.rotateAngle, 0 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);

                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);

                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1404)
                {
                    //从下绕入

                    currElement.RenderTransformOrigin = new Point(0, 1);
                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);


                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    DoubleAnimation da1            = DoubleAnimationUtil.initDoubleAnimation(animation, 0, 1.0);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);


                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity);
                }
                else if (animation.type == 1501)
                {
                    //翻开
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    SkewTransform   skewTransform  = TransformGroupUtil.GetSkewTransform(group);
                    IEasingFunction easingFunction = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut, Amplitude = 0.1
                    };
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 10, 0, easingFunction);
                    skewTransform.BeginAnimation(SkewTransform.AngleXProperty, da);


                    ScaleTransform  scaleTransform  = TransformGroupUtil.GetScaleTransform(group);
                    IEasingFunction easingFunction1 = new BackEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    DoubleAnimation da1 = DoubleAnimationUtil.initDoubleAnimation(animation, 0.4, 1.0, easingFunction1);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da1);


                    IEasingFunction easingFunction2 = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity, easingFunction2);
                }
                else if (animation.type == 1502)
                {
                    //旋转
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);
                    DoubleAnimation da = DoubleAnimationUtil.initDoubleAnimation(animation, 0 + currDControl.rotateAngle, 360 + currDControl.rotateAngle);
                    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, da);

                    IEasingFunction easingFunction2 = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    DoubleAnimationUtil.andBeginOpacityAnimation(currElement, animation, 0, currOpacity, easingFunction2);
                }
                else if (animation.type == 1601)
                {
                    //光晕 来回缩放
                    currElement.RenderTransformOrigin = new Point(0.5, 0.5);

                    double halfSeconds = animation.durationSeconds / 2.0;
                    DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames();
                    if (animation.playTimes <= 0)
                    {
                        da.RepeatBehavior = RepeatBehavior.Forever;
                    }
                    else
                    {
                        da.RepeatBehavior = new RepeatBehavior(animation.playTimes);
                    }
                    ScaleTransform  scaleTransform = TransformGroupUtil.GetScaleTransform(group);
                    var             keyFrames      = da.KeyFrames;
                    IEasingFunction easingFunction = new CubicEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    };
                    keyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromMilliseconds(0)));
                    keyFrames.Add(new LinearDoubleKeyFrame(0.78, TimeSpan.FromMilliseconds(halfSeconds)));
                    keyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromMilliseconds(animation.durationSeconds)));
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                    scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Handles the Click event of the Button control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        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. 29
0
        public override EasingFunctionBase Create(DeterministicRandom random)
        {
            EasingFunctionBase easingFunction;
            EasingMode         easingMode;
            int    easingSwitch = random.Next(10);
            double amplitude1   = (double)random.NextDouble() * 10;
            double amplitude2   = (double)random.NextDouble() * 10;

            easingMode = random.NextEnum <EasingMode>();

            switch (easingSwitch)
            {
            case 0:
                easingFunction = new BackEase()
                {
                    EasingMode = easingMode, Amplitude = amplitude1
                };
                break;

            case 1:
                easingFunction = new BounceEase()
                {
                    EasingMode = easingMode, Bounces = (int)amplitude1, Bounciness = amplitude2
                };
                break;

            case 2:
                easingFunction = new CircleEase()
                {
                    EasingMode = easingMode
                };
                break;

            case 3:
                easingFunction = new CubicEase()
                {
                    EasingMode = easingMode
                };
                break;

            case 4:
                easingFunction = new ElasticEase()
                {
                    EasingMode = easingMode, Oscillations = (int)amplitude1, Springiness = amplitude2
                };
                break;

            case 5:
                easingFunction = new ExponentialEase()
                {
                    EasingMode = easingMode, Exponent = amplitude1
                };
                break;

            case 6:
                easingFunction = new PowerEase()
                {
                    EasingMode = easingMode, Power = amplitude1
                };
                break;

            case 7:
                easingFunction = new QuarticEase()
                {
                    EasingMode = easingMode
                };
                break;

            case 8:
                easingFunction = new SineEase()
                {
                    EasingMode = easingMode
                };
                break;

            default:
                return(null);
            }
            return(easingFunction);
        }
Esempio n. 30
0
        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();
        }