void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
        {
            double fromValue = (double)animatableElement.GetValue(dependencyProperty);

            DoubleAnimation animation = new DoubleAnimation();

            animation.From     = fromValue;
            animation.To       = toValue;
            animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);
            QuadraticEase ease = new QuadraticEase();

            ease.EasingMode          = EasingMode.EaseOut;
            animation.EasingFunction = ease;

            animation.Completed += (sender, e) =>
            {
                //
                // When the animation has completed bake final value of the animation
                // into the property.
                //
                animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty));
                CancelAnimation(animatableElement, dependencyProperty);

                if (completedEvent != null)
                {
                    completedEvent(sender, e);
                }
            };

            animation.Freeze();

            animatableElement.BeginAnimation(dependencyProperty, animation);
        }
Exemple #2
0
        public ROFLCopter(List <Grid> targetGrids)
        {
            _copter         = new Image();
            _copter.Stretch = Stretch.None;

            _targetGrids = targetGrids;

            var gif = new BitmapImage();

            gif.BeginInit();
            gif.UriSource = new Uri("..\\images\\roflcropped.gif", UriKind.Relative);
            gif.EndInit();

            ImageBehavior.SetAnimatedSource(_copter, gif);

            _translatePitch = new RotateTransform(10);
            _translateXY    = new TranslateTransform();

            var group = new TransformGroup();

            _copter.RenderTransform = group;
            _copter.Width           = 300;
            _copter.Height          = 300;

            group.Children.Add(_translatePitch);
            group.Children.Add(_translateXY);

            var easingY = new SineEase
            {
                EasingMode = EasingMode.EaseInOut
            };

            var easingPitch = new QuadraticEase
            {
                EasingMode = EasingMode.EaseOut
            };

            _animatePitch = new DoubleAnimation(0, 10, new Duration(new TimeSpan(0, 0, 5)))
            {
                EasingFunction = easingPitch,
                AutoReverse    = true
            };

            _animateY = new DoubleAnimation()
            {
                EasingFunction = easingY,
                AutoReverse    = true
            };

            _animateX            = new DoubleAnimation();
            _animateX.Completed += OnAnimationCompleted;

            _copter.Loaded += (s, a) =>
            {
                Play();
            };

            SetActiveGrid();
            _activeGrid.Children.Add(_copter);
        }
Exemple #3
0
        public static void RotateImage(UIElement cntrl, double ToAngle, double TimeSecond, double TimeMillisecond = 0)
        {
            QuadraticEase EP = new QuadraticEase();

            EP.EasingMode = EasingMode.EaseInOut;

            var CurrentRotation = new RotateTransform();

            CurrentRotation = (RotateTransform)cntrl.RenderTransform;

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

            Storyboard.SetTarget(DirRotation, cntrl);
            Storyboard.SetTargetProperty(DirRotation, new PropertyPath("(UIElement.RenderTransform).(RotateTransform.Angle)"));
            var ST = new Storyboard();

            ST.Children.Add(DirRotation);
            ST.Begin();
        }
Exemple #4
0
        public void Switch(UIElement eIn, UIElement eOut, double duration)
        {
            // create storyboard
            var sb = new Storyboard();

            // initialize parameters
            var ts = duration / 2;

            // rotate eOut from zero to 90
            if (eOut != null)
            {
                var da = CreateAnimation(eOut, _property, 0, 90, ts, 0);
                sb.Children.Add(da);

                var qe = new QuadraticEase();
                qe.EasingMode     = EasingMode.EaseIn;
                da.EasingFunction = qe;
            }

            // rotate eIn from 90 to zero
            if (eIn != null)
            {
                var da = CreateAnimation(eIn, _property, -90, 0, ts, eOut != null ? ts : 0);
                sb.Children.Add(da);

                var qe = new QuadraticEase();
                qe.EasingMode     = EasingMode.EaseOut;
                da.EasingFunction = qe;
            }

            // do it
            sb.Begin();
        }
