Esempio n. 1
0
 protected override float GetCurrentValueCore(float defaultOriginValue, float defaultDestinationValue,
                                              AnimationClock animationClock)
 {
     throw new NotImplementedException();
 }
Esempio n. 2
0
        protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock)
        {
            double s    = From;
            double f    = To;
            double dist = f - s;

            if (dist == 0)
            {
                parent.velocity = 0;
                return(s);
            }
            double v = velocity / dist;
            double x = (double)animationClock.CurrentProgress / 2 + 0.5;

            double ease = easeFunc(x, v) - easeFunc(0, v);
            //ease = (ease - 0.5) * 2;
            double vel = easeVelFunc(x, v);

            parent.velocity = vel * dist;
            ease            = (ease - 0.5) * 2;
            return(ease * dist + s);
        }
Esempio n. 3
0
        protected override Point GetCurrentValueCore(Point defaultOriginValue, Point defaultDestinationValue, AnimationClock animationClock)
        {
            Nullable <Point> to   = this.To;
            Nullable <Point> from = this.From;

            if (!from.HasValue)
            {
                from = defaultOriginValue;
            }

            if (!to.HasValue)
            {
                to = defaultDestinationValue;
            }

            Point toValue   = to.GetValueOrDefault();
            Point fromValue = from.GetValueOrDefault();

            if ((!animationClock.CurrentProgress.HasValue) ||
                (animationClock.CurrentProgress.Value == 1))
            {
                return(toValue);
            }

            if (animationClock.CurrentProgress.Value == 0)
            {
                return(fromValue);
            }

            double totalTime   = animationClock.Timeline.Duration.TimeSpan.TotalMilliseconds;
            double elapsedTime = totalTime * animationClock.CurrentProgress.Value;

            if (elapsedTime >= totalTime)
            {
                return(toValue);
            }

            Point animationStep = this.GetAnimationStep(fromValue, toValue, elapsedTime, totalTime);

            if (DoubleUtil.AreClose(animationStep.X, toValue.X) && DoubleUtil.AreClose(animationStep.Y, toValue.Y))
            {
                return(toValue);
            }

            return(animationStep);
        }
 public sealed override object GetCurrentValue(object defaultOriginValue,
                                               object defaultDestinationValue, AnimationClock animationClock)
 {
     if (defaultOriginValue == null)
     {
         throw new ArgumentNullException("defaultOriginValue");
     }
     if (defaultDestinationValue == null)
     {
         throw new ArgumentNullException("defaultDestinationValue");
     }
     return(this.GetCurrentValue((LinearGradientBrush)defaultOriginValue,
                                 (LinearGradientBrush)defaultDestinationValue, animationClock));
 }
Esempio n. 5
0
        /// <summary>
        /// Animates the double value
        /// </summary>
        /// <param name="defaultOriginValue">The original value to animate</param>
        /// <param name="defaultDestinationValue">The final value</param>
        /// <param name="animationClock">The animation clock (timer)</param>
        /// <returns>Returns the new double to set</returns>
        protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock)
        {
            double fromVal = this.From.Value;
            double toVal   = this.To.Value;

            if (defaultOriginValue == toVal)
            {
                fromVal = toVal;
                toVal   = this.ReverseValue.Value;
            }

            if (fromVal > toVal)
            {
                return((1 - animationClock.CurrentProgress.Value) *
                       (fromVal - toVal) + toVal);
            }
            else
            {
                return(animationClock.CurrentProgress.Value *
                       (toVal - fromVal) + fromVal);
            }
        }
