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(); }); }
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); }; }
public void Remove(ServiceWorkers.NotificationItem item) => worker.Remove(item);
public void Add(ServiceWorkers.NotificationItem item) => worker.Add(item);
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)); })); } }
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; }