/// <summary> 
 /// Constructor for public SizeAnimationClockResource. 
 /// This constructor accepts the base value and AnimationClock.
 /// Note that since there is no current requirement that we be able to set or replace either the 
 /// base value or the AnimationClock, this is the only way to initialize an instance of
 /// SizeAnimationClockResource.
 /// Also, we currently Assert that the resource is non-null, since without mutability
 /// such a resource isn't needed. 
 /// We can easily extend this class if/when new requirements arise.
 /// </summary> 
 /// <param name="baseValue"> Size - The base value. </param> 
 /// <param name="animationClock"> AnimationClock - cannot be null. </param>
 public SizeAnimationClockResource( 
     Size baseValue,
     AnimationClock animationClock
     ): base( animationClock )
 { 
     _baseValue = baseValue;
 } 
 /// <summary>
 /// Constructor for public RectAnimationClockResource.
 /// This constructor accepts the base value and AnimationClock.
 /// Note that since there is no current requirement that we be able to set or replace either the
 /// base value or the AnimationClock, this is the only way to initialize an instance of
 /// RectAnimationClockResource.
 /// Also, we currently Assert that the resource is non-null, since without mutability
 /// such a resource isn't needed.
 /// We can easily extend this class if/when new requirements arise.
 /// </summary>
 /// <param name="baseValue"> Rect - The base value. </param>
 /// <param name="animationClock"> AnimationClock - cannot be null. </param>
 public RectAnimationClockResource(
     Rect baseValue,
     AnimationClock animationClock
     ): base( animationClock )
 {
     _baseValue = baseValue;
 }
Beispiel #3
0
        public void Init(MyModel mm)
        {
            this.mm = mm;

            Transform3DGroup t3dg = (Transform3DGroup)this.mm.m3dg.Transform;
            RotateTransform3D rtx = (RotateTransform3D)t3dg.Children[2];
            AxisAngleRotation3D aar3dx = (AxisAngleRotation3D)rtx.Rotation;
            RotateTransform3D rty = (RotateTransform3D)t3dg.Children[3];
            AxisAngleRotation3D aar3dy = (AxisAngleRotation3D)rty.Rotation;
            RotateTransform3D rtz = (RotateTransform3D)t3dg.Children[4];
            AxisAngleRotation3D aar3dz = (AxisAngleRotation3D)rtz.Rotation;

            DoubleAnimation dax = new DoubleAnimation(360, new Duration(new TimeSpan(0, 0, 10)));
            dax.RepeatBehavior = RepeatBehavior.Forever;
            //aar3dx.BeginAnimation(AxisAngleRotation3D.AngleProperty, dax);
            clockx = dax.CreateClock();

            DoubleAnimation day = new DoubleAnimation(360, new Duration(new TimeSpan(0, 0, 5)));
            day.RepeatBehavior = RepeatBehavior.Forever;
            clocky = day.CreateClock();

            DoubleAnimation daz = new DoubleAnimation(360, new Duration(new TimeSpan(0, 0, 5)));
            daz.RepeatBehavior = RepeatBehavior.Forever;
            clockz = daz.CreateClock();

            aar3dx.ApplyAnimationClock(AxisAngleRotation3D.AngleProperty, clockx);
            aar3dy.ApplyAnimationClock(AxisAngleRotation3D.AngleProperty, clocky);
            aar3dz.ApplyAnimationClock(AxisAngleRotation3D.AngleProperty, clockx);
            clockx.Controller.Begin();
            clocky.Controller.Begin();
            clockz.Controller.Begin();
        }
 /// <summary>
 /// Constructor for public PointAnimationClockResource.
 /// This constructor accepts the base value and AnimationClock.
 /// Note that since there is no current requirement that we be able to set or replace either the
 /// base value or the AnimationClock, this is the only way to initialize an instance of
 /// PointAnimationClockResource.
 /// Also, we currently Assert that the resource is non-null, since without mutability
 /// such a resource isn't needed.
 /// We can easily extend this class if/when new requirements arise.
 /// </summary>
 /// <param name="baseValue"> Point - The base value. </param>
 /// <param name="animationClock"> AnimationClock - cannot be null. </param>
 public PointAnimationClockResource(
     Point baseValue,
     AnimationClock animationClock
     ): base( animationClock )
 {
     _baseValue = baseValue;
 }
 /// <summary>
 /// Constructor for public DoubleAnimationClockResource.
 /// This constructor accepts the base value and AnimationClock.
 /// Note that since there is no current requirement that we be able to set or replace either the
 /// base value or the AnimationClock, this is the only way to initialize an instance of
 /// DoubleAnimationClockResource.
 /// Also, we currently Assert that the resource is non-null, since without mutability
 /// such a resource isn't needed.
 /// We can easily extend this class if/when new requirements arise.
 /// </summary>
 /// <param name="baseValue"> Double - The base value. </param>
 /// <param name="animationClock"> AnimationClock - cannot be null. </param>
 public DoubleAnimationClockResource(
     Double baseValue,
     AnimationClock animationClock
     ): base( animationClock )
 {
     _baseValue = baseValue;
 }
Beispiel #6
0
 public override object GetCurrentValue(object defaultOriginValue, 
     object defaultDestinationValue,
     AnimationClock animationClock)
 {
     TimeSpan? current = animationClock.CurrentTime;
     Double increase = _to - _from;
     return _from + (increase / ((Double)Duration.TimeSpan.Ticks / (Double)current.Value.Ticks));
 }
Beispiel #7
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 override void DrawLine(
     Pen pen,
     Point point0,
     AnimationClock point0Animations,
     Point point1,
     AnimationClock point1Animations)
 {
     Debug.Assert(false);
 }