Esempio n. 6
0
 protected abstract CornerRadius GetCurrentValueCore(CornerRadius defaultOriginValue, CornerRadius defaultDestinationValue, AnimationClock animationClock);
        protected LinearGradientBrush GetCurrentValueCore(LinearGradientBrush defaultOriginValue, LinearGradientBrush defaultDestinationValue, AnimationClock animationClock)
        {
            if (!this._isAnimationFunctionValid)
            {
                this.ValidateAnimationFunction();
            }
            double          num            = animationClock.CurrentProgress.Value;
            IEasingFunction easingFunction = this.EasingFunction;

            if (easingFunction != null)
            {
                num = easingFunction.Ease(num);
            }
            LinearGradientBrush brush  = null;
            LinearGradientBrush brush2 = null;
            LinearGradientBrush value  = null;
            LinearGradientBrush value2 = null;

            switch (this._animationType)
            {
            case AnimationType.Automatic:
                brush  = defaultOriginValue;
                brush2 = defaultDestinationValue;
                value  = GetDefaultLinearGradientBrush(brush);
                value2 = GetDefaultLinearGradientBrush(brush);
                break;

            case AnimationType.From:
                brush  = this._keyValues[0];
                brush2 = defaultDestinationValue;
                value  = GetDefaultLinearGradientBrush(brush);
                value2 = GetDefaultLinearGradientBrush(brush);
                break;

            case AnimationType.To:
                brush  = defaultOriginValue;
                brush2 = this._keyValues[0];
                value  = GetDefaultLinearGradientBrush(brush2);
                value2 = GetDefaultLinearGradientBrush(brush2);
                break;

            case AnimationType.By:
                brush2 = this._keyValues[0];
                value2 = defaultOriginValue;
                value  = GetDefaultLinearGradientBrush(brush2);
                value2 = GetDefaultLinearGradientBrush(brush2);
                break;

            case AnimationType.FromTo:
                brush  = this._keyValues[0];
                brush2 = this._keyValues[1];
                value  = GetDefaultLinearGradientBrush(brush);
                value2 = GetDefaultLinearGradientBrush(brush);
                if (this.IsAdditive)
                {
                    value2 = defaultOriginValue;
                }
                break;

            case AnimationType.FromBy:
                brush  = this._keyValues[0];
                brush2 = AddLinearGradientBrush(this._keyValues[0], this._keyValues[1]);
                value  = GetDefaultLinearGradientBrush(brush);
                value2 = GetDefaultLinearGradientBrush(brush);
                if (this.IsAdditive)
                {
                    value2 = defaultOriginValue;
                }
                break;
            }

            if (this.IsCumulative)
            {
                double num2 = (double)(animationClock.CurrentIteration - 1).Value;
                if (num2 > 0.0)
                {
                    LinearGradientBrush value3 = SubtractLinearGradientBrush(brush2, brush);
                    value = ScaleLinearGradientBrush(value3, num2);
                }
            }
            LinearGradientBrush returnBrush = AddLinearGradientBrush(value2, AddLinearGradientBrush(value, InterpolateGradientBrush(brush, brush2, num)));

            return(returnBrush);
        }
 protected abstract double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue,
                                               AnimationClock animationClock);
Esempio n. 9
0
 /// <summary>
 ///     DrawLine -
 ///     Draws a line with the specified pen.
 ///     Note that this API does not accept a Brush, as there is no area to fill.
 /// </summary>
 /// <param name="pen"> The Pen with which to stroke the line. </param>
 /// <param name="point0"> The start Point for the line. </param>
 /// <param name="point0Animations"> Optional AnimationClock for point0. </param>
 /// <param name="point1"> The end Point for the line. </param>
 /// <param name="point1Animations"> Optional AnimationClock for point1. </param>
 public abstract void DrawLine(
     Pen pen,
     Point point0,
     AnimationClock point0Animations,
     Point point1,
     AnimationClock point1Animations);
Esempio n. 10
0
        /// <summary>
        /// This method is called by WPF to implement the actual animation, so this method calculates
        /// the exponential value based on how long we've been running so far.
        /// </summary>
        /// <param name="defaultOriginValue"></param>
        /// <param name="defaultDestinationValue"></param>
        /// <param name="clock"></param>
        /// <returns></returns>
        protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock)
        {
            double returnValue;
            double start        = (double)From;
            double delta        = (double)To - start;
            double timeFraction = animationClock.CurrentProgress.Value;

            if (timeFraction == 1)
            {
                return((double)this.To);
            }
            switch (this.EdgeBehavior)
            {
            case EdgeBehavior.EaseIn:
                returnValue = EaseIn(timeFraction, start, delta, Power);
                break;

            case EdgeBehavior.EaseOut:
                returnValue = EaseOut(timeFraction, start, delta, Power);
                break;

            case EdgeBehavior.EaseInOut:
            default:
                returnValue = EaseInOut(timeFraction, start, delta, Power);
                break;
            }
            return(returnValue);
        }
