Exemple #1
0
        private void HelpDialogClose_Click(object sender, RoutedEventArgs e)
        {
            if (HelpDialogClose.IsEnabled == false)
            {
                return;
            }
            HelpDialogClose.IsEnabled = false;
            PowerEase pe = new PowerEase();

            pe.Power = 2.5;
            ThicknessAnimation dm = new ThicknessAnimation();

            dm.EasingFunction = pe;
            dm.From           = HelpDialog.Margin;
            dm.To             = new Thickness((this.Width - HelpDialog.Width) / 2, -500, Barcode.Margin.Right, Barcode.Margin.Bottom);
            dm.Duration       = AnimationDuration;
            ColorAnimation pc = new ColorAnimation();

            pc.EasingFunction = pe;
            Color blackFrom = Colors.Black;

            blackFrom.A           = 153;
            pc.From               = blackFrom;
            blackFrom.A           = 0;
            pc.To                 = blackFrom;
            pc.Duration           = AnimationDuration;
            HelpSplash.Visibility = Visibility.Visible;
            HelpDialog.BeginAnimation(Grid.MarginProperty, dm);
            HelpSplash.Background.BeginAnimation(SolidColorBrush.ColorProperty, pc);
            DelayCall(500, new Action(() => { InfoButton.IsEnabled = true; HelpSplash.Visibility = Visibility.Hidden; }));
        }
Exemple #2
0
        private void OnLoadedTrailer(object sender, TrailerLoadedEventArgs e)
        {
            if (!e.InError)
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    #region Fade in opacity

                    DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
                    opacityAnimation.Duration               = new Duration(TimeSpan.FromSeconds(0.5));
                    PowerEase opacityEasingFunction         = new PowerEase();
                    opacityEasingFunction.EasingMode        = EasingMode.EaseInOut;
                    EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(1.0, KeyTime.FromPercent(0));
                    EasingDoubleKeyFrame endOpacityEasing   = new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(1.0),
                                                                                       opacityEasingFunction);
                    opacityAnimation.KeyFrames.Add(startOpacityEasing);
                    opacityAnimation.KeyFrames.Add(endOpacityEasing);

                    MovieContainer.BeginAnimation(OpacityProperty, opacityAnimation);

                    #endregion
                });

                TrailerPlayer.Source = new Uri(e.TrailerUrl);
                TrailerPlayer.Play();
            }
        }
        public static void Move(FrameworkElement target, Thickness from, Thickness to, double durationMilliseconds, EasingMode easingMode, Action callBack)
        {
            EasingFunctionBase easeFunction = new PowerEase()
            {
                EasingMode = easingMode,
                Power      = EasingPower
            };
            ThicknessAnimation animation = new ThicknessAnimation()
            {
                From           = from,                                           //起始值
                To             = to,                                             //结束值
                EasingFunction = easeFunction,                                   //缓动函数
                Duration       = TimeSpan.FromMilliseconds(durationMilliseconds) //动画播放时间
            };

            if (callBack != null)
            {
                animation.Completed += (sender, e) =>
                {
                    callBack();
                };
            }

            AnimationClock clock = animation.CreateClock();

            target.ApplyAnimationClock(FrameworkElement.MarginProperty, clock);
        }
Exemple #4
0
        /// <summary>
        /// The user control_ loaded.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void UserControlLoaded(object sender, RoutedEventArgs e)
        {
            this.story.BeginTime = TimeSpan.FromSeconds(this.Delay);
            PowerEase ease = new PowerEase {
                Power = 0.3, EasingMode = EasingMode.EaseInOut
            };
            DoubleAnimation opacityAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.8)))
            {
                EasingFunction = ease,
                AutoReverse    = true
            };
            ThicknessAnimation dbxPos = new ThicknessAnimation(
                new Thickness(0, 0, 0, 0),
                new Thickness(this.ActualWidth, 0, 0, 0),
                new Duration(TimeSpan.FromSeconds(1.6)))
            {
                EasingFunction = ease, AutoReverse = true
            };

            this.story.Children.Add(opacityAnimation);
            this.story.Children.Add(dbxPos);
            Storyboard.SetTarget(opacityAnimation, this.Rect);
            Storyboard.SetTarget(dbxPos, this.Rect);
            Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(OpacityProperty));
            Storyboard.SetTargetProperty(dbxPos, new PropertyPath(MarginProperty));
        }