Exemple #5
0
        public void AppliesEasingFunction()
        {
            const double defaultOrigin      = 0;
            const double defaultDestination = 100;
            var          defaultAnimation   = new FromToByDoubleAnimation();
            var          easingAnimation    = new FromToByDoubleAnimation();
            var          clock          = new ControllableAnimationClock();
            var          easingFunction = new QuadraticEase();

            easingAnimation.EasingFunction = easingFunction;

            for (double progress = 0d; progress <= 1d; progress += 0.01)
            {
                // Manually apply the easing function.
                double easedProgress = easingFunction.Ease(progress);
                clock.CurrentProgress = easedProgress;
                double expectedResult = defaultAnimation.GetCurrentValue(defaultOrigin, defaultDestination, clock);

                // Then test if the animation does it on its own.
                clock.CurrentProgress = progress;
                double easedResult = easingAnimation.GetCurrentValue(defaultOrigin, defaultDestination, clock);

                Assert.Equal(expectedResult, easedResult);
            }
        }
Exemple #6
0
        void CreateStoryboards()
        {
            trans = new TranslateTransform()
            {
                X = 0, Y = 0
            };
            RecoverDialog.RenderTransformOrigin = new Point(0, 0);
            RecoverDialog.RenderTransform       = trans;
            trans = RecoverDialog.RenderTransform as TranslateTransform;

            SbShowDialog = new Storyboard();
            DoubleAnimation showAnim = new DoubleAnimation();

            showAnim.Duration = TimeSpan.FromMilliseconds(400);
            showAnim.To       = -480;
            var easing = new QuadraticEase();

            easing.EasingMode       = EasingMode.EaseOut;
            showAnim.EasingFunction = easing;
            Storyboard.SetTarget(showAnim, RecoverDialog);
            Storyboard.SetTargetProperty(showAnim, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
            SbShowDialog.Children.Add(showAnim);
            SbShowDialog.Completed += new EventHandler(SbShowDialog_Completed);

            SbHideDialog = new Storyboard();
            DoubleAnimation hideAnim = new DoubleAnimation();

            hideAnim.Duration       = TimeSpan.FromMilliseconds(400);
            hideAnim.To             = 0;
            hideAnim.EasingFunction = easing;
            Storyboard.SetTarget(hideAnim, RecoverDialog);
            Storyboard.SetTargetProperty(hideAnim, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
            SbHideDialog.Children.Add(hideAnim);
        }
        private void ListButton_Click(object sender, RoutedEventArgs e)
        {
            DoubleAnimation da   = new DoubleAnimation();
            QuadraticEase   ease = new QuadraticEase();

            ease.EasingMode   = EasingMode.EaseInOut;
            da.EasingFunction = ease;

            if (!IsTrackListToggle)
            {
                da.To       = 337;
                da.Duration = TimeSpan.FromSeconds(0.30);
                TrackListBorder.BeginAnimation(Border.HeightProperty, da);
                ListButton.Background = new ImageBrush(new BitmapImage(new Uri("Icons/sort-up.png", UriKind.Relative)));
                IsTrackListToggle     = true;
            }

            else
            {
                da.To       = 0;
                da.Duration = TimeSpan.FromSeconds(0.30);
                TrackListBorder.BeginAnimation(Border.HeightProperty, da);
                ListButton.Background = new ImageBrush(new BitmapImage(new Uri("Icons/justify-align.png", UriKind.Relative)));
                IsTrackListToggle     = false;
            }
        }
Exemple #8
0
        private void ContentShowerNavigationFrame_Navigated(object sender, NavigatingCancelEventArgs e)
        {
            var ta = new ThicknessAnimation();

            ta.Duration = TimeSpan.FromSeconds(1);
            QuadraticEase EasingFunction = new QuadraticEase();

            EasingFunction.EasingMode = EasingMode.EaseOut;
            ta.EasingFunction         = EasingFunction;
            ta.DecelerationRatio      = 0.7;
            ta.To = new Thickness(0, 0, 0, 0);
            if (e.NavigationMode == NavigationMode.New)
            {
                ta.From = new Thickness(0, 200, 0, 0);
            }
            else if (e.NavigationMode == NavigationMode.Back)
            {
                ta.From = new Thickness(0, 0, 0, 200);
            }

            var ta2 = new DoubleAnimation();

            ta2.To   = 1;
            ta2.From = 0;
            QuadraticEase EasingFunction2 = new QuadraticEase();

            EasingFunction2.EasingMode = EasingMode.EaseOut;
            ta.EasingFunction          = EasingFunction2;
            //(e.Content as Page).BeginAnimation(MarginProperty, ta);
            ContentShowerNavigationFrame.BeginAnimation(MarginProperty, ta);
            ContentShowerNavigationFrame.BeginAnimation(OpacityProperty, ta2);
        }
        /// <summary>
        /// Initializes a new instance of the HybridOrientationChangesFrame class.
        /// </summary>
        public HybridOrientationChangesFrame()
        {
            // Set up animations
            Storyboard.SetTargetProperty(_beforeOpacityAnimation, new PropertyPath(UIElement.OpacityProperty));
            _storyboard.Children.Add(_beforeOpacityAnimation);
            Storyboard.SetTargetProperty(_afterOpacityAnimation, new PropertyPath(UIElement.OpacityProperty));
            _storyboard.Children.Add(_afterOpacityAnimation);
            Storyboard.SetTargetProperty(_beforeRotationAnimation, new PropertyPath(RotateTransform.AngleProperty));
            _storyboard.Children.Add(_beforeRotationAnimation);
            Storyboard.SetTargetProperty(_afterRotationAnimation, new PropertyPath(RotateTransform.AngleProperty));
            _storyboard.Children.Add(_afterRotationAnimation);
            _storyboard.Completed += new EventHandler(HandleStoryboardCompleted);

            // Initialize variables
            EasingFunction = new QuadraticEase(); // Initialized here to avoid a single shared instance

            // Add custom transform to end of existing group
            var transformGroup = RenderTransform as TransformGroup;

            if (null != transformGroup)
            {
                transformGroup.Children.Add(_afterRotateTransform);
            }

            // Hook events
            OrientationChanged += new EventHandler <OrientationChangedEventArgs>(HandleOrientationChanged);
        }
        private void HideFreshNews()
        {
            if (this._isAnimating || !this._isFreshNewsShowed || this._ucHeader.IsLoadingFreshNews)
            {
                return;
            }
            this._isAnimating = true;
            TranslateTransform target             = this._translateFreshNews;
            double             y                  = this._translateFreshNews.Y;
            double             to                 = this._minOffsetFreshNews;
            DependencyProperty dependencyProperty = TranslateTransform.YProperty;
            int           duration                = 250;
            int?          startTime               = new int?(0);
            QuadraticEase quadraticEase           = new QuadraticEase();
            int           num1 = 0;

            quadraticEase.EasingMode = (EasingMode)num1;
            Action completed = (Action)(() =>
            {
                this._isAnimating = false;
                this._isFreshNewsShowed = false;
            });
            int num2 = 0;

            target.Animate(y, to, (object)dependencyProperty, duration, startTime, (IEasingFunction)quadraticEase, completed, num2 != 0);
        }
        private void Hide(bool hideFreshNews = false)
        {
            this.UpdateSystemTrayAndAppBarIfNeeded();
            this._isAnimating = true;
            IEasingFunction      ieasingFunction = new QuadraticEase();
            object               yproperty       = TranslateTransform.YProperty;
            List <AnimationInfo> animInfoList    = new List <AnimationInfo>()
            {
                new AnimationInfo()
                {
                    target = (DependencyObject)this._translateHeader, propertyPath = yproperty, from = this._translateHeader.Y, to = this._minOffsetHeader, easing = ieasingFunction, duration = 150
                }
            };

            if (hideFreshNews && this._isFreshNewsShowed)
            {
                animInfoList.Add(new AnimationInfo()
                {
                    target       = this._translateFreshNews,
                    propertyPath = yproperty,
                    from         = this._translateFreshNews.Y,
                    to           = this._minOffsetFreshNews,
                    easing       = ieasingFunction,
                    duration     = 150
                });
            }
            AnimationUtil.AnimateSeveral(animInfoList, new int?(0), (Action)(() =>
            {
                this.UpdateExtraCrop();
                this.UpdateSystemTrayAndAppBarIfNeeded();
                this._isAnimating = false;
            }));
        }
Exemple #12
0
        static PageBase()
        {
            QuadraticEase quadraticEase = new QuadraticEase();
            int           num           = 0;

            ((EasingFunctionBase)quadraticEase).EasingMode = ((EasingMode)num);
            PageBase._menuEasing = (IEasingFunction)quadraticEase;
        }
Exemple #13
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);
        }
        public static void GroupViewClose(this LongListSelector list, GroupViewClosingEventArgs e)
        {
            //Cancelling automatic closing and scrolling to do it manually.
            e.Cancel = true;
            if (e.SelectedGroup != null)
            {
                list.ScrollToGroup(e.SelectedGroup);
            }

            //Dispatch the swivel animation for performance on the UI thread.
            Application.Current.RootVisual.Dispatcher.BeginInvoke(() =>
            {
                //Construct and begin a swivel animation to pop out the group view.
                IEasingFunction quadraticEase = new QuadraticEase {
                    EasingMode = EasingMode.EaseOut
                };
                Storyboard _swivelHide  = new Storyboard();
                ItemsControl groupItems = e.ItemsControl;

                foreach (var item in groupItems.Items)
                {
                    UIElement container = groupItems.ItemContainerGenerator.ContainerFromItem(item) as UIElement;
                    if (container != null)
                    {
                        Border content = VisualTreeHelper.GetChild(container, 0) as Border;
                        if (content != null)
                        {
                            DoubleAnimationUsingKeyFrames showAnimation = new DoubleAnimationUsingKeyFrames();

                            EasingDoubleKeyFrame showKeyFrame1 = new EasingDoubleKeyFrame();
                            showKeyFrame1.KeyTime        = TimeSpan.FromMilliseconds(0);
                            showKeyFrame1.Value          = 0;
                            showKeyFrame1.EasingFunction = quadraticEase;

                            EasingDoubleKeyFrame showKeyFrame2 = new EasingDoubleKeyFrame();
                            showKeyFrame2.KeyTime        = TimeSpan.FromMilliseconds(125);
                            showKeyFrame2.Value          = 90;
                            showKeyFrame2.EasingFunction = quadraticEase;

                            showAnimation.KeyFrames.Add(showKeyFrame1);
                            showAnimation.KeyFrames.Add(showKeyFrame2);

                            Storyboard.SetTargetProperty(showAnimation, new PropertyPath(PlaneProjection.RotationXProperty));
                            Storyboard.SetTarget(showAnimation, content.Projection);

                            _swivelHide.Children.Add(showAnimation);
                        }
                    }
                }

                _swivelHide.Completed += delegate
                {
                    list.CloseGroupView();
                };
                _swivelHide.Begin();
            });
        }
