Beispiel #1
0
        private void Display_MouseLeave(object sender, EventArgs e)
        {
            _mouseIn = false;
            Animation animName = _opacityFallbackType == OpacityFallbackType.Normal
                ? Animation.FadeOut
                : Animation.FadeOutFull;

            StartAnimation(animName, _mouseOverSavedCallback);
            _mouseOverSavedCallback = null;
        }
Beispiel #2
0
        public void StartAnimation(Animation animName, OnAnimationStopDelegate actionAfterAnimation = null,
                                   bool forceAnimation = false)
        {
            lock (_animationLock)
            {
                if (_curAnimationName != animName)
                {
                    _onAnimationStopEvent = null;
                    _fadeAnimation        = null;
                }

                if (!_mouseIn)
                {
                    _onAnimationStopEvent = actionAfterAnimation;
                }
                else if (!forceAnimation)
                {
                    _mouseOverSavedCallback = actionAfterAnimation;
                    return;
                }

                if (_animationTimer.Enabled)
                {
                    _animationTimer.Stop();
                }

                switch (animName)
                {
                case Animation.FadeInNormal:
                    _fadeAnimation       = new Fade(_display.MyOpacity, _normalOpacity.Value, 100 /*fadeLength.Value*/);
                    _opacityFallbackType = OpacityFallbackType.Normal;
                    break;

                case Animation.FadeInOver:
                    _fadeAnimation = new Fade(_display.MyOpacity, _overOpacity.Value, 100 /*fadeLength.Value*/);
                    break;

                case Animation.FadeOut:
                    _fadeAnimation       = new Fade(_display.MyOpacity, _normalOpacity.Value, 400 /*fadeLength.Value*/);
                    _opacityFallbackType = OpacityFallbackType.Normal;
                    break;

                case Animation.FadeOutFull:
                    _fadeAnimation       = new Fade(_display.MyOpacity, 0, 400 /*fadeLength.Value*/);
                    _opacityFallbackType = OpacityFallbackType.Transparent;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(animName), animName, null);
                }
                _curAnimationName = animName;

                _animationTimer.Start();
            }
        }
Beispiel #3
0
        private void AnimationTimer_Tick(object sender, EventArgs e)
        {
            int prevOpacity = _display.MyOpacity;

            lock (_animationLock)
            {
                if (_fadeAnimation != null)
                {
                    _display.MyOpacity = _fadeAnimation.GetOpacity();
                    if (_fadeAnimation.Done())
                    {
                        _animationTimer.Stop();
                        _fadeAnimation = null;
                        _onAnimationStopEvent?.Invoke();
                        _onAnimationStopEvent = null;
                    }
                }
            }
            if (prevOpacity != _display.MyOpacity)
            {
                Main.GetInstance().RequestRedraw(true);
            }
        }
Beispiel #4
0
 private void Display_MouseEnter(object sender, EventArgs e)
 {
     _mouseOverSavedCallback = _onAnimationStopEvent;
     _mouseIn = true;
     StartAnimation(Animation.FadeInOver, forceAnimation: true);
 }