private void FetchProperties() { if (_animation.SpeedRatio < 0d) { throw new ArgumentOutOfRangeException("SpeedRatio value should not be negative."); } if (_animation.Duration.TotalSeconds <= 0) { throw new InvalidOperationException("Duration value cannot be negative or zero."); } _easeFunc = _animation.Easing; _speedRatioConv = 1d / _animation.SpeedRatio; _initialDelay = _animation.Delay; _duration = _animation.Duration; _iterationDelay = _animation.DelayBetweenIterations; if (_animation.IterationCount.RepeatType == IterationType.Many) { _iterationCount = _animation.IterationCount.Value; } else { _iterationCount = null; } _playbackDirection = _animation.PlaybackDirection; _fillMode = _animation.FillMode; }
public AnimationInstance(Animation animation, Animatable control, Animator <T> animator, IClock baseClock, Action OnComplete, Func <double, T, T> Interpolator) { if (animation.SpeedRatio <= 0) { throw new InvalidOperationException("Speed ratio cannot be negative or zero."); } if (animation.Duration.TotalSeconds <= 0) { throw new InvalidOperationException("Duration cannot be negative or zero."); } _parent = animator; _easeFunc = animation.Easing; _targetControl = control; _neutralValue = (T)_targetControl.GetValue(_parent.Property); _speedRatio = animation.SpeedRatio; _delay = animation.Delay; _duration = animation.Duration; _iterationDelay = animation.DelayBetweenIterations; switch (animation.RepeatCount.RepeatType) { case RepeatType.None: _repeatCount = 1; break; case RepeatType.Loop: _isLooping = true; break; case RepeatType.Repeat: _repeatCount = (long)animation.RepeatCount.Value; break; } _animationDirection = animation.PlaybackDirection; _fillMode = animation.FillMode; _onCompleteAction = OnComplete; _interpolator = Interpolator; _baseClock = baseClock; }
public override object ConvertFrom(ITypeDescriptorContext?context, CultureInfo?culture, object value) { return(Easing.Parse((string)value)); }