Exemple #5
0
 /// <summary>
 /// 滑条缓变动画
 /// </summary>
 /// <param name="sliname">指定控件</param>
 /// <param name="from">起始值</param>
 /// <param name="to">目标值</param>
 /// <param name="time">持续时间(ms)</param>
 public static void FloatSlider(Slider sliname, double from, double to, int time)
 {
     lock (sliname)
     {
         EasingFunctionBase easeFunction = new PowerEase()
         {
             EasingMode = EasingMode.EaseOut,
             Power      = 5
         };
         DoubleAnimation slianimation = new DoubleAnimation()
         {
             From           = from,
             To             = to,
             EasingFunction = easeFunction,                   //缓动函数
             Duration       = TimeSpan.FromMilliseconds(time) //动画播放时间
         };
         EventHandler handler = null;
         slianimation.Completed += handler = (s, e) =>
         {
             sliname.Value           = to;
             slianimation.Completed -= handler;
             slianimation            = null;
         };
         sliname.BeginAnimation(Slider.ValueProperty, slianimation);
     }
 }
        private void animate()
        {
            var ease = new PowerEase {
                EasingMode = EasingMode.EaseOut
            };
            DoubleAnimation myanimation;

            if (engage)
            {
                myanimation = new DoubleAnimation(0, angle, new Duration(TimeSpan.FromMilliseconds(speed)));
            }
            else
            {
                myanimation = new DoubleAnimation(angle, 0, new Duration(TimeSpan.FromMilliseconds(speed)));
            }

            myanimation.Completed += Myanimation_Completed;

            //Adding Power ease to the animation
            myanimation.EasingFunction = ease;

            RotateTransform rt = new RotateTransform();

            border.RenderTransform       = rt;
            border.RenderTransformOrigin = new Point(0.5, 0.5);
            rt.BeginAnimation(RotateTransform.AngleProperty, myanimation);
        }
Exemple #7
0
        /// <summary>
        /// Fade in opacity of the window, let the progress ring appear and collapse the NoMouvieFound label when loading movies
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">EventArgs</param>
        private void OnMoviesLoading(object sender, EventArgs e)
        {
            // We have to deal with the DispatcherHelper, otherwise we're having the classic cross-thread access exception
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                ProgressRing.IsActive = true;

                #region Fade in opacity
                DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
                opacityAnimation.Duration               = new Duration(TimeSpan.FromSeconds(0.5));
                PowerEase opacityEasingFunction         = new PowerEase();
                opacityEasingFunction.EasingMode        = EasingMode.EaseInOut;
                EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(1, KeyTime.FromPercent(0));
                EasingDoubleKeyFrame endOpacityEasing   = new EasingDoubleKeyFrame(0.2, KeyTime.FromPercent(1.0),
                                                                                   opacityEasingFunction);
                opacityAnimation.KeyFrames.Add(startOpacityEasing);
                opacityAnimation.KeyFrames.Add(endOpacityEasing);
                ItemsList.BeginAnimation(OpacityProperty, opacityAnimation);
                #endregion

                if (NoMouvieFound.Visibility == Visibility.Visible)
                {
                    NoMouvieFound.Visibility = Visibility.Collapsed;
                }
            });
        }
Exemple #8
0
        private void PlayShowingAnimation()
        {
            //Slide animation
            this.PlaySlideInAnim();

            //BG alpha animation
            IEasingFunction powerEasing = new PowerEase()
            {
                EasingMode = EasingMode.EaseOut
            };

            Color     startColor            = "#FFFFFF55".ToColor();
            Color     endColor              = "#FFFFFF00".ToColor();
            const int AlphaDurationMillisec = 400;

            for (int i = 0; i < itemViews.Length; ++i)
            {
                int reverseI = itemViews.Length - 1 - i;

                Duration       alphaDuration = new Duration(new TimeSpan(0, 0, 0, 0, AlphaDurationMillisec));
                ColorAnimation alhpaAnim     = new ColorAnimation()
                {
                    BeginTime      = new TimeSpan(0, 0, 0, 0, reverseI * 30),
                    From           = startColor,
                    To             = endColor,
                    Duration       = alphaDuration,
                    EasingFunction = powerEasing,
                };
                OrderTypeItemView itemView = itemViews[i];
                itemView.Background = new SolidColorBrush(startColor);
                itemView.Background.BeginAnimation(SolidColorBrush.ColorProperty, alhpaAnim);
            }
        }