Beispiel #8
0
 protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock)
 {
     double time = animationClock.CurrentTime.HasValue ? animationClock.CurrentTime.Value.TotalMilliseconds : 0.0;
     double from = this.From.HasValue ? this.From.Value : defaultOriginValue;
     double to = this.To.HasValue ? this.To.Value : defaultDestinationValue;
     double delta = to - from;
     double duration = this.Duration.TimeSpan.TotalMilliseconds;
     return CalculateCurrentValue(time, from, delta, duration);
 }
        /// <summary> 
        /// Protected constructor for AnimationClockResource.
        /// The derived class must provide a created duceResource.
        /// </summary>
        /// <param name="animationClock"> The AnimationClock for this resource.  Can be null. </param> 
        protected AnimationClockResource(AnimationClock animationClock)
        { 
            _animationClock = animationClock; 

            if (_animationClock != null) 
            {
                _animationClock.CurrentTimeInvalidated += new EventHandler(OnChanged);
            }
        } 
    public void Add(AnimationClock clock)
    {
      if (clock == null)
      {
        throw new ArgumentNullException("clock");
      }

      List.Add(clock);
    }
    public bool Contains(AnimationClock clock)
    {
      if (clock == null)
      {
        throw new ArgumentNullException("clock");
      }

      return List.Contains(clock);
    }
    public void CopyTo(AnimationClock[] array, int arrayIndex)
    {
      if (array == null)
      {
        throw new ArgumentNullException("array");
      }

      List.CopyTo(array, arrayIndex);
    }
    public int IndexOf(AnimationClock clock)
    {
      if (clock == null)
      {
        throw new ArgumentNullException("clock");
      }

      return List.IndexOf(clock);
    }
    public void Insert(int index, AnimationClock clock)
    {
      if (clock == null)
      {
        throw new ArgumentNullException("clock");
      }

      List.Insert(index, clock);
    }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Internal Constructor
        /// </summary>
        /// <param name="clock"></param>
        /// <param name="property"></param>
        /// <param name="target"></param>
        /// <param name="message"></param>
        /// <param name="innerException"></param>
        internal AnimationException(
            AnimationClock clock, DependencyProperty property, IAnimatable target,
            string message, Exception innerException)
            : base(message, innerException)
        {
            _clock = clock;
            _property = property;
            _targetElement = target;
        }
        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);
        }
Beispiel #17
0
		protected override Point3DCollection GetCurrentValueCore(Point3DCollection defaultOriginValue,
		                                                         Point3DCollection defaultDestinationValue,
		                                                         AnimationClock animationClock)
		{
			double progress = animationClock.CurrentProgress.Value;
			if (progress <= 0.0)
			{
				Initialize();
			}
			return GetMeshPositions(progress);
		}
        public Point3DCollection GetCurrentValue(Point3DCollection defaultOriginValue,
		                                         Point3DCollection defaultDestinationValue,
		                                         AnimationClock animationClock)
        {
            if (animationClock == null)
            {
                throw new ArgumentException("animationClock");
            }

            return GetCurrentValueCore(defaultOriginValue, defaultDestinationValue, animationClock);
        }
Beispiel #19
0
        public override object GetCurrentValue(object defaultOriginValue,
            object defaultDestinationValue, AnimationClock animationClock)
        {
            var fromVal = ((GridLength)GetValue(FromProperty)).Value;
            var toVal = ((GridLength)GetValue(ToProperty)).Value;

            return fromVal > toVal
                       ? new GridLength((1 - animationClock.CurrentProgress.Value)*(fromVal - toVal) + toVal,
                                        GridUnitType.Star)
                       : new GridLength(animationClock.CurrentProgress.Value*(toVal - fromVal) + fromVal,
                                        GridUnitType.Star);
        }
 /// <summary>
 /// Calculates the value this animation believes should be the current value for the property.
 /// </summary>
 /// <param name="defaultOriginValue">
 /// This value is the suggested origin value provided to the animation
 /// to be used if the animation does not have its own concept of a
 /// start value. If this animation is the first in a composition chain
 /// this value will be the snapshot value if one is available or the
 /// base property value if it is not; otherise this value will be the 
 /// value returned by the previous animation in the chain with an 
 /// animationClock that is not Stopped.
 /// </param>
 /// <param name="defaultDestinationValue">
 /// This value is the suggested destination value provided to the animation
 /// to be used if the animation does not have its own concept of an
 /// end value. This value will be the base value if the animation is
 /// in the first composition layer of animations on a property; 
 /// otherwise this value will be the output value from the previous 
 /// composition layer of animations for the property.
 /// </param>
 /// <param name="animationClock">
 /// This is the animationClock which can generate the CurrentTime or
 /// CurrentProgress value to be used by the animation to generate its
 /// output value.
 /// </param>
 /// <returns>
 /// The value this animation believes should be the current value for the property.
 /// </returns>
 public override sealed object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
 {
     // Verify that object arguments are non-null since we are a value type
     if (defaultOriginValue == null)
     {
         throw new ArgumentNullException("defaultOriginValue");
     }
     if (defaultDestinationValue == null)
     {
         throw new ArgumentNullException("defaultDestinationValue");
     }
     return GetCurrentValue((CornerRadius)defaultOriginValue, (CornerRadius)defaultDestinationValue, animationClock);
 }