Esempio n. 11
0
 /// <summary>
 ///     PushOpacity -
 ///     Push an opacity which will blend the composite of all drawing primitives added
 ///     until the corresponding Pop call.
 /// </summary>
 /// <param name="opacity">
 ///     The opacity with which to blend - 0 is transparent, 1 is opaque.
 /// </param>
 /// <param name="opacityAnimations"> Optional AnimationClock for opacity. </param>
 public abstract void PushOpacity(
     Double opacity,
     AnimationClock opacityAnimations);
Esempio n. 12
0
 /// <summary>
 ///     DrawVideo -
 ///     Draw a Video into the region specified by the Rect.
 ///     The Video will potentially be stretched and distorted to fit the Rect.
 ///     For more fine grained control, consider filling a Rect with an VideoBrush via
 ///     DrawRectangle.
 /// </summary>
 /// <param name="player"> The MediaPlayer to draw. </param>
 /// <param name="rectangle"> The Rect into which the media will be fit. </param>
 /// <param name="rectangleAnimations"> Optional AnimationClock for rectangle. </param>
 public abstract void DrawVideo(
     MediaPlayer player,
     Rect rectangle,
     AnimationClock rectangleAnimations);
Esempio n. 13
0
 /// <summary>
 ///     DrawImage -
 ///     Draw an Image into the region specified by the Rect.
 ///     The Image will potentially be stretched and distorted to fit the Rect.
 ///     For more fine grained control, consider filling a Rect with an ImageBrush via
 ///     DrawRectangle.
 /// </summary>
 /// <param name="imageSource"> The ImageSource to draw. </param>
 /// <param name="rectangle">
 ///     The Rect into which the ImageSource will be fit.
 /// </param>
 /// <param name="rectangleAnimations"> Optional AnimationClock for rectangle. </param>
 public abstract void DrawImage(
     ImageSource imageSource,
     Rect rectangle,
     AnimationClock rectangleAnimations);