Exemple #15
0
        private void SetAnimation()
        {
            QuadraticEase easing = new QuadraticEase();

            easing.EasingMode                = EasingMode.EaseInOut;
            myDoubleAnimation.Duration       = new Duration(TimeSpan.FromSeconds(2));
            myDoubleAnimation.EasingFunction = easing;
            myDoubleAnimation.Completed     += new EventHandler(Picture_Faded);
        }
Exemple #16
0
        /// <summary>
        ///		Obtiene una función cuadrática
        /// </summary>
        private QuadraticEase GetQuadraticEase(QuadraticEaseModel quadraticEase)
        {
            QuadraticEase ease = new QuadraticEase();

            // Asigna las propiedades
            ease.EasingMode = ConvertEaseMode(quadraticEase.EaseMode);
            // Devuelve la función
            return(ease);
        }
Exemple #17
0
 public void ShouldThrowWhenModeIsInvalid()
 {
     var easingFunction = new QuadraticEase();
       Assert.That(
     () =>
     {
       easingFunction.Mode = (EasingMode)99;
       easingFunction.Ease(0.0f);
     }, Throws.TypeOf<InvalidAnimationException>());
 }
        public void ShouldThrowWhenModeIsInvalid()
        {
            var easingFunction = new QuadraticEase();

            Assert.That(
                () =>
            {
                easingFunction.Mode = (EasingMode)99;
                easingFunction.Ease(0.0f);
            }, Throws.TypeOf <InvalidAnimationException>());
        }