Beispiel #21
0
        protected override double GetCurrentValueCore(double startValue, double targetValue, AnimationClock clock)
        {
            try
            {
                // might be able to speed this up by caching it, but who knows
                object[] methodParams = new object[4] { clock.CurrentTime.Value.TotalSeconds, From, To - From, Duration.TimeSpan.TotalSeconds };

                return (double)_EasingMethod.Invoke(this, methodParams);
            }
            catch
            {
                return From;
            }
        }
        public override Geometry GetCurrentValueCore(Geometry defaultOriginValue, Geometry defaultDestinationValue, AnimationClock animationClock)
        {
            var progress = animationClock.CurrentProgress.Value;

            foreach (var f in Geometry.Figures)
            {
                foreach (var s in f.Segments)
                {

                }
            }

            return null;
        }
        public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
        {
            double fromValue = ((GridLength)GetValue(GridLengthAnimation.FromProperty)).Value;
            double toValue = ((GridLength)GetValue(GridLengthAnimation.ToProperty)).Value;

            if (fromValue > toValue)
            {
                return new GridLength((1 - animationClock.CurrentProgress.Value) * (fromValue - toValue) + toValue, this.To.IsStar ? GridUnitType.Star : GridUnitType.Pixel);
            }
            else
            {
                return new GridLength((animationClock.CurrentProgress.Value) * (toValue - fromValue) + fromValue, this.To.IsStar ? GridUnitType.Star : GridUnitType.Pixel);
            }
        }
        public override object GetCurrentValue(
            object defaultOriginValue, object defaultDestinationValue,
            AnimationClock animationClock)
        {
            PathGeometry path = this.PathGeometry;

            Point point;
            Point tangent;

            path.GetPointAtFractionLength(
                animationClock.CurrentProgress.Value, out point, out tangent);

            return new Point3D(point.X, point.Y, Z);
        }
Beispiel #25
0
        protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue,
            AnimationClock clock)
        {
            var 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). 
            var returnValue = Direction == DirectionEnum.XDirection
                ? Math.Cos(2*Math.PI*time)
                : Math.Sin(2*Math.PI*time);

            // Need to add the defaultOriginValue so that composition works.
            return returnValue*Radius + defaultOriginValue;
        }
        public override object GetCurrentValue(object defaultOriginValue,
            object defaultDestinationValue, AnimationClock animationClock)
        {
            var fromGridLength = ((GridLength)GetValue(GridLengthAnimation.FromProperty));
            var toGridLength = ((GridLength)GetValue(GridLengthAnimation.ToProperty));

            return toGridLength;

            //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);
        }
        /// <summary>
        /// Attaches an AnimationClock but does not add it to the collection.
        /// </summary>
        /// <remarks>
        /// It's expected that the AnimationClock will have been added to the
        /// collection before this is called.
        /// </remarks>
        /// <param name="animationClock">The AnimationClock.</param>
        /// <param name="removeRequestedHandler">
        /// The event handler to be executed when the RemoveRequested event is
        /// raised by the AnimationClock.
        /// </param>
        internal void AttachAnimationClock(
            AnimationClock animationClock,
            EventHandler removeRequestedHandler)
        {
            Debug.Assert(animationClock != null);
            Debug.Assert(_dependencyObject.Target != null);
            Debug.Assert(_currentTimeInvalidatedHandler != null);

            animationClock.CurrentTimeInvalidated += _currentTimeInvalidatedHandler;

            if (animationClock.HasControllableRoot)
            {
                animationClock.RemoveRequested += removeRequestedHandler;
            }
        }
        public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
        {
            if (!animationClock.CurrentProgress.HasValue) return From;

            var progress = (EasingFunction != null) ? EasingFunction.Ease(animationClock.CurrentProgress.Value) : animationClock.CurrentProgress.Value;

            double newMin, newMax;
            if (_from.Min > To.Min) newMin = (1 - progress) * (_from.Min - To.Min) + To.Min;
            else newMin = progress * (To.Min - _from.Min) + _from.Min;
            if (_from.Max > To.Max) newMax = (1 - progress) * (_from.Max - To.Max) + To.Max;
            else newMax = progress * (To.Max - _from.Max) + _from.Max;
            From.Update(newMin, newMax);
            //Debug.WriteLine(string.Format("{0:HH:mm:ss.fff} GetCurrentValue returning: {1}", DateTime.Now, From));
            return From;
        }
        public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
        {
            var from = (GridLength)this.GetValue(FromProperty);
            var to = (GridLength)this.GetValue(ToProperty);
            if (from.GridUnitType != to.GridUnitType) // We can't animate different types, so just skip straight to it
                return to;
            var fromVal = from.Value;
            var toVal = to.Value;

            if (fromVal > toVal)
            {
                return new GridLength((1 - animationClock.CurrentProgress.Value) * (fromVal - toVal) + toVal, GridUnitType.Star);
            }
            return new GridLength(animationClock.CurrentProgress.Value * (toVal - fromVal) + fromVal, GridUnitType.Star);
        }
 /// <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 override void DrawLine(
     Pen pen,
     Point point0,
     AnimationClock point0Animations,
     Point point1,
     AnimationClock point1Animations)
 {
     _drawingContext.DrawLine(
         pen,
         point0,
         point0Animations,
         point1,
         point1Animations
         );
 }