Exemple #9
0
        public static void FadeIn(ImageBrush image)
        {
            var ease = new PowerEase();

            ease.EasingMode = EasingMode.EaseOut;
            ease.Power      = 2.0f;

            Storyboard sb = new Storyboard();

            DoubleAnimation xa = new DoubleAnimation();

            Storyboard.SetTargetProperty(xa, new PropertyPath(ImageBrush.OpacityProperty));
            int rand = new Random(100).Next();

            xa.Duration       = TimeSpan.FromSeconds(1);
            xa.BeginTime      = TimeSpan.FromMilliseconds(rand);
            xa.From           = 0;
            xa.To             = 0.2;
            xa.EasingFunction = ease;

            sb.Children.Add(xa);

            Storyboard.SetTarget(xa, image);
            sb.Begin();
        }
Exemple #10
0
        private void btnDesnaStrelica_Click(object sender, RoutedEventArgs e)
        {
            vrednost -= 750;
            brojac++;
            if (brojac == 3)
            {
                btnDesnaStrelica.Visibility = Visibility.Hidden;
            }
            else if (brojac == 0 || brojac == 1)
            {
                btnLevaStrelica.Visibility  = Visibility.Visible;
                btnDesnaStrelica.Visibility = Visibility.Visible;
            }

            DoubleAnimation doubleAnimation = new DoubleAnimation();
            PowerEase       powerEase       = new PowerEase();

            powerEase.EasingMode = EasingMode.EaseInOut;
            powerEase.Power      = 10;

            doubleAnimation.To       = vrednost;
            doubleAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 700));
            // doubleAnimation.EasingFunction = powerEase;

            Grid1.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
            Grid2.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
            Grid3.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
            Grid4.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
            Grid5.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
            Grid6.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
            Grid7.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
        }
Exemple #11
0
        /// <summary>
        /// Fade out opacity of the window, let the progress ring disappear and set to visible the NoMouvieFound label when movies are loaded
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">EventArgs</param>
        private void OnMoviesLoaded(object sender, NumberOfLoadedMoviesEventArgs e)
        {
            // We have to deal with the DispatcherHelper, otherwise we're having the classic cross-thread access exception
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                // We exclude exceptions like TaskCancelled when getting back results
                if ((e.NumberOfMovies == 0 && !e.IsExceptionThrown) || (e.NumberOfMovies != 0 && !e.IsExceptionThrown))
                {
                    ProgressRing.IsActive = false;

                    #region Fade out opacity
                    DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
                    opacityAnimation.Duration               = new Duration(TimeSpan.FromSeconds(0.5));
                    PowerEase opacityEasingFunction         = new PowerEase();
                    opacityEasingFunction.EasingMode        = EasingMode.EaseInOut;
                    EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(0.2, KeyTime.FromPercent(0));
                    EasingDoubleKeyFrame endOpacityEasing   = new EasingDoubleKeyFrame(1, KeyTime.FromPercent(1.0),
                                                                                       opacityEasingFunction);
                    opacityAnimation.KeyFrames.Add(startOpacityEasing);
                    opacityAnimation.KeyFrames.Add(endOpacityEasing);
                    ItemsList.BeginAnimation(OpacityProperty, opacityAnimation);
                    #endregion
                }

                var vm = DataContext as MoviesViewModel;
                if (vm != null)
                {
                    // If we searched movies and there's no result, display the NoMovieFound label (we exclude exceptions like TaskCancelled when getting back results)
                    if (!vm.Movies.Any() && e.NumberOfMovies == 0 && !e.IsExceptionThrown)
                    {
                        NoMouvieFound.Visibility = Visibility.Visible;
                    }
                }
            });
        }
        /// <summary> 缩小到右下角隐藏 </summary>
        public static void ScaleReduceWithAction(this WindowBase w, Point point, double second, double power, Action complate)
        {
            w.RenderTransformOrigin = point;

            EasingFunctionBase easeFunction = new PowerEase()
            {
                EasingMode = EasingMode.EaseInOut,
                Power      = power
            };

            {
                DoubleAnimation dbAscending = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(second)));
                dbAscending.EasingFunction = easeFunction;

                Storyboard storyboard = new Storyboard();
                //dbAscending.RepeatBehavior = RepeatBehavior.Forever;
                storyboard.Children.Add(dbAscending);
                Storyboard.SetTarget(dbAscending, w);
                Storyboard.SetTargetProperty(dbAscending, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
                storyboard.Begin();
            }

            {
                DoubleAnimation dbAscending1 = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(second)));
                dbAscending1.EasingFunction = easeFunction;

                Storyboard storyboard1 = new Storyboard();
                //dbAscending.RepeatBehavior = RepeatBehavior.Forever;
                storyboard1.Children.Add(dbAscending1);
                Storyboard.SetTarget(dbAscending1, w);
                Storyboard.SetTargetProperty(dbAscending1, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
                storyboard1.Completed += delegate { complate.Invoke(); };
                storyboard1.Begin();
            }
        }