Exemple #19
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);
        }
        public BackgroundAnimation() : base()
        {
            To             = Colors.White;
            Duration       = (Duration)(System.Windows.Application.Current.TryFindResource("Short") ?? new Duration(TimeSpan.FromSeconds(.1)));
            EasingFunction = new QuadraticEase()
            {
                EasingMode = EasingMode.EaseInOut
            };

            SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(Background).(SolidColorBrush.Color)"));
        }
        private void conversionsLongListSelector_GroupViewOpened(object sender, GroupViewOpenedEventArgs e)
        {
            //Hold a reference to the active long list selector.
            currentSelector = sender as LongListSelector;



            //Dispatch the swivel animation for performance on the UI thread.
            Dispatcher.BeginInvoke(() =>
            {
                //Construct and begin a swivel animation to pop in the group view.
                IEasingFunction quadraticEase = new QuadraticEase {
                    EasingMode = EasingMode.EaseOut
                };
                Storyboard _swivelShow = new Storyboard();
                _swivelShow.SetValue(NameProperty, "_swivelShowStoryboard");
                ItemsControl groupItems = e.ItemsControl;

                foreach (var item in groupItems.Items)
                {
                    UIElement container = groupItems.ItemContainerGenerator.ContainerFromItem(item) as UIElement;
                    if (container != null)
                    {
                        Border content = VisualTreeHelper.GetChild(container, 0) as Border;
                        if (content != null)
                        {
                            DoubleAnimationUsingKeyFrames showAnimation = new DoubleAnimationUsingKeyFrames();

                            EasingDoubleKeyFrame showKeyFrame1 = new EasingDoubleKeyFrame();
                            showKeyFrame1.KeyTime        = TimeSpan.FromMilliseconds(0);
                            showKeyFrame1.Value          = -60;
                            showKeyFrame1.EasingFunction = quadraticEase;

                            EasingDoubleKeyFrame showKeyFrame2 = new EasingDoubleKeyFrame();
                            showKeyFrame2.KeyTime        = TimeSpan.FromMilliseconds(85);
                            showKeyFrame2.Value          = 0;
                            showKeyFrame2.EasingFunction = quadraticEase;

                            showAnimation.KeyFrames.Add(showKeyFrame1);
                            showAnimation.KeyFrames.Add(showKeyFrame2);

                            Storyboard.SetTargetProperty(showAnimation, new PropertyPath(PlaneProjection.RotationXProperty));
                            Storyboard.SetTarget(showAnimation, content.Projection);

                            _swivelShow.Children.Add(showAnimation);
                        }
                    }
                }

                _swivelShow.Begin();
            });
        }