Beispiel #31
0
 protected override System.Windows.Media.Media3D.Vector3D GetCurrentValueCore(System.Windows.Media.Media3D.Vector3D defaultOriginValue, System.Windows.Media.Media3D.Vector3D defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(System.Windows.Media.Media3D.Vector3D));
 }
        /// <summary>
        /// Calculates the value this animation believes should be the current value for the property.
        /// </summary>
        /// <param name="defaultOriginValue">
        /// This value is the suggested origin value provided to the animation
        /// to be used if the animation does not have its own concept of a
        /// start value. If this animation is the first in a composition chain
        /// this value will be the snapshot value if one is available or the
        /// base property value if it is not; otherise this value will be the
        /// value returned by the previous animation in the chain with an
        /// animationClock that is not Stopped.
        /// </param>
        /// <param name="defaultDestinationValue">
        /// This value is the suggested destination value provided to the animation
        /// to be used if the animation does not have its own concept of an
        /// end value. This value will be the base value if the animation is
        /// in the first composition layer of animations on a property;
        /// otherwise this value will be the output value from the previous
        /// composition layer of animations for the property.
        /// </param>
        /// <param name="animationClock">
        /// This is the animationClock which can generate the CurrentTime or
        /// CurrentProgress value to be used by the animation to generate its
        /// output value.
        /// </param>
        /// <returns>
        /// The value this animation believes should be the current value for the property.
        /// </returns>
        protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock)
        {
            Debug.Assert(animationClock.CurrentState != ClockState.Stopped);

            PathGeometry pathGeometry = PathGeometry;

            if (pathGeometry == null)
            {
                return(defaultDestinationValue);
            }

            if (!_isValid)
            {
                Validate();
            }

            Point  pathPoint;
            Point  pathTangent;
            double pathValue = 0.0;

            pathGeometry.GetPointAtFractionLength(animationClock.CurrentProgress.Value, out pathPoint, out pathTangent);

            switch (Source)
            {
            case PathAnimationSource.Angle:
                pathValue = CalculateAngleFromTangentVector(pathTangent.X, pathTangent.Y);
                break;

            case PathAnimationSource.X:
                pathValue = pathPoint.X;
                break;

            case PathAnimationSource.Y:
                pathValue = pathPoint.Y;
                break;
            }

            double currentRepeat = (double)(animationClock.CurrentIteration - 1);

            if (IsCumulative &&
                currentRepeat > 0)
            {
                pathValue += (_accumulatingValue * currentRepeat);
            }

            if (IsAdditive)
            {
                return(defaultOriginValue + pathValue);
            }
            else
            {
                return(pathValue);
            }
        }
 protected sealed override string GetCurrentValueCore(string defaultOriginValue, string defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(string));
 }
