Ejemplo n.º 1
0
        private void TransitionTo(ToastState state)
        {
            Timer.Stop();
            State = state;

            switch (state)
            {
            case ToastState.Showing:
                if (Options.ShowTransitionDuration <= 0)
                {
                    TransitionTo(ToastState.Visible);
                }
                else
                {
                    Timer.Start(Options.ShowTransitionDuration);
                }
                break;

            case ToastState.Visible:
                if (Options.RequireInteraction)
                {
                    TransitionState = TransitionState.ForRequiredInteraction(Options.MaximumOpacity);
                    OnUpdate?.Invoke();
                    return;
                }
                else if (Options.VisibleStateDuration < 0)
                {
                    TransitionTo(ToastState.Hiding);
                }
                else
                {
                    Timer.Start(Options.VisibleStateDuration);
                }
                break;

            case ToastState.Hiding:
                if (Options.HideTransitionDuration <= 0)
                {
                    OnClose?.Invoke(this);
                    return;
                }
                else
                {
                    Timer.Start(Options.HideTransitionDuration);
                }
                break;

            case ToastState.MouseOver:
                break;
            }

            UpdateTransitionState();
            OnUpdate?.Invoke();
        }
Ejemplo n.º 2
0
 private void UpdateTransitionState()
 {
     TransitionState = State == ToastState.Visible && Options.RequireInteraction
         ? TransitionState.ForRequiredInteraction(Options.MaximumOpacity)
         : new TransitionState(Timer, Options.MaximumOpacity);
 }