Exemple #22
0
        public void AnimateCameraTarget(Vector3 newTarget)
        {
            if (cameraTargetStoryboard != null)
            {
                cameraTargetStoryboard.Stop();
            }

            // Create the storyboard and set us as the target
            cameraTargetStoryboard = new Storyboard();
            Storyboard.SetTarget(cameraTargetStoryboard, this);
            cameraTargetStoryboard.Completed += (s, e) => cameraTargetStoryboard = null;

            // Create the easing function we'll apply to the animations
            IEasingFunction easingFunction = new QuadraticEase {
                EasingMode = EasingMode.EaseInOut
            };

            // Create animations for each of the axis
            DoubleAnimation xAnimation = new DoubleAnimation
            {
                From           = CameraTargetX,
                To             = newTarget.X,
                Duration       = cameraAnimationDuration,
                EasingFunction = easingFunction
            };
            DoubleAnimation yAnimation = new DoubleAnimation
            {
                From           = CameraTargetY,
                To             = newTarget.Y,
                Duration       = cameraAnimationDuration,
                EasingFunction = easingFunction
            };
            DoubleAnimation zAnimation = new DoubleAnimation
            {
                From           = CameraTargetZ,
                To             = newTarget.Z,
                Duration       = cameraAnimationDuration,
                EasingFunction = easingFunction
            };

            // Set the target properties of the animations
            Storyboard.SetTargetProperty(xAnimation, new PropertyPath(CameraTargetXProperty));
            Storyboard.SetTargetProperty(yAnimation, new PropertyPath(CameraTargetYProperty));
            Storyboard.SetTargetProperty(zAnimation, new PropertyPath(CameraTargetZProperty));

            // Add the animations to the storyboard
            cameraTargetStoryboard.Children.Add(xAnimation);
            cameraTargetStoryboard.Children.Add(yAnimation);
            cameraTargetStoryboard.Children.Add(zAnimation);

            cameraTargetStoryboard.Begin();
        }