Beispiel #34
0
 /// <summary>
 /// Calculates the value this animation believes should be the current value for the property.
 /// </summary>
 /// <param name="defaultOriginValue">
 /// This value is the suggested origin value provided to the animation
 /// to be used if the animation does not have its own concept of a
 /// start value. If this animation is the first in a composition chain
 /// this value will be the snapshot value if one is available or the
 /// base property value if it is not; otherise this value will be the
 /// value returned by the previous animation in the chain with an
 /// animationClock that is not Stopped.
 /// </param>
 /// <param name="defaultDestinationValue">
 /// This value is the suggested destination value provided to the animation
 /// to be used if the animation does not have its own concept of an
 /// end value. This value will be the base value if the animation is
 /// in the first composition layer of animations on a property;
 /// otherwise this value will be the output value from the previous
 /// composition layer of animations for the property.
 /// </param>
 /// <param name="animationClock">
 /// This is the animationClock which can generate the CurrentTime or
 /// CurrentProgress value to be used by the animation to generate its
 /// output value.
 /// </param>
 /// <returns>
 /// The value this animation believes should be the current value for the property.
 /// </returns>
 protected abstract Char GetCurrentValueCore(Char defaultOriginValue, Char defaultDestinationValue, AnimationClock animationClock);
 protected abstract short GetCurrentValueCore(short defaultOriginValue, short defaultDestinationValue, AnimationClock animationClock);
        /// <summary>
        /// Calculates the value this animation believes should be the current value for the property.
        /// </summary>
        /// <param name="defaultOriginValue">
        /// This value is the suggested origin value provided to the animation
        /// to be used if the animation does not have its own concept of a
        /// start value. If this animation is the first in a composition chain
        /// this value will be the snapshot value if one is available or the
        /// base property value if it is not; otherise this value will be the
        /// value returned by the previous animation in the chain with an
        /// animationClock that is not Stopped.
        /// </param>
        /// <param name="defaultDestinationValue">
        /// This value is the suggested destination value provided to the animation
        /// to be used if the animation does not have its own concept of an
        /// end value. This value will be the base value if the animation is
        /// in the first composition layer of animations on a property;
        /// otherwise this value will be the output value from the previous
        /// composition layer of animations for the property.
        /// </param>
        /// <param name="animationClock">
        /// This is the animationClock which can generate the CurrentTime or
        /// CurrentProgress value to be used by the animation to generate its
        /// output value.
        /// </param>
        /// <returns>
        /// The value this animation believes should be the current value for the property.
        /// </returns>
        protected sealed override Int16 GetCurrentValueCore(
            Int16 defaultOriginValue,
            Int16 defaultDestinationValue,
            AnimationClock animationClock)
        {
            Debug.Assert(animationClock.CurrentState != ClockState.Stopped);

            if (_keyFrames == null)
            {
                return(defaultDestinationValue);
            }

            // We resolved our KeyTimes when we froze, but also got notified
            // of the frozen state and therefore invalidated ourselves.
            if (!_areKeyTimesValid)
            {
                ResolveKeyTimes();
            }

            if (_sortedResolvedKeyFrames == null)
            {
                return(defaultDestinationValue);
            }

            TimeSpan currentTime      = animationClock.CurrentTime.Value;
            Int32    keyFrameCount    = _sortedResolvedKeyFrames.Length;
            Int32    maxKeyFrameIndex = keyFrameCount - 1;

            Int16 currentIterationValue;

            Debug.Assert(maxKeyFrameIndex >= 0, "maxKeyFrameIndex is less than zero which means we don't actually have any key frames.");

            Int32 currentResolvedKeyFrameIndex = 0;

            // Skip all the key frames with key times lower than the current time.
            // currentResolvedKeyFrameIndex will be greater than maxKeyFrameIndex
            // if we are past the last key frame.
            while (currentResolvedKeyFrameIndex < keyFrameCount &&
                   currentTime > _sortedResolvedKeyFrames[currentResolvedKeyFrameIndex]._resolvedKeyTime)
            {
                currentResolvedKeyFrameIndex++;
            }

            // If there are multiple key frames at the same key time, be sure to go to the last one.
            while (currentResolvedKeyFrameIndex < maxKeyFrameIndex &&
                   currentTime == _sortedResolvedKeyFrames[currentResolvedKeyFrameIndex + 1]._resolvedKeyTime)
            {
                currentResolvedKeyFrameIndex++;
            }

            if (currentResolvedKeyFrameIndex == keyFrameCount)
            {
                // Past the last key frame.
                currentIterationValue = GetResolvedKeyFrameValue(maxKeyFrameIndex);
            }
            else if (currentTime == _sortedResolvedKeyFrames[currentResolvedKeyFrameIndex]._resolvedKeyTime)
            {
                // Exactly on a key frame.
                currentIterationValue = GetResolvedKeyFrameValue(currentResolvedKeyFrameIndex);
            }
            else
            {
                // Between two key frames.
                Double currentSegmentProgress = 0.0;
                Int16  fromValue;

                if (currentResolvedKeyFrameIndex == 0)
                {
                    // The current key frame is the first key frame so we have
                    // some special rules for determining the fromValue and an
                    // optimized method of calculating the currentSegmentProgress.

                    // If we're additive we want the base value to be a zero value
                    // so that if there isn't a key frame at time 0.0, we'll use
                    // the zero value for the time 0.0 value and then add that
                    // later to the base value.
                    if (IsAdditive)
                    {
                        fromValue = AnimatedTypeHelpers.GetZeroValueInt16(defaultOriginValue);
                    }
                    else
                    {
                        fromValue = defaultOriginValue;
                    }

                    // Current segment time divided by the segment duration.
                    // Note: the reason this works is that we know that we're in
                    // the first segment, so we can assume:
                    //
                    // currentTime.TotalMilliseconds                                  = current segment time
                    // _sortedResolvedKeyFrames[0]._resolvedKeyTime.TotalMilliseconds = current segment duration

                    currentSegmentProgress = currentTime.TotalMilliseconds
                                             / _sortedResolvedKeyFrames[0]._resolvedKeyTime.TotalMilliseconds;
                }
                else
                {
                    Int32    previousResolvedKeyFrameIndex = currentResolvedKeyFrameIndex - 1;
                    TimeSpan previousResolvedKeyTime       = _sortedResolvedKeyFrames[previousResolvedKeyFrameIndex]._resolvedKeyTime;

                    fromValue = GetResolvedKeyFrameValue(previousResolvedKeyFrameIndex);

                    TimeSpan segmentCurrentTime = currentTime - previousResolvedKeyTime;
                    TimeSpan segmentDuration    = _sortedResolvedKeyFrames[currentResolvedKeyFrameIndex]._resolvedKeyTime - previousResolvedKeyTime;

                    currentSegmentProgress = segmentCurrentTime.TotalMilliseconds
                                             / segmentDuration.TotalMilliseconds;
                }

                currentIterationValue = GetResolvedKeyFrame(currentResolvedKeyFrameIndex).InterpolateValue(fromValue, currentSegmentProgress);
            }



            // If we're cumulative, we need to multiply the final key frame
            // value by the current repeat count and add this to the return
            // value.
            if (IsCumulative)
            {
                Double currentRepeat = (Double)(animationClock.CurrentIteration - 1);

                if (currentRepeat > 0.0)
                {
                    currentIterationValue = AnimatedTypeHelpers.AddInt16(
                        currentIterationValue,
                        AnimatedTypeHelpers.ScaleInt16(GetResolvedKeyFrameValue(maxKeyFrameIndex), currentRepeat));
                }
            }

            // If we're additive we need to add the base value to the return value.
            if (IsAdditive)
            {
                return(AnimatedTypeHelpers.AddInt16(defaultOriginValue, currentIterationValue));
            }


            return(currentIterationValue);
        }
 protected override sealed Color GetCurrentValueCore(Color defaultOriginValue, Color defaultDestinationValue, AnimationClock animationClock)
 {
     throw new NotImplementedException();
 }