Exemple #13
0
 static PowerEase checkEase(PowerEase easeFunction)
 {
     if (easeFunction == null)
     {
         easeFunction = defaultEaseFunction;
     }
     return(easeFunction);
 }
 /// <summary>
 ///     创建一个Thickness动画
 /// </summary>
 /// <param name="thickness"></param>
 /// <param name="milliseconds"></param>
 /// <returns></returns>
 public static ThicknessAnimation CreateAnimation(Thickness thickness = default, double milliseconds = 200)
 {
     return(new(thickness, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
     {
         EasingFunction = new PowerEase {
             EasingMode = EasingMode.EaseInOut
         }
     });
 public linearIndeterminate()
 {
     InitializeComponent();
     ProgressColor             = colorConverter.convertToColor("#3d87f0");
     BackgroundColor           = colorConverter.convertToColor("#c0d4e7");
     easingFunction            = new PowerEase();
     easingFunction.EasingMode = EasingMode.EaseInOut;
 }
Exemple #16
0
        /// <summary>
        ///		Obtiene una potencia
        /// </summary>
        private PowerEase GetPowerEase(PowerEaseModel powerEase)
        {
            PowerEase ease = new PowerEase();

            // Asigna las propiedades
            ease.EasingMode = ConvertEaseMode(powerEase.EaseMode);
            ease.Power      = powerEase.Power;
            // Devuelve la función
            return(ease);
        }
        private Storyboard TranslateBoard(Point target, UserControl circle)
        {
            Point current = new Point(Canvas.GetLeft(Board), Canvas.GetTop(Board));
            var   length  = (target - current).Length;

            Debug.WriteLine(length);
            TimeSpan duration = TimeSpan.FromSeconds(0.5);

            if (length > 1000)
            {
                duration = TimeSpan.FromSeconds(1);
            }

            PowerEase ease = new PowerEase();

            ease.Power      = 2;
            ease.EasingMode = EasingMode.EaseInOut;

            circleContainer.Children.Clear();
            Storyboard story = new Storyboard();

            story.FillBehavior = FillBehavior.Stop;

            DoubleAnimation x = new DoubleAnimation();

            x.EasingFunction = ease;
            x.Duration       = duration;
            x.To             = target.X;

            DoubleAnimation y = new DoubleAnimation();

            y.EasingFunction = ease;
            y.Duration       = duration;
            y.To             = target.Y;

            story.Children.Add(x);
            story.Children.Add(y);
            Storyboard.SetTarget(x, Board);
            Storyboard.SetTarget(y, Board);
            Storyboard.SetTargetProperty(x, new PropertyPath("(Canvas.Left)"));
            Storyboard.SetTargetProperty(y, new PropertyPath("(Canvas.Top)"));


            story.Completed += (s, ee) =>
            {
                Canvas.SetLeft(Board, target.X);
                Canvas.SetTop(Board, target.Y);
                if (circle != null)
                {
                    circleContainer.Children.Add(circle);
                }
            };

            return(story);
        }
Exemple #18
0
        private void StartTilt(Point position, UIElement container)
        {
            _tilting = false;

            if (_presenter != null && _planeProjection == null)
            {
                _planeProjection      = new PlaneProjection();
                _presenter.Projection = _planeProjection;

                _tiltUpStoryboard            = new Storyboard();
                _tiltUpStoryboard.Completed += new EventHandler <object>(TiltUpCompleted);

                PowerEase ease = new PowerEase();
                ease.Power = 2;

                Duration duration = TiltUpAnimationDuration;

                DoubleAnimation tiltUpRotateXAnimation = new DoubleAnimation();
                Storyboard.SetTarget(tiltUpRotateXAnimation, _planeProjection);
                Storyboard.SetTargetProperty(tiltUpRotateXAnimation, "RotationX");
                tiltUpRotateXAnimation.To             = 0;
                tiltUpRotateXAnimation.EasingFunction = ease;
                tiltUpRotateXAnimation.Duration       = duration;

                DoubleAnimation tiltUpRotateYAnimation = new DoubleAnimation();
                Storyboard.SetTarget(tiltUpRotateYAnimation, _planeProjection);
                Storyboard.SetTargetProperty(tiltUpRotateYAnimation, "RotationY");
                tiltUpRotateYAnimation.To = 0;

                tiltUpRotateYAnimation.EasingFunction = ease;
                tiltUpRotateYAnimation.Duration       = duration;

                DoubleAnimation tiltUpOffsetZAnimation = new DoubleAnimation();
                Storyboard.SetTarget(tiltUpOffsetZAnimation, _planeProjection);
                Storyboard.SetTargetProperty(tiltUpOffsetZAnimation, "GlobalOffsetZ");
                tiltUpOffsetZAnimation.To             = 0;
                tiltUpOffsetZAnimation.EasingFunction = ease;
                tiltUpOffsetZAnimation.Duration       = duration;

                _tiltUpStoryboard.Children.Add(tiltUpRotateXAnimation);
                _tiltUpStoryboard.Children.Add(tiltUpRotateYAnimation);
                _tiltUpStoryboard.Children.Add(tiltUpOffsetZAnimation);
            }
            if (_planeProjection != null)
            {
                _width  = ActualWidth;
                _height = ActualHeight;
                if (_tiltUpStoryboard != null)
                {
                    _tiltUpStoryboard.Stop();
                }
                DepressAndTilt(position, container);
            }
        }
Exemple #19
0
        private void refresh_Click(object sender, RoutedEventArgs e)
        {
            if (sender == refreshAttractions)
            {
                attractions.ItemsSource = null;
                if (admin.Attractions != null)
                {
                    attractions.ItemsSource = admin.Attractions;
                }

                var ease = new PowerEase {
                    EasingMode = EasingMode.EaseOut
                };

                //DoubleAnimation(FromValue. ToValue, Duration)
                DoubleAnimation myanimation = new DoubleAnimation
                                                  (0, 360, new Duration(TimeSpan.FromSeconds(0.8)));

                //Adding Power ease to the animation
                myanimation.EasingFunction = ease;

                RotateTransform rt = new RotateTransform();

                //  "img" is Image added in XAML
                refreshAttractions.RenderTransform       = rt;
                refreshAttractions.RenderTransformOrigin = new Point(0.5, 0.5);
                rt.BeginAnimation(RotateTransform.AngleProperty, myanimation);
            }
            else if (sender == refreshPersonnel)
            {
                personnel.ItemsSource = null;
                if (admin.ToutLePersonnel != null)
                {
                    personnel.ItemsSource = admin.ToutLePersonnel;
                }
                var ease = new PowerEase {
                    EasingMode = EasingMode.EaseOut
                };

                //DoubleAnimation(FromValue. ToValue, Duration)
                DoubleAnimation myanimation = new DoubleAnimation
                                                  (0, 360, new Duration(TimeSpan.FromSeconds(0.8)));

                //Adding Power ease to the animation
                myanimation.EasingFunction = ease;

                RotateTransform rt = new RotateTransform();

                //  "img" is Image added in XAML
                refreshPersonnel.RenderTransform       = rt;
                refreshPersonnel.RenderTransformOrigin = new Point(0.5, 0.5);
                rt.BeginAnimation(RotateTransform.AngleProperty, myanimation);
            }
        }
Exemple #20
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 #21
0
        public static DoubleAnimation Animate(double duration, double from, double to, int repeatCount, EventHandler updating = null, EventHandler Completed = null
                                              , PowerEase easeFunction = null, bool autoReverse = false)
        {
            var result = new DoubleAnimation
            {
                From           = new double?(double.IsNaN(from) ? 0.0 : from),
                To             = new double?(double.IsNaN(to) ? 0.0 : to),
                EasingFunction = checkEase(easeFunction)
            };

            return(Animate <DoubleAnimation>(result, duration, autoReverse, repeatCount, updating, Completed));
        }
Exemple #22
0
        /// <summary>
                /// 支撑同时旋转和缩放的动画
                /// </summary>
                /// <param name="element">控件</param>
                /// <param name="from">元素开始的大小</param>
                /// <param name="to">元素到达的大小</param>
                /// <param name="time">动画世界</param>
                /// <param name="completed">结束事件</param>
                public static void ScaleRotateEasingAnimationShow(UIElement element, double from, double to, double mseconds, double mlateSeconds, EventHandler completed)
        {
                        //旋转
                        RotateTransform angle = new RotateTransform();

                        //缩放
                        ScaleTransform scale = new ScaleTransform();
            TransformGroup             group = new TransformGroup();

            group.Children.Add(scale);
            group.Children.Add(angle);
            element.RenderTransform = group;

                        //定义圆心位置
                        element.RenderTransformOrigin = new Point(0.5, 0.5);
            EasingFunctionBase easeFunction           = new PowerEase()
            {
                EasingMode = EasingMode.EaseInOut,
                Power      = 2
            };

                        // 动画参数
                        DoubleAnimation scaleAnimation = new DoubleAnimation()
            {
                From           = from,
                To             = to,
                EasingFunction = easeFunction,
                Duration       = TimeSpan.FromMilliseconds(mseconds),
                BeginTime      = TimeSpan.FromMilliseconds(mlateSeconds),
                FillBehavior   = FillBehavior.Stop
            };

                        // 动画参数
                        DoubleAnimation angleAnimation = new DoubleAnimation()
            {
                From           = 0,
                To             = 360,
                EasingFunction = easeFunction,
                Duration       = TimeSpan.FromMilliseconds(mseconds),
                BeginTime      = TimeSpan.FromMilliseconds(mlateSeconds),
                FillBehavior   = FillBehavior.Stop,
            };

            //angleAnimation.Completed += completed;

            // 执行动画
            scale.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            scale.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            //angle.BeginAnimation(RotateTransform.AngleProperty, angleAnimation);
        }
        static public void falseColorAnimation(Button btn)
        {
            ColorAnimation buttonColorAnimation = new ColorAnimation();

            buttonColorAnimation.To           = Colors.Red;
            buttonColorAnimation.AutoReverse  = true;
            buttonColorAnimation.Duration     = TimeSpan.FromSeconds(0.2);
            buttonColorAnimation.FillBehavior = FillBehavior.Stop;
            PowerEase pe = new PowerEase();

            pe.EasingMode = EasingMode.EaseOut;
            buttonColorAnimation.EasingFunction = pe;
            btn.Background.BeginAnimation(SolidColorBrush.ColorProperty, buttonColorAnimation);
        }
Exemple #24
0
    public MainWindow()
    {
        InitializeComponent();
        var viewModel = new ViewModel();

        //handle the completed event to re-execute the storyboard
        this.storyboard            = this.Resources["Storyboard1"] as Storyboard;
        this.storyboard.Completed += Storyboard_Completed;

        //get the animation to locate our easing function defined in xaml.
        var animation = storyboard.Children[0] as ColorAnimationUsingKeyFrames;

        //find the second keyframe, thats the one that has easing function.
        this.easingFunction = (animation.KeyFrames[1] as EasingColorKeyFrame).EasingFunction as PowerEase;
    }
        static Timeline CreateTimeline()
        {
            DoubleAnimation timeline = new DoubleAnimation();

            timeline.From      = 0;
            timeline.To        = 1.0;
            timeline.Duration  = new Duration(TimeSpan.FromSeconds(2.0));
            timeline.BeginTime = TimeSpan.Zero;
            PowerEase easingFunction = new PowerEase();

            easingFunction.EasingMode = EasingMode.EaseInOut;
            easingFunction.Power      = 3.0;
            timeline.EasingFunction   = easingFunction;
            return(timeline);
        }
        public new void Close()
        {
            Closed?.Invoke(this, new EventArgs());
            DoubleAnimation d = new DoubleAnimation();

            d.To = 0;
            PowerEase pe = new PowerEase();

            pe.EasingMode    = EasingMode.EaseInOut;
            pe.Power         = 4;
            d.EasingFunction = pe;
            d.SpeedRatio     = SpeedRatio;
            d.Completed     += (s, e) => { base.Close(); };
            BeginAnimation(OpacityProperty, d);
        }
Exemple #27
0
        public void Switch(UIElement eIn, UIElement eOut, double duration)
        {
            // create storyboard
            var sb = new Storyboard();

            // make sure eIn is behind eOut
            if (eIn != null)
            {
                eIn.SetValue(Canvas.ZIndexProperty, 0);
                eIn.RenderTransform = null;
                eIn.Opacity         = 1;
            }

            // rotate eOut from zero to 90
            if (eOut != null)
            {
                eOut.SetValue(Canvas.ZIndexProperty, 1);

                var ease = new PowerEase();
                ease.EasingMode = EasingMode.EaseOut;
                ease.Power      = 3;

                var rt = new RotateTransform();
                eOut.RenderTransform = rt;
                var da = new DoubleAnimation();
                da.To             = 90;
                da.Duration       = TimeSpan.FromMilliseconds(duration);
                da.EasingFunction = ease;
                Storyboard.SetTargetProperty(da, new PropertyPath("Angle"));
                Storyboard.SetTarget(da, rt);
                sb.Children.Add(da);

                da                = new DoubleAnimation();
                da.From           = 1;
                da.To             = 0;
                da.BeginTime      = TimeSpan.FromMilliseconds(duration * .8);
                da.Duration       = TimeSpan.FromMilliseconds(duration * .2);
                da.EasingFunction = ease;
                Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));
                Storyboard.SetTarget(da, eOut);
                sb.Children.Add(da);
            }

            // do it
            sb.Begin();
        }
        private void DialogWindow_Loaded(object sender, RoutedEventArgs e)
        {
            DialogFrame.Navigate(Page);
            Window          window = sender as Window;
            DoubleAnimation d      = new DoubleAnimation();

            d.From = 0;
            d.To   = 1;
            PowerEase pe = new PowerEase();

            pe.EasingMode    = EasingMode.EaseInOut;
            pe.Power         = 4;
            d.SpeedRatio     = SpeedRatio;
            d.EasingFunction = pe;
            d.Completed     += (s, ee) => { Page.LoadCompleted(this, new EventArgs()); };
            window.BeginAnimation(OpacityProperty, d);
        }