Exemple #23
0
        /// <summary>
        /// Initializes a new instance of the FadeOrientationChangesFrame class.
        /// </summary>
        public FadeOrientationChangesFrame()
        {
            // Set up animation
            Storyboard.SetTargetProperty(_animation, new PropertyPath(UIElement.OpacityProperty));
            _storyboard.Children.Add(_animation);
            _storyboard.Completed += new EventHandler(HandleStoryboardCompleted);

            // Initialize variables
            EasingFunction = new QuadraticEase(); // Initialized here to avoid a single shared instance

            // Hook events
            OrientationChanged += new EventHandler <OrientationChangedEventArgs>(HandleOrientationChanged);
        }
Exemple #24
0
 public void InitializeComponent()
 {
     if (this._contentLoaded)
     {
         return;
     }
     this._contentLoaded = true;
     Application.LoadComponent(this, new Uri("/VKClient.Common;component/UC/ToggleControl.xaml", UriKind.Relative));
     this.EasingFunc          = (QuadraticEase)base.FindName("EasingFunc");
     this.AnimateChecked      = (Storyboard)base.FindName("AnimateChecked");
     this.AnimateUnchecked    = (Storyboard)base.FindName("AnimateUnchecked");
     this.textBlockTitle      = (TextBlock)base.FindName("textBlockTitle");
     this.controlToggleSwitch = (VKClient.Common.UC.w10m.ToggleSwitch) /*(ToggleSwitchControl)*/ base.FindName("controlToggleSwitch");
 }
        private void ApplyContinuumElementAnimation()
        {
            this.continuumElementAnimation = new RadMoveAndFadeAnimation();
            FrameworkElement rootVisual = Window.Current.Content as FrameworkElement;

            QuadraticEase easing = new QuadraticEase();

            if (this.InOutAnimationMode == InOutAnimationMode.Out)
            {
                double durationInMs = 200;
                double keyTime      = 0.2 * durationInMs;
                easing.EasingMode = EasingMode.EaseIn;
                this.continuumElementAnimation.MoveAnimation.StartPoint = new Point(0, 0);
                DoubleKeyFrameCollection middlePointsY = new DoubleKeyFrameCollection();
                middlePointsY.Add(new EasingDoubleKeyFrame()
                {
                    KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(keyTime)), Value = 20
                });
                this.continuumElementAnimation.MoveAnimation.MiddlePointsYAxis = middlePointsY;

                DoubleKeyFrameCollection middlePointsX = new DoubleKeyFrameCollection();
                middlePointsX.Add(new EasingDoubleKeyFrame()
                {
                    KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(keyTime)), Value = 10
                });
                this.continuumElementAnimation.MoveAnimation.MiddlePointsXAxis = middlePointsX;

                this.continuumElementAnimation.MoveAnimation.EndPoint     = new Point(rootVisual.ActualWidth, this.continuumElement.ActualHeight);
                this.continuumElementAnimation.FadeAnimation.StartOpacity = 1;
                this.continuumElementAnimation.FadeAnimation.EndOpacity   = 0;

                this.continuumElementAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(durationInMs));
            }
            else
            {
                this.continuumElementAnimation.MoveAnimation.StartPoint   = new Point((-1 * this.continuumElement.ActualWidth) - this.continuumElementScreenShotInfo.OriginalLocation.X, -2 * this.continuumElement.ActualHeight);
                this.continuumElementAnimation.MoveAnimation.EndPoint     = new Point(0, 0);
                this.continuumElementAnimation.FadeAnimation.StartOpacity = 0;
                this.continuumElementAnimation.FadeAnimation.EndOpacity   = 1;
                this.continuumElementAnimation.Duration = TimeSpan.FromMilliseconds(200);
                easing.EasingMode = EasingMode.EaseOut;
            }

            this.continuumElementAnimation.Easing = easing;

            this.continuumElementAnimation.Ended += this.ContinuumElementAnimation_Ended;
        }