Beispiel #38
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>
        /// <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>
        /// <returns>The calculated value of the property, as determined by the current animation.</returns>
        // Token: 0x06001742 RID: 5954 RVA: 0x00072068 File Offset: 0x00070268
        protected override Thickness GetCurrentValueCore(Thickness defaultOriginValue, Thickness defaultDestinationValue, AnimationClock animationClock)
        {
            if (!this._isAnimationFunctionValid)
            {
                this.ValidateAnimationFunction();
            }
            double          num            = animationClock.CurrentProgress.Value;
            IEasingFunction easingFunction = this.EasingFunction;

            if (easingFunction != null)
            {
                num = easingFunction.Ease(num);
            }
            Thickness thickness  = default(Thickness);
            Thickness thickness2 = default(Thickness);
            Thickness value      = default(Thickness);
            Thickness value2     = default(Thickness);
            bool      flag       = false;
            bool      flag2      = false;

            switch (this._animationType)
            {
            case AnimationType.Automatic:
                thickness  = defaultOriginValue;
                thickness2 = defaultDestinationValue;
                flag       = true;
                flag2      = true;
                break;

            case AnimationType.From:
                thickness  = this._keyValues[0];
                thickness2 = defaultDestinationValue;
                flag2      = true;
                break;

            case AnimationType.To:
                thickness  = defaultOriginValue;
                thickness2 = this._keyValues[0];
                flag       = true;
                break;

            case AnimationType.By:
                thickness2 = this._keyValues[0];
                value2     = defaultOriginValue;
                flag       = true;
                break;

            case AnimationType.FromTo:
                thickness  = this._keyValues[0];
                thickness2 = this._keyValues[1];
                if (this.IsAdditive)
                {
                    value2 = defaultOriginValue;
                    flag   = true;
                }
                break;

            case AnimationType.FromBy:
                thickness  = this._keyValues[0];
                thickness2 = AnimatedTypeHelpers.AddThickness(this._keyValues[0], this._keyValues[1]);
                if (this.IsAdditive)
                {
                    value2 = defaultOriginValue;
                    flag   = true;
                }
                break;
            }
            if (flag && !AnimatedTypeHelpers.IsValidAnimationValueThickness(defaultOriginValue))
            {
                throw new InvalidOperationException(SR.Get("Animation_Invalid_DefaultValue", new object[]
                {
                    base.GetType(),
                    "origin",
                    defaultOriginValue.ToString(CultureInfo.InvariantCulture)
                }));
            }
            if (flag2 && !AnimatedTypeHelpers.IsValidAnimationValueThickness(defaultDestinationValue))
            {
                throw new InvalidOperationException(SR.Get("Animation_Invalid_DefaultValue", new object[]
                {
                    base.GetType(),
                    "destination",
                    defaultDestinationValue.ToString(CultureInfo.InvariantCulture)
                }));
            }
            if (this.IsCumulative)
            {
                double num2 = (double)(animationClock.CurrentIteration - 1).Value;
                if (num2 > 0.0)
                {
                    Thickness value3 = AnimatedTypeHelpers.SubtractThickness(thickness2, thickness);
                    value = AnimatedTypeHelpers.ScaleThickness(value3, num2);
                }
            }
            return(AnimatedTypeHelpers.AddThickness(value2, AnimatedTypeHelpers.AddThickness(value, AnimatedTypeHelpers.InterpolateThickness(thickness, thickness2, num))));
        }
Beispiel #39
0
 public long GetCurrentValue(long defaultOriginValue, long defaultDestinationValue, AnimationClock animationClock)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Calculates the value this animation believes should be the current value for the property.
 /// </summary>
 /// <param name="defaultOriginValue">
 /// This value is the suggested origin value provided to the animation
 /// to be used if the animation does not have its own concept of a
 /// start value. If this animation is the first in a composition chain
 /// this value will be the snapshot value if one is available or the
 /// base property value if it is not; otherise this value will be the
 /// value returned by the previous animation in the chain with an
 /// animationClock that is not Stopped.
 /// </param>
 /// <param name="defaultDestinationValue">
 /// This value is the suggested destination value provided to the animation
 /// to be used if the animation does not have its own concept of an
 /// end value. This value will be the base value if the animation is
 /// in the first composition layer of animations on a property;
 /// otherwise this value will be the output value from the previous
 /// composition layer of animations for the property.
 /// </param>
 /// <param name="animationClock">
 /// This is the animationClock which can generate the CurrentTime or
 /// CurrentProgress value to be used by the animation to generate its
 /// output value.
 /// </param>
 /// <returns>
 /// The value this animation believes should be the current value for the property.
 /// </returns>
 protected abstract Single GetCurrentValueCore(Single defaultOriginValue, Single defaultDestinationValue, AnimationClock animationClock);
Beispiel #41
0
 public override sealed object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
 {
     return(GetCurrentValue((long)defaultOriginValue, (long)defaultDestinationValue, animationClock));
 }
Beispiel #42
0
 protected override Decimal GetCurrentValueCore(Decimal defaultOriginValue, Decimal defaultDestinationValue, AnimationClock animationClock)
 {
     throw new NotImplementedException();
 }
 public byte GetCurrentValue(byte defaultOriginValue, byte defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(byte));
 }
 protected abstract byte GetCurrentValueCore(byte defaultOriginValue, byte defaultDestinationValue, AnimationClock animationClock);
 public sealed override Object GetCurrentValue(Object defaultOriginValue, Object defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(Object));
 }
        /// <summary>
        /// Calculates the value this animation believes should be the current value for the property.
        /// </summary>
        /// <param name="defaultOriginValue">
        /// This value is the suggested origin value provided to the animation
        /// to be used if the animation does not have its own concept of a
        /// start value. If this animation is the first in a composition chain
        /// this value will be the snapshot value if one is available or the
        /// base property value if it is not; otherise this value will be the
        /// value returned by the previous animation in the chain with an
        /// animationClock that is not Stopped.
        /// </param>
        /// <param name="defaultDestinationValue">
        /// This value is the suggested destination value provided to the animation
        /// to be used if the animation does not have its own concept of an
        /// end value. This value will be the base value if the animation is
        /// in the first composition layer of animations on a property;
        /// otherwise this value will be the output value from the previous
        /// composition layer of animations for the property.
        /// </param>
        /// <param name="animationClock">
        /// This is the animationClock which can generate the CurrentTime or
        /// CurrentProgress value to be used by the animation to generate its
        /// output value.
        /// </param>
        /// <returns>
        /// The value this animation believes should be the current value for the property.
        /// </returns>
        public Single GetCurrentValue(Single defaultOriginValue, Single defaultDestinationValue, AnimationClock animationClock)
        {
            ReadPreamble();

            if (animationClock == null)
            {
                throw new ArgumentNullException("animationClock");
            }

            // We check for null above but presharp doesn't notice so we suppress the
            // warning here.

            #pragma warning suppress 6506
            if (animationClock.CurrentState == ClockState.Stopped)
            {
                return(defaultDestinationValue);
            }

            /*
             * if (!AnimatedTypeHelpers.IsValidAnimationValueSingle(defaultDestinationValue))
             * {
             *  throw new ArgumentException(
             *      SR.Get(
             *          SRID.Animation_InvalidBaseValue,
             *          defaultDestinationValue,
             *          defaultDestinationValue.GetType(),
             *          GetType()),
             *          "defaultDestinationValue");
             * }
             */

            return(GetCurrentValueCore(defaultOriginValue, defaultDestinationValue, animationClock));
        }
 public short GetCurrentValue(short defaultOriginValue, short defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(short));
 }
 protected abstract System.Windows.Media.Matrix GetCurrentValueCore(System.Windows.Media.Matrix defaultOriginValue, System.Windows.Media.Matrix defaultDestinationValue, AnimationClock animationClock);