Esempio n. 14
0
        public override Point?UpdatePosition(VEMap map)
        {
            if (this.Map != map)
            {
                map.AddRegisteredPosition(this, DisplayLatLong);
                isNewPin = false;
            }

            base.UpdatePosition(map);

            VEPushPinAltitudeEvent altEvent;
            bool  isVisible;
            Point?anchorPosition = GetPosition(DisplayLatLong, out altEvent, out isVisible);

            if (isVisible)
            {
                this.SetValue(VEPushPin.VisibilityProperty, Visibility.Visible);

                //If transitioning from invisible
                if (currentState != VEPushPinState.Visible &&
                    currentState != VEPushPinState.FadingIn)
                {
                    OnShow();

                    AnimationClock showClock = AnimateUtility.AnimateElementDouble(this,
                                                                                   VEPushPin.OpacityProperty,
                                                                                   1,
                                                                                   0,
                                                                                   1);

                    showClock.Completed += new EventHandler(showClock_Completed);
                    currentState         = VEPushPinState.FadingIn;

                    //If transitioning and has a parent
                    if (this.ParentPushPin != null &&
                        (altEvent == VEPushPinAltitudeEvent.TransitionIntoUpperRange))
                    {
                        this.DisplayLatitude  = this.ParentPushPin.Latitude;
                        this.DisplayLongitude = this.ParentPushPin.Longitude;
                    }

                    if (this.DisplayLatitude != this.Latitude ||
                        this.DisplayLongitude != this.Longitude)
                    {
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLatitudeProperty,
                                                            this.Latitude,
                                                            0,
                                                            1);
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLongitudeProperty,
                                                            this.Longitude,
                                                            0,
                                                            1);

                        anchorPosition = GetPosition(DisplayLatLong);
                    }
                }
            }
            else
            {
                //If transitioning from Visible
                if (currentState != VEPushPinState.Hidden &&
                    currentState != VEPushPinState.FadingOut)
                {
                    OnHide();

                    AnimationClock hideClock = AnimateUtility.AnimateElementDouble(this,
                                                                                   VEPushPin.OpacityProperty,
                                                                                   0,
                                                                                   0,
                                                                                   1);

                    hideClock.Completed += new EventHandler(hideClock_Completed);
                    currentState         = VEPushPinState.FadingOut;

                    //If transitioning and has a parent
                    if (this.ParentPushPin != null &&
                        (altEvent == VEPushPinAltitudeEvent.TransitionAboveUpperRange))
                    {
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLatitudeProperty,
                                                            this.ParentPushPin.Latitude,
                                                            0,
                                                            1);
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLongitudeProperty,
                                                            this.ParentPushPin.Longitude,
                                                            0,
                                                            1);

                        anchorPosition = GetPosition(DisplayLatLong);
                    }
                    else
                    {
                        //Not animating, just hide immediately
                        //this.Visibility = Visibility.Collapsed;
                    }
                }
            }

            //Update the calculated position
            if (anchorPosition == null || !map.IsMapLoaded)
            {
                this.Visibility   = Visibility.Collapsed;
                this.Opacity      = 0;
                this.currentState = VEPushPinState.Hidden;

                return(null);
            }

            if (!this.IsMeasureValid)
            {
                this.Opacity      = 0;
                this.currentState = VEPushPinState.Hidden;
                return(null);
            }

            Point anchorOffset = GetAnchorOffset();

            double displayLeft = anchorPosition.Value.X - anchorOffset.X;
            double displayTop  = anchorPosition.Value.Y - anchorOffset.Y;

            return(new Point(displayLeft, displayTop));
        }
 public LinearGradientBrush GetCurrentValue(LinearGradientBrush defaultOriginValue, LinearGradientBrush defaultDestinationValue, AnimationClock animationClock)
 {
     base.ReadPreamble();
     if (animationClock == null)
     {
         throw new ArgumentNullException("animationClock");
     }
     if (animationClock.CurrentState == ClockState.Stopped)
     {
         return(defaultDestinationValue);
     }
     return(this.GetCurrentValueCore(defaultOriginValue, defaultDestinationValue, animationClock));
 }
Esempio n. 16
0
 public void ApplyAnimationClock(DependencyProperty property, AnimationClock clock)
 {
   ApplyAnimationClock(property, clock, HandoffBehavior.SnapshotAndReplace);
 }
Esempio n. 17
0
        public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
        {
            double fromVal = ((GridLength)GetValue(GridLengthAnimation.FromProperty)).Value;
            double toVal   = ((GridLength)GetValue(GridLengthAnimation.ToProperty)).Value;

            if (fromVal > toVal)
            {
                return(new GridLength((1 - animationClock.CurrentProgress.Value) *
                                      (fromVal - toVal) + toVal, GridUnitType.Star));
            }
            else
            {
                return(new GridLength(animationClock.CurrentProgress.Value *
                                      (toVal - fromVal) + fromVal, GridUnitType.Star));
            }
        }
Esempio n. 18
0
        protected override Color GetCurrentValueCore(Color defaultOriginValue, Color defaultDestinationValue, AnimationClock animationClock)
        {
            System.Diagnostics.Debug.Assert(animationClock.CurrentState != ClockState.Stopped);
            if (!_isAnimationFunctionValid)
            {
                ValidateAnimationFunction();
            }
            double          progress       = animationClock.CurrentProgress.Value;
            IEasingFunction easingFunction = EasingFunction;

            if (easingFunction != null)
            {
                progress = easingFunction.Ease(progress);
            }
            double fromVal = _keyvalues[0];
            double toVal   = _keyvalues[1];
            double target;

            if (fromVal > toVal)
            {
                target = (1 - progress) * (fromVal - toVal) + toVal;
            }
            else
            {
                target = (toVal - fromVal) * progress + fromVal;
            }
            Color originColor = OriginColor;

            if (target == 0)
            {
                return(originColor);
            }
            return(ColorEx.ChangeColorBrightness(originColor, target));
        }