Exemple #26
0
        void HighlightAnimation()
        {
            // Max out the scaling at 1.2, also allow for 6px padding
            double scaleFactor = Math.Min(Math.Abs(this.SliderContainerWidth / (this.sizeContainer.ActualWidth - 12)), 1.2);

            this.HighlightStoryBoard.Stop();

            //Dispatcher.BeginInvoke(() =>
            //{
            this.HighlightStoryBoard.Children.Clear();
            IEasingFunction easing = new QuadraticEase()
            {
                EasingMode = EasingMode.EaseOut
            };

            // Animate the highlight
            DoubleAnimation mainScaleAnimX = new DoubleAnimation()
            {
                From           = 1.0,
                To             = scaleFactor,
                Duration       = TimeSpan.FromMilliseconds(500),
                EasingFunction = easing,
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever,
            };

            Storyboard.SetTarget(mainScaleAnimX, this.sizeContainer.RenderTransform);
            Storyboard.SetTargetProperty(mainScaleAnimX, new PropertyPath(CompositeTransform.ScaleXProperty));
            this.HighlightStoryBoard.Children.Add(mainScaleAnimX);
            DoubleAnimation mainScaleAnimY = new DoubleAnimation()
            {
                From           = 1.0,
                To             = scaleFactor,
                Duration       = TimeSpan.FromMilliseconds(500),
                EasingFunction = easing,
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever,
            };

            Storyboard.SetTarget(mainScaleAnimY, this.sizeContainer.RenderTransform);
            Storyboard.SetTargetProperty(mainScaleAnimY, new PropertyPath(CompositeTransform.ScaleYProperty));
            this.HighlightStoryBoard.Children.Add(mainScaleAnimY);

            this.HighlightStoryBoard.Begin();
            //});
        }
        public static MyStoryboard showDecksManerger(Grid gd, double star, double end, double time)
        {
            MyStoryboard       msb    = new MyStoryboard();
            DoubleAnimation    da     = new DoubleAnimation(star, end, TimeSpan.FromMilliseconds(time));
            EasingFunctionBase easing = new QuadraticEase()
            {
                EasingMode = EasingMode.EaseOut,       //公式
                //Oscillations =1,                           //滑过动画目标的次数
                //Springiness = 2                             //弹簧刚度
            };

            da.EasingFunction = easing;
            msb.Children.Add(da);
            Storyboard.SetTarget(da, gd);
            Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));

            return(msb);
        }
