Exemplo n.º 1
0
        public MatToast Add(string message, MatToastType type, string title, string icon, Action <MatToastOptions> configure)
        {
            if (string.IsNullOrEmpty(message))
            {
                return(null);
            }

            message = message.Trim();
            title   = string.IsNullOrEmpty(title) ? "" : title.Trim();

            if (Configuration.PreventDuplicates && ToastAlreadyPresent(message, title, type))
            {
                return(null);
            }

            var options = new MatToastOptions(type, Configuration);

            configure?.Invoke(options);

            var toast = new MatToast(message, title, icon, options);

            toast.OnClose += Remove;
            Toasts.Add(toast);

            OnToastsUpdated?.Invoke();

            return(toast);
        }
Exemplo n.º 2
0
        public void Add(ToastType type, string message, string title, Action <ToastOptions> configure)
        {
            if (message.IsEmpty())
            {
                return;
            }

            message = message.Trimmed();
            title   = title.Trimmed();

            var options = new ToastOptions(type, Configuration);

            configure?.Invoke(options);

            var toast = new Toast(title, message, options);

            ToastLock.EnterWriteLock();
            try
            {
                if (Configuration.PreventDuplicates && ToastAlreadyPresent(toast))
                {
                    return;
                }
                toast.OnClose += Remove;
                Toasts.Add(toast);
            }
            finally
            {
                ToastLock.ExitWriteLock();
            }

            OnToastsUpdated?.Invoke();
        }
Exemplo n.º 3
0
        public void Remove(Toast toast)
        {
            toast.OnClose -= Remove;
            Toasts.Remove(toast);

            OnToastsUpdated?.Invoke();
            toast.Dispose();
        }
Exemplo n.º 4
0
        public void Clear()
        {
            var toasts = Toasts;

            Toasts = new List <Toast>();
            OnToastsUpdated?.Invoke();
            DisposeToasts(toasts);
        }
Exemplo n.º 5
0
        public void Remove(string par1)
        {
            var item = Toasts.Where(x => x.Titel == par1).FirstOrDefault();

            Toasts.Remove(item);

            OnToastsUpdated?.Invoke();
        }
Exemplo n.º 6
0
        public void Add(string par1)
        {
            var t = new ToastItem();

            t.Titel = par1;
            Toasts.Add(t);

            OnToastsUpdated?.Invoke();
        }
Exemplo n.º 7
0
        public void Clear()
        {
            ToastLock.EnterWriteLock();
            try
            {
                RemoveAllToasts(Toasts);
            }
            finally
            {
                ToastLock.ExitWriteLock();
            }

            OnToastsUpdated?.Invoke();
        }
Exemplo n.º 8
0
        public void Remove(Toast toast)
        {
            toast.Dispose();
            toast.OnClose -= Remove;

            ToastLock.EnterWriteLock();
            try
            {
                var index = Toasts.IndexOf(toast);
                if (index < 0)
                {
                    return;
                }
                Toasts.RemoveAt(index);
            }
            finally
            {
                ToastLock.ExitWriteLock();
            }

            OnToastsUpdated?.Invoke();
        }
Exemplo n.º 9
0
 private void ConfigurationUpdated()
 {
     OnToastsUpdated?.Invoke();
 }