Esempio n. 19
0
        public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
        {
            if (defaultOriginValue is GridLength == false)
            {
                throw new ArgumentException("Parameter must be a GridLength", "defaultOriginValue");
            }

            if (defaultDestinationValue is GridLength == false)
            {
                throw new ArgumentException("Parameter must be a GridLength", "defaultDestinationValue");
            }

            return(GetCurrentValueCore((GridLength)defaultOriginValue, (GridLength)defaultDestinationValue, animationClock));
        }
        public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock clock)
        {
            double from = ((GridLength)GetValue(GAnimation.FromProp)).Value;
            double to   = ((GridLength)GetValue(GAnimation.ToProp)).Value;

            if (from > to)
            {
                return(new GridLength((from - to) * (1 - clock.CurrentProgress.Value) + to, GridUnitType.Pixel));
            }
            else
            {
                return(new GridLength((to - from) * clock.CurrentProgress.Value + from, GridUnitType.Pixel));
            }
        }
Esempio n. 21
0
 public abstract GridLength GetCurrentValueCore(GridLength defaultOriginValue, GridLength defaultDestinationValue, AnimationClock animationClock);
Esempio n. 22
0
        /// <summary>
        /// Work out which type of animation is needed
        /// </summary>
        /// <param name="defaultOriginValue">default start value</param>
        /// <param name="defaultDestinationValue">default end value</param>
        /// <param name="animationClock">Animaiton to run</param>
        /// <returns></returns>
        protected override Point GetCurrentValueCore(Point defaultOriginValue, Point defaultDestinationValue, AnimationClock animationClock)
        {
            double returnValueX = 0;
            double returnValueY = 0;

            double time          = animationClock.CurrentTime.Value.TotalSeconds;
            double startValueX   = FromValue.X;
            double eqFinalValueX = ToValue.X - FromValue.X;

            double startValueY   = FromValue.Y;
            double eqFinalValueY = ToValue.Y - FromValue.Y;
            double duration      = Duration.TimeSpan.TotalSeconds;


            switch (this.EaseFunction)
            {
            case PointEasingMode.EaseIn:
                returnValueX = eqFinalValueX * (time /= duration) * time + startValueX;
                returnValueY = eqFinalValueY * (time /= duration) * time + startValueY;
                break;

            case PointEasingMode.EaseOut:
                returnValueX = -eqFinalValueX * (time /= duration) * (time - 2) + startValueX;
                returnValueY = -eqFinalValueY * (time /= duration) * (time - 2) + startValueY;
                break;

            case PointEasingMode.EaseInOut:
                if ((time /= duration / 2) < 1)
                {
                    returnValueX = eqFinalValueX / 2 * time * time + startValueX;
                    returnValueY = eqFinalValueY / 2 * time * time + startValueY;
                }
                else
                {
                    returnValueX = -eqFinalValueX / 2 * ((--time) * (time - 2) - 1) + startValueX;
                    returnValueY = -eqFinalValueY / 2 * ((--time) * (time - 2) - 1) + startValueY;
                }
                break;

            default:
                break;
            }

            return(new Point(returnValueX, returnValueY));
        }
Esempio n. 23
0
        public override GridLength GetCurrentValueCore(GridLength defaultOriginValue, GridLength defaultDestinationValue, AnimationClock animationClock)
        {
            double?from = From;

            if (from == null && (defaultOriginValue.IsAbsolute || defaultOriginValue.IsStar))
            {
                from = defaultOriginValue.Value;
            }

            if (from == null)
            {
                throw new Exception("From must be specified in a GridLengthAnimation");
            }

            double a_to;

            if (To != null)
            {
                a_to = To.Value;
            }
            else if (By != null)
            {
                a_to = from.Value + By.Value;
            }
            else
            {
                throw new Exception("Either To or By must be specified in a GridLengthAnimation");
            }

            return(new GridLength(from.Value + ((a_to - from.Value) * animationClock.CurrentProgress.Value)));
        }
