示例#1
0
        /// <inheritdoc/>
        public virtual IDisposable Apply(Animation animation, Animatable control, IClock clock, IObservable <bool> match, Action onComplete)
        {
            if (!_isVerifiedAndConverted)
            {
                VerifyConvertKeyFrames();
            }

            return(match
                   .Where(p => p)
                   .Subscribe(_ =>
            {
                var timerObs = RunKeyFrames(animation, control, clock, onComplete);
            }));
        }
示例#2
0
        /// <inheritdocs/>
        public IDisposable Apply(Animatable control, IObservable <bool> matchObs)
        {
            if (_isChildrenChanged)
            {
                InterpretKeyframes();
                _isChildrenChanged = false;
            }

            foreach (IAnimator keyframes in _animators)
            {
                _subscription.Add(keyframes.Apply(this, control, matchObs));
            }
            return(this);
        }
示例#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;
        }
示例#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;
        }
示例#5
0
        /// <inheritdocs/>
        public virtual IDisposable Apply(Animatable control, IClock clock, object oldValue, object newValue)
        {
            var transition = DoTransition(new TransitionInstance(clock, Delay, Duration), (T)oldValue, (T)newValue);

            return(control.Bind <T>((AvaloniaProperty <T>)Property, transition, Data.BindingPriority.Animation));
        }
示例#6
0
 public DisposeAnimationInstanceSubject(Animator <T> animator, Animation animation, Animatable control, IClock clock, Action onComplete)
 {
     this._animator   = animator;
     this._animation  = animation;
     this._control    = control;
     this._onComplete = onComplete;
     this._clock      = clock;
 }
示例#7
0
        /// <inheritdocs/>
        public virtual IDisposable Apply(Animatable control, object oldValue, object newValue)
        {
            var transition = DoTransition(Timing.GetTransitionsTimer(control, Duration, TimeSpan.Zero), (T)oldValue, (T)newValue).Select(p => (object)p);

            return(control.Bind(Property, transition, Data.BindingPriority.Animation));
        }
示例#8
0
        /// <summary>
        /// Runs the KeyFrames Animation.
        /// </summary>
        private IDisposable RunKeyFrames(Animation animation, Animatable control, Action onComplete)
        {
            var instance = new AnimationInstance <T>(animation, control, this, onComplete, DoInterpolation);

            return(control.Bind <T>((AvaloniaProperty <T>)Property, instance, BindingPriority.Animation));
        }