Exemple #29
0
 /// <summary>
 /// 滑条缓变动画
 /// </summary>
 /// <param name="sliname">指定控件</param>
 /// <param name="to">目标值</param>
 /// <param name="time">持续时间(ms)</param>
 public static void FloatSlider(Slider sliname, double to, int time)
 {
     lock (sliname)
     {
         EasingFunctionBase easeFunction = new PowerEase()
         {
             EasingMode = EasingMode.EaseOut,
             Power      = 5
         };
         DoubleAnimation slianimation = new DoubleAnimation()
         {
             To             = to,
             EasingFunction = easeFunction,                   //缓动函数
             Duration       = TimeSpan.FromMilliseconds(time) //动画播放时间
         };
         sliname.BeginAnimation(Slider.ValueProperty, slianimation);
     }
 }
        public static void Linear(DependencyObject target, DependencyProperty property, LinearConfig <double> config)
        {
            Linear <double>(target, property, config, () =>
            {
                EasingFunctionBase easeFunction = new PowerEase()
                {
                    EasingMode = config.EasingMode,
                    Power      = EasingPower
                };

                DoubleAnimation animation = new DoubleAnimation();
                animation.From            = config.Start;
                animation.To             = config.End;
                animation.Duration       = new Duration(TimeSpan.FromMilliseconds(config.DurationMilliseconds));
                animation.EasingFunction = easeFunction;
                return(animation);
            });
        }