Esempio n. 24
0
        /// <summary>
        /// Calculates a value that represents the current value of the property being animated, as determined by the <see cref="T:System.Windows.Media.Animation.ThicknessAnimation"/>.
        /// </summary>
        ///
        /// <returns>
        /// The calculated value of the property, as determined by the current animation.
        /// </returns>
        /// <param name="defaultOriginValue">The suggested origin value, used if the animation does not have its own explicitly set start value.</param><param name="defaultDestinationValue">The suggested destination value, used if the animation does not have its own explicitly set end value.</param><param name="animationClock">An <see cref="T:System.Windows.Media.Animation.AnimationClock"/> that generates the <see cref="P:System.Windows.Media.Animation.Clock.CurrentTime"/> or <see cref="P:System.Windows.Media.Animation.Clock.CurrentProgress"/> used by the animation.</param>
        protected override CornerRadius GetCurrentValueCore(CornerRadius defaultOriginValue, CornerRadius defaultDestinationValue, AnimationClock animationClock)
        {
            if (!this._isAnimationFunctionValid)
            {
                this.ValidateAnimationFunction();
            }
            double          num1           = animationClock.CurrentProgress.Value;
            IEasingFunction easingFunction = this.EasingFunction;

            if (easingFunction != null)
            {
                num1 = easingFunction.Ease(num1);
            }
            var  from       = new CornerRadius();
            var  to         = new CornerRadius();
            var  thickness1 = new CornerRadius();
            var  thickness2 = new CornerRadius();
            bool flag1      = false;
            bool flag2      = false;

            switch (this._AnimationMode)
            {
            case AnimationMode.Automatic:
                from  = defaultOriginValue;
                to    = defaultDestinationValue;
                flag1 = true;
                flag2 = true;
                break;

            case AnimationMode.From:
                from  = this._keyValues[0];
                to    = defaultDestinationValue;
                flag2 = true;
                break;

            case AnimationMode.To:
                from  = defaultOriginValue;
                to    = this._keyValues[0];
                flag1 = true;
                break;

            case AnimationMode.By:
                to         = this._keyValues[0];
                thickness2 = defaultOriginValue;
                flag1      = true;
                break;

            case AnimationMode.FromTo:
                from = this._keyValues[0];
                to   = this._keyValues[1];
                if (this.IsAdditive)
                {
                    thickness2 = defaultOriginValue;
                    flag1      = true;
                    break;
                }
                break;

            case AnimationMode.FromBy:
                from = this._keyValues[0];
                to   = AnimationHelpers.AddCornerRadius(this._keyValues[0], this._keyValues[1]);
                if (this.IsAdditive)
                {
                    thickness2 = defaultOriginValue;
                    flag1      = true;
                    break;
                }
                break;
            }
            if (flag1 && !AnimationHelpers.IsValidAnimationValueCornerRadius(defaultOriginValue))
            {
                throw new InvalidOperationException("Animation_Invalid_DefaultValue");
            }
            if (flag2 && !AnimationHelpers.IsValidAnimationValueCornerRadius(defaultDestinationValue))
            {
                throw new InvalidOperationException("Animation_Invalid_DefaultValue");
            }
            if (this.IsCumulative)
            {
                int?   currentIteration = animationClock.CurrentIteration;
                int    num2             = 1;
                double factor           = (double)(currentIteration.HasValue ? new int?(currentIteration.GetValueOrDefault() - num2) : new int?()).Value;
                if (factor > 0.0)
                {
                    thickness1 = AnimationHelpers.ScaleCornerRadius(AnimationHelpers.SubtractCornerRadius(to, from), factor);
                }
            }
            return(AnimationHelpers.AddCornerRadius(thickness2, AnimationHelpers.AddCornerRadius(thickness1, AnimationHelpers.InterpolateCornerRadius(from, to, num1))));
        }
 public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
 {
     return(this.GetCurrentValue(defaultOriginValue as Brush, defaultDestinationValue as Brush, animationClock));
 }
 protected abstract LinearGradientBrush GetCurrentValueCore(LinearGradientBrush
                                                            defaultOriginValue, LinearGradientBrush defaultDestinationValue,
                                                            AnimationClock animationClock);
        public object GetCurrentValue(Brush defaultOriginValue, Brush defaultDestinationValue, AnimationClock animationClock)
        {
            if (!animationClock.CurrentProgress.HasValue)
            {
                return(Brushes.Transparent);
            }

            //use the standard values if From and To are not set
            //(it is the value of the given property)
            defaultOriginValue      = this.From ?? defaultOriginValue;
            defaultDestinationValue = this.To ?? defaultDestinationValue;

            if (animationClock.CurrentProgress.Value == 0)
            {
                return(defaultOriginValue);
            }
            if (animationClock.CurrentProgress.Value == 1)
            {
                return(defaultDestinationValue);
            }

            return(new VisualBrush(new Border {
                Width = 1, Height = 1, Background = defaultOriginValue, Child = new Border {
                    Background = defaultDestinationValue, Opacity = animationClock.CurrentProgress.Value
                }
            }));
        }
