Exemple #1
0
        private void TransitionTo(MatToastState state)
        {
            Timer.Stop();
            State = state;

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

            case MatToastState.Visible:
                if (Toast.Options.RequireInteraction)
                {
                    TransitionState = MatToastTransitionState.ForRequiredInteraction(Toast.Options.MaximumOpacity);
                    Toast.InvokeOnUpdate();
                    return;
                }
                else if (Toast.Options.VisibleStateDuration < 0)
                {
                    TransitionTo(MatToastState.Hiding);
                }
                else
                {
                    Timer.Start(Toast.Options.VisibleStateDuration);
                }

                break;

            case MatToastState.Hiding:
                if (Toast.Options.HideTransitionDuration <= 0)
                {
                    Toast.InvokeOnClose();
                    return;
                }
                else
                {
                    Timer.Start(Toast.Options.HideTransitionDuration);
                }

                break;

            case MatToastState.MouseOver:
                break;
            }

            UpdateTransitionState();
            Toast.InvokeOnUpdate();
        }
Exemple #2
0
 private void UpdateTransitionState()
 {
     TransitionState = State == MatToastState.Visible && Toast.Options.RequireInteraction
         ? MatToastTransitionState.ForRequiredInteraction(Toast.Options.MaximumOpacity)
         : new MatToastTransitionState(Timer, Toast.Options.MaximumOpacity);
 }