public void PushNotification(INotification notification)
        {
            if (_disposed)
            {
                Debug.WriteLine($"Warn ToastNotifications {this}.{nameof(PushNotification)} is already disposed");
                return;
            }

            if (_interval.IsRunning == false)
            {
                TimerStart();
            }

            if (_notifications.Count == _maximumNotificationCount)
            {
                if (_notificationsPending == null)
                {
                    _notificationsPending = new Queue <INotification>();
                }
                _notificationsPending.Enqueue(notification);
                return;
            }

            int numberOfNotificationsToClose = Math.Max(_notifications.Count - _maximumNotificationCount + 1, 0);

            var notificationsToRemove = _notifications
                                        .OrderBy(x => x.Key)
                                        .Take(numberOfNotificationsToClose)
                                        .Select(x => x.Value)
                                        .ToList();

            foreach (var n in notificationsToRemove)
            {
                CloseNotification(n.Notification);
            }

            _notifications.Add(notification);
            RequestShowNotification(new ShowNotificationEventArgs(notification));
        }
Exemplo n.º 2
0
        public void PushNotification(INotification notification)
        {
            if (_disposed)
            {
                Debug.WriteLine($"Warn ToastNotifications {this}.{nameof(PushNotification)} is already disposed");
                return;
            }

            int numberOfNotificationsToClose = Math.Max(_notifications.Count - _maximumNotificationCount, 0);

            var notificationsToRemove = _notifications
                                        .OrderBy(x => x.Key)
                                        .Take(numberOfNotificationsToClose)
                                        .Select(x => x.Value)
                                        .ToList();

            foreach (var n in notificationsToRemove)
            {
                CloseNotification(n.Notification);
            }

            _notifications.Add(notification);
            RequestShowNotification(new ShowNotificationEventArgs(notification));
        }