Exemple #28
0
        /// <summary>
        /// Use this method to make an animation for a window in X axis
        /// </summary>
        /// <param name="cntrl">The targhetting window</param>
        /// <param name="FromXPos">The position before the final position</param>
        /// <param name="XPos">The final position</param>
        /// <param name="TimeSecond">The duration on the animation</param>
        /// <param name="TimeMillisecond">The delay of the animation</param>
        public static void MoveWindowToTargetX(Control cntrl, double FromXPos, double XPos, double TimeSecond, double TimeMillisecond = 0)
        {
            QuadraticEase EP = new QuadraticEase();

            EP.EasingMode = EasingMode.EaseInOut;

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

            cntrl.BeginAnimation(Window.TopProperty, DirX);
        }
Exemple #29
0
        private void EventSetter_OnHandler(object sender, RoutedEventArgs e)
        {
            var t = sender as FrameworkElement;

            t.Opacity         = 0;
            t.RenderTransform = new TranslateTransform(-20, 0);
            var ease      = new QuadraticEase();
            var slideAnim = new DoubleAnimation(-20, 0, TimeSpan.FromMilliseconds(750))
            {
                EasingFunction = ease
            };
            var fadeAnim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(750))
            {
                EasingFunction = ease
            };

            t.BeginAnimation(OpacityProperty, fadeAnim);
            t.RenderTransform.BeginAnimation(TranslateTransform.XProperty, slideAnim);
        }
Exemple #30
0
        public void AnimateBackground(double widthDiff, Image backgroundImage)
        {
            if (widthDiff > 0 || widthDiff > -10)
            {
                return;
            }

            // Clear out any existing keyframes
            StopAndClearAnimation();

            backgroundImage.RenderTransform = new CompositeTransform();

            var easing = new QuadraticEase {
                EasingMode = EasingMode.EaseInOut
            };

            // create the timeline
            var animation = new DoubleAnimationUsingKeyFrames();

            animation.KeyFrames.Add(new EasingDoubleKeyFrame {
                KeyTime = TimeSpan.Zero, Value = 0.0, EasingFunction = easing
            });
            animation.KeyFrames.Add(new EasingDoubleKeyFrame {
                KeyTime = TimeSpan.FromMilliseconds(40000), Value = widthDiff, EasingFunction = easing
            });
            animation.AutoReverse = true;

            // notice the first parameter takes a timeline object not the storyboard itself
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
            Storyboard.SetTarget(animation, backgroundImage);

            _storyboard.RepeatBehavior = RepeatBehavior.Forever;

            // Have to do a stop() here otherwise adding children chucks an exception
            _storyboard.Stop();
            _storyboard.Children.Add(animation);

            // start the animation
            if (new AppSettings().AnimatePhotosSetting)
            {
                _storyboard.Begin();
            }
        }
Exemple #31
0
        public static void MoveToTargetXwoMargin(UIElement cntrl, double XPos, double FromXPos = 0, double TimeSecond = 0, double TimeMillisecond = 0)
        {
            QuadraticEase EP = new QuadraticEase();

            EP.EasingMode = EasingMode.EaseOut;

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

            cntrl.RenderTransform = new TranslateTransform();
            cntrl.RenderTransform.BeginAnimation(TranslateTransform.XProperty, DirX);
        }
 public RotateAnimation()
 {
     Duration = 1.0;
     StartRotation = 0.0;
     Easing = new QuadraticEase();
 }