示例#1
0
 public void AddToast(ToastOptions options, string title, string message)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options), "The ToastOptions object cannot be null.");
     }
     options.Display = true;
     options.Title   = title ?? string.Empty;
     options.Message = message ?? string.Empty;
     if (PreventDuplicates)
     {
         foreach (var option in Options)
         {
             if (options.Equals(option))
             {
                 return;
             }
         }
     }
     if (NewestOnTop)
     {
         Options.Insert(0, options);
     }
     else
     {
         Options.Add(options);
     }
     StateHasChanged();
 }
示例#2
0
 public void AddToast(ToastOptions options, string title, string message)
 {
     OnAddToast?.Invoke(options, title, message);
     if (options.TimeOut > 0)
     {
         StartCountdown(options);
     }
 }
示例#3
0
 public static ToastOptions CreateToastOptions(ToastOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     return(new ToastOptions(options));
 }
示例#4
0
        public void AddSuccessToast(string title, string message)
        {
            var options = new ToastOptions(Configuration.ToastOptions)
            {
                IconClass = "toast-success"
            };

            AddToast(options, title, message);
        }
示例#5
0
        public void AddWarningToast(string title, string message)
        {
            var options = new ToastOptions(Configuration.ToastOptions)
            {
                IconClass = "toast-warning"
            };

            AddToast(options, title, message);
        }
示例#6
0
 private void SetCountdown(ToastOptions options)
 {
     if (Countdown == null)
     {
         Countdown           = new Timer(options.TimeOut);
         Countdown.Elapsed  += RemoveToast;
         Countdown.AutoReset = false;
     }
 }
示例#7
0
 public void RemoveToast(ToastOptions options)
 {
     if (options != null)
     {
         InvokeAsync(() =>
         {
             // change the CSS to fadeOut, slideDown or hide here, call StateHasChanged.  Use timer, can set ease duration in Toast.cs
             Options.Remove(options);
             StateHasChanged();
         });
     }
 }
示例#8
0
 private void StartCountdown(ToastOptions options)
 {
     SetCountdown(options);
     Stack.Push(options);
     if (Countdown.Enabled)
     {
         Countdown.Stop();
         Countdown.Start();
     }
     else
     {
         Countdown.Start();
     }
 }
示例#9
0
        internal ToastOptions(ToastOptions options)
        {
            this.CloseButton      = options.CloseButton;
            this.CloseButtonClass = options.CloseButtonClass;
            this.Display          = options.Display;
            this.FirstRendering   = options.FirstRendering;
            this.HideClass        = options.HideClass;
            this.IconClass        = options.IconClass;
            this.Message          = options.Message;
            this.MessageClass     = options.MessageClass;
            this.RTL          = options.RTL;
            this.ShowClass    = options.ShowClass;
            this.TapToDismiss = options.TapToDismiss;
            this.TimeOut      = options.TimeOut;
            this.Title        = options.Title;
            this.TitleClass   = options.TitleClass;
            this.ToastClass   = options.ToastClass;
//            this.Type = options.Type;
        }