Beispiel #49
0
 public string GetCurrentValue(string defaultOriginValue, string defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(string));
 }
Beispiel #50
0
 public double GetCurrentValue(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock)
 {
     throw new NotImplementedException();
 }
 protected sealed override System.Windows.Point GetCurrentValueCore(System.Windows.Point defaultOriginValue, System.Windows.Point defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(System.Windows.Point));
 }
        /// <summary>
        /// Calculates the value this animation believes should be the current value for the property.
        /// </summary>
        /// <param name="defaultOriginValue">
        /// This value is the suggested origin value provided to the animation
        /// to be used if the animation does not have its own concept of a
        /// start value. If this animation is the first in a composition chain
        /// this value will be the snapshot value if one is available or the
        /// base property value if it is not; otherise this value will be the
        /// value returned by the previous animation in the chain with an
        /// animationClock that is not Stopped.
        /// </param>
        /// <param name="defaultDestinationValue">
        /// This value is the suggested destination value provided to the animation
        /// to be used if the animation does not have its own concept of an
        /// end value. This value will be the base value if the animation is
        /// in the first composition layer of animations on a property;
        /// otherwise this value will be the output value from the previous
        /// composition layer of animations for the property.
        /// </param>
        /// <param name="animationClock">
        /// This is the animationClock which can generate the CurrentTime or
        /// CurrentProgress value to be used by the animation to generate its
        /// output value.
        /// </param>
        /// <returns>
        /// The value this animation believes should be the current value for the property.
        /// </returns>
        protected override Rotation3D GetCurrentValueCore(Rotation3D defaultOriginValue, Rotation3D defaultDestinationValue, AnimationClock animationClock)
        {
            Debug.Assert(animationClock.CurrentState != ClockState.Stopped);

            if (!_isAnimationFunctionValid)
            {
                ValidateAnimationFunction();
            }

            double progress = animationClock.CurrentProgress.Value;

            IEasingFunction easingFunction = EasingFunction;

            if (easingFunction != null)
            {
                progress = easingFunction.Ease(progress);
            }

            Rotation3D from        = Rotation3D.Identity;
            Rotation3D to          = Rotation3D.Identity;
            Rotation3D accumulated = Rotation3D.Identity;
            Rotation3D foundation  = Rotation3D.Identity;

            // need to validate the default origin and destination values if
            // the animation uses them as the from, to, or foundation values
            bool validateOrigin      = false;
            bool validateDestination = false;

            switch (_animationType)
            {
            case AnimationType.Automatic:

                from = defaultOriginValue;
                to   = defaultDestinationValue;

                validateOrigin      = true;
                validateDestination = true;

                break;

            case AnimationType.From:

                from = _keyValues[0];
                to   = defaultDestinationValue;

                validateDestination = true;

                break;

            case AnimationType.To:

                from = defaultOriginValue;
                to   = _keyValues[0];

                validateOrigin = true;

                break;

            case AnimationType.By:

                // According to the SMIL specification, a By animation is
                // always additive.  But we don't force this so that a
                // user can re-use a By animation and have it replace the
                // animations that precede it in the list without having
                // to manually set the From value to the base value.

                to         = _keyValues[0];
                foundation = defaultOriginValue;

                validateOrigin = true;

                break;

            case AnimationType.FromTo:

                from = _keyValues[0];
                to   = _keyValues[1];

                if (IsAdditive)
                {
                    foundation     = defaultOriginValue;
                    validateOrigin = true;
                }

                break;

            case AnimationType.FromBy:

                from = _keyValues[0];
                to   = AnimatedTypeHelpers.AddRotation3D(_keyValues[0], _keyValues[1]);

                if (IsAdditive)
                {
                    foundation     = defaultOriginValue;
                    validateOrigin = true;
                }

                break;

            default:

                Debug.Fail("Unknown animation type.");

                break;
            }

            if (validateOrigin &&
                !AnimatedTypeHelpers.IsValidAnimationValueRotation3D(defaultOriginValue))
            {
                throw new InvalidOperationException(
                          SR.Get(
                              SRID.Animation_Invalid_DefaultValue,
                              this.GetType(),
                              "origin",
                              defaultOriginValue.ToString(CultureInfo.InvariantCulture)));
            }

            if (validateDestination &&
                !AnimatedTypeHelpers.IsValidAnimationValueRotation3D(defaultDestinationValue))
            {
                throw new InvalidOperationException(
                          SR.Get(
                              SRID.Animation_Invalid_DefaultValue,
                              this.GetType(),
                              "destination",
                              defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));
            }


            if (IsCumulative)
            {
                double currentRepeat = (double)(animationClock.CurrentIteration - 1);

                if (currentRepeat > 0.0)
                {
                    Rotation3D accumulator = AnimatedTypeHelpers.SubtractRotation3D(to, from);

                    accumulated = AnimatedTypeHelpers.ScaleRotation3D(accumulator, currentRepeat);
                }
            }

            // return foundation + accumulated + from + ((to - from) * progress)

            return(AnimatedTypeHelpers.AddRotation3D(
                       foundation,
                       AnimatedTypeHelpers.AddRotation3D(
                           accumulated,
                           AnimatedTypeHelpers.InterpolateRotation3D(from, to, progress))));
        }
 public System.Windows.Media.Matrix GetCurrentValue(System.Windows.Media.Matrix defaultOriginValue, System.Windows.Media.Matrix defaultDestinationValue, AnimationClock animationClock)
 {
     return(default(System.Windows.Media.Matrix));
 }