Esempio n. 28
0
 public double GetCurrentValueCorePublic(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock) =>
 GetCurrentValueCore(defaultOriginValue, defaultDestinationValue, animationClock);
Esempio n. 29
0
        protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock clock)
        {
            double returnValue;
            double start = From != null ? (double)From : defaultOriginValue;
            double delta = To != null ? (double)To - start : defaultOriginValue - start;

            switch (this.EdgeBehavior)
            {
            case EdgeBehaviorEnum.EaseIn:
                returnValue = easeIn(clock.CurrentProgress.Value, start, delta, Power);
                break;

            case EdgeBehaviorEnum.EaseOut:
                returnValue = easeOut(clock.CurrentProgress.Value, start, delta, Power);
                break;

            case EdgeBehaviorEnum.EaseInOut:
            default:
                returnValue = easeInOut(clock.CurrentProgress.Value, start, delta, Power);
                break;
            }
            return(returnValue);
        }
Esempio n. 30
0
        /// <summary>
        /// returns the current size value for a given time between <see cref="From"/> and <see cref="To"/>
        /// </summary>
        /// <param name="defaultOriginValue">start size value</param>
        /// <param name="defaultDestinationValue">end size value</param>
        /// <param name="animationClock">describes the current time</param>
        /// <returns></returns>
        public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
        {
            double fromValue = From.Value;
            double toValue   = To.Value;

            if (fromValue > toValue)
            {
                return(new GridLength((1 - animationClock.CurrentProgress.Value) * (fromValue - toValue) + toValue, GridUnitType.Pixel));
            }
            else
            {
                return(new GridLength(animationClock.CurrentProgress.Value * (toValue - fromValue) + fromValue, GridUnitType.Pixel));
            }
        }
Esempio n. 31
0
        protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock clock)
        {
            double returnValue;
            double time = clock.CurrentProgress.Value;

            // math magic: calculate new coordinates using polar coordinate equations. This requires two
            // animations to be wired up in order to move in a circle, since we don't make any assumptions
            // about what we're animating (e.g. a TranslateTransform).
            if (Direction == DirectionEnum.XDirection)
            {
                returnValue = Math.Cos(2 * Math.PI * time);
            }
            else
            {
                returnValue = Math.Sin(2 * Math.PI * time);
            }

            // Need to add the defaultOriginValue so that composition works.
            return(returnValue * Radius + defaultOriginValue);
        }
 protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue,
                                               AnimationClock animationClock)
 {
   throw new NotImplementedException();
 }
Esempio n. 33
0
 void Start()
 {
     Stop();
     m_clock = s_animationClock.CreateClock();
     ApplyAnimationClock(AnimationClockProperty, m_clock);
 }
Esempio n. 34
0
 public void ApplyAnimationClock(DependencyProperty property, AnimationClock clock, HandoffBehavior handoffBehavior) {}
 public double GetCurrentValue(double defaultOriginValue, double defaultDestinationValue,
                               AnimationClock animationClock)
 {
   return GetCurrentValueCore(defaultOriginValue, defaultDestinationValue, animationClock);
 }