private void UpdateNeutralValue()
        {
            var property  = _animator.Property;
            var baseValue = _targetControl.GetBaseValue(property, BindingPriority.LocalValue);

            _neutralValue = baseValue != AvaloniaProperty.UnsetValue ?
                            (T)baseValue : (T)_targetControl.GetValue(property);
        }
Ejemplo n.º 2
0
        public AnimationInstance(Animation animation, Animatable control, Animator <T> animator, IClock baseClock, Action OnComplete, Func <double, T, T> Interpolator)
        {
            _animator         = animator;
            _animation        = animation;
            _targetControl    = control;
            _onCompleteAction = OnComplete;
            _interpolator     = Interpolator;
            _baseClock        = baseClock;
            _neutralValue     = (T)_targetControl.GetValue(_animator.Property);

            FetchProperties();
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        public AnimatorStateMachine(Animation animation, Animatable control, Animator <T> animator, Action onComplete)
        {
            _parent          = animator;
            _targetAnimation = animation;
            _targetControl   = control;
            _neutralValue    = (T)_targetControl.GetValue(_parent.Property);

            _delayTotalFrameCount    = (ulong)(animation.Delay.Ticks / Timing.FrameTick.Ticks);
            _durationTotalFrameCount = (ulong)(animation.Duration.Ticks / Timing.FrameTick.Ticks);

            switch (animation.RepeatCount.RepeatType)
            {
            case RepeatType.Loop:
                _isLooping          = true;
                _checkLoopAndRepeat = true;
                break;

            case RepeatType.Repeat:
                _isRepeating        = true;
                _checkLoopAndRepeat = true;
                _repeatCount        = animation.RepeatCount.Value;
                break;
            }

            _isReversed         = (animation.PlaybackDirection & PlaybackDirection.Reverse) != 0;
            _animationDirection = _targetAnimation.PlaybackDirection;
            _fillMode           = _targetAnimation.FillMode;

            if (_durationTotalFrameCount > 0)
            {
                _currentState = KeyFramesStates.DoDelay;
            }
            else
            {
                _currentState = KeyFramesStates.DoRun;
            }
            _onComplete = onComplete;
        }