Beispiel #54
0
 /// <summary>
 /// Calculates the value this animation believes should be the current value for the property.
 /// </summary>
 /// <param name="defaultOriginValue">
 /// This value is the suggested origin value provided to the animation
 /// to be used if the animation does not have its own concept of a
 /// start value. If this animation is the first in a composition chain
 /// this value will be the snapshot value if one is available or the
 /// base property value if it is not; otherise this value will be the
 /// value returned by the previous animation in the chain with an
 /// animationClock that is not Stopped.
 /// </param>
 /// <param name="defaultDestinationValue">
 /// This value is the suggested destination value provided to the animation
 /// to be used if the animation does not have its own concept of an
 /// end value. This value will be the base value if the animation is
 /// in the first composition layer of animations on a property;
 /// otherwise this value will be the output value from the previous
 /// composition layer of animations for the property.
 /// </param>
 /// <param name="animationClock">
 /// This is the animationClock which can generate the CurrentTime or
 /// CurrentProgress value to be used by the animation to generate its
 /// output value.
 /// </param>
 /// <returns>
 /// The value this animation believes should be the current value for the property.
 /// </returns>
 protected abstract Int16 GetCurrentValueCore(Int16 defaultOriginValue, Int16 defaultDestinationValue, AnimationClock animationClock);
Beispiel #55
0
 protected abstract double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock);
Beispiel #56
0
 /// <summary>
 /// Applies an AnimationClock to a DepencencyProperty which will
 /// replace the current animations on the property using the snapshot
 /// and replace HandoffBehavior.
 /// </summary>
 /// <param name="dp">
 /// The DependencyProperty to animate.
 /// </param>
 /// <param name="clock">
 /// The AnimationClock that will animate the property. If this is null
 /// then all animations will be removed from the property.
 /// </param>
 public void ApplyAnimationClock(
     DependencyProperty dp,
     AnimationClock clock)
 {
     ApplyAnimationClock(dp, clock, HandoffBehavior.SnapshotAndReplace);
 }
Beispiel #57
0
 /// <summary>
 /// Calculates the value this animation believes should be the current value for the property.
 /// </summary>
 /// <param name="defaultOriginValue">
 /// This value is the suggested origin value provided to the animation
 /// to be used if the animation does not have its own concept of a
 /// start value. If this animation is the first in a composition chain
 /// this value will be the snapshot value if one is available or the
 /// base property value if it is not; otherise this value will be the
 /// value returned by the previous animation in the chain with an
 /// animationClock that is not Stopped.
 /// </param>
 /// <param name="defaultDestinationValue">
 /// This value is the suggested destination value provided to the animation
 /// to be used if the animation does not have its own concept of an
 /// end value. This value will be the base value if the animation is
 /// in the first composition layer of animations on a property;
 /// otherwise this value will be the output value from the previous
 /// composition layer of animations for the property.
 /// </param>
 /// <param name="animationClock">
 /// This is the animationClock which can generate the CurrentTime or
 /// CurrentProgress value to be used by the animation to generate its
 /// output value.
 /// </param>
 /// <returns>
 /// The value this animation believes should be the current value for the property.
 /// </returns>
 protected abstract Rotation3D GetCurrentValueCore(Rotation3D defaultOriginValue, Rotation3D defaultDestinationValue, AnimationClock animationClock);
Beispiel #58
0
        /// <summary>
        /// Calculates the value of the animation at the current time.
        /// </summary>
        public override object GetCurrentValue(object defaultOriginValue, object baseValue, System.Windows.Media.Animation.AnimationClock animClock)
        {
            // return discrete value ...
            int index = (int)Math.Floor((double)(animClock.CurrentProgress * (_values.Length)));

            return(_values[(index < _values.Length) ? index : _values.Length - 1]);
        }
Beispiel #59
0
 protected abstract long GetCurrentValueCore(long defaultOriginValue, long defaultDestinationValue, AnimationClock animationClock);
 /// <summary>
 /// Calculates the value this animation believes should be the current value for the property.
 /// </summary>
 /// <param name="defaultOriginValue">
 /// This value is the suggested origin value provided to the animation
 /// to be used if the animation does not have its own concept of a
 /// start value. If this animation is the first in a composition chain
 /// this value will be the snapshot value if one is available or the
 /// base property value if it is not; otherise this value will be the
 /// value returned by the previous animation in the chain with an
 /// animationClock that is not Stopped.
 /// </param>
 /// <param name="defaultDestinationValue">
 /// This value is the suggested destination value provided to the animation
 /// to be used if the animation does not have its own concept of an
 /// end value. This value will be the base value if the animation is
 /// in the first composition layer of animations on a property;
 /// otherwise this value will be the output value from the previous
 /// composition layer of animations for the property.
 /// </param>
 /// <param name="animationClock">
 /// This is the animationClock which can generate the CurrentTime or
 /// CurrentProgress value to be used by the animation to generate its
 /// output value.
 /// </param>
 /// <returns>
 /// The value this animation believes should be the current value for the property.
 /// </returns>
 public override sealed object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
 {
     // Verify that object arguments are non-null since we are a value type
     if (defaultOriginValue == null)
     {
         throw new ArgumentNullException("defaultOriginValue");
     }
     if (defaultDestinationValue == null)
     {
         throw new ArgumentNullException("defaultDestinationValue");
     }
     return(GetCurrentValue((Single)defaultOriginValue, (Single)defaultDestinationValue, animationClock));
 }