public void ShutdownAll()
 {
     if (!ServiceWorkers.Any())
     {
         return;
     }
     ServiceWorkers.ToList().ForEach(svc =>
     {
         svc.Shutdown();
     });
 }
 public void HaltAll()
 {
     if (!ServiceWorkers.Any())
     {
         return;
     }
     ServiceWorkers.ToList().ForEach(svc =>
     {
         svc.Suspend();
     });
 }
 /// <summary>
 ///
 /// </summary>
 public void ResumeAll()
 {
     if (!ServiceWorkers.Any())
     {
         return;
     }
     ServiceWorkers.ToList().ForEach(svc =>
     {
         svc.Resume();
     });
 }
Exemplo n.º 4
0
 public NotificationViewModel(ServiceWorkers.NotificationItem notification)
 {
     if (notification == null)
         throw new ArgumentNullException(nameof(notification));
     Notification = notification;
     notification.PropertyChanged += (s, e) =>
     {
         if (e.PropertyName == nameof(notification.IconUrl))
             RaisePropertyChanged(() => HasIcon);
         if (e.PropertyName == nameof(notification.Message))
             RaisePropertyChanged(() => HasMessage);
     };
 }
Exemplo n.º 5
0
 public void Remove(ServiceWorkers.NotificationItem item) => worker.Remove(item);
Exemplo n.º 6
0
 public void Add(ServiceWorkers.NotificationItem item) => worker.Add(item);
Exemplo n.º 7
0
        private void OnNotificationsChanged(object sender, ServiceWorkers.NotificationItemEventArgs e)
        {
            if (e.Action == ServiceWorkers.NotificationListAction.Add)
            {
                RunUnderDispatcher(new Action(() => 
                    e.Items.Select(i => FromItem(i))
                        .ToList()
                        .ForEach(i => notifications.Add(i)))
                );
            }
            else if (e.Action == ServiceWorkers.NotificationListAction.Remove)
            {
                RunUnderDispatcher(new Action(() =>
                {
                    if (SelectedNotification != null && e.Items.Contains(SelectedNotification.Notification, ServiceWorkers.NotificationsWorker.GenericComparer))
                        SelectedNotification = null;

                    e.Items.Join(notifications, i => i, n => n.Notification, (i, n) => n, ServiceWorkers.NotificationsWorker.GenericComparer)
                         .ToList()
                         .ForEach(i => notifications.Remove(i));
                }));
            }
        }
Exemplo n.º 8
0
        private NotificationViewModel FromItem(ServiceWorkers.NotificationItem item)
        {
            var n = new NotificationViewModel(item);
            n.OnCloseClick += (s, e) => Remove(((NotificationViewModel)s).Notification);
            n.OnOpenClick += (s, e) => SelectedNotification = (NotificationViewModel)s;

            return n;
        }