Exemple #1
0
        public void RegisterWindowToaster(Toaster toaster, bool removeWhenEmpty = false)
        {
            if (_toasters.ContainsKey(toaster.Window))
            {
                throw new InvalidOperationException("There is already a toaster for this window.");
            }

            _toasters.Add(toaster.Window, toaster);
            if (removeWhenEmpty)
            {
                toaster.IsEmpty += (s, e) => _toasters.Remove(toaster.Window);
            }
        }
Exemple #2
0
 public ToastAdorner Show(
     string message,
     string title,
     Window window,
     ToastAdornerSettings toastSettings = null,
     UIElement toastView = null,
     Action clickAction  = null)
 {
     if (!_toasters.ContainsKey(window))
     {
         var toaster = new Toaster(window, _settings, _getDefaultView, _defaultToastSettings);
         toaster.IsEmpty += (s, e) => _toasters.Remove(window);
         _toasters.Add(window, toaster);
     }
     return(_toasters[window].Show(message, title, toastSettings, toastView, clickAction));
 }