private void Notification_OnReadStatusChanged(object sender, EventArgs e) { var notif = (sender as MenuNotificationViewModel).MenuNotification; if (repository.Contains(notif)) { repository.Remove(notif); } NotificationCollectionChanged?.Invoke(this, new NotificationCollectionChangedEventArgs(NotificationCollectionChangedAction.ReadStatusChange, notif)); }
public void Remove(MenuNotificationViewModel notificationVm) { if (notificationVm == null) { throw new ArgumentNullException(nameof(notificationVm)); } notifications.Remove(notificationVm); repository.Remove(notificationVm.MenuNotification); NotificationCollectionChanged?.Invoke(this, new NotificationCollectionChangedEventArgs(NotificationCollectionChangedAction.Remove, notificationVm.MenuNotification)); }
public void Add(MenuNotification notification) { if (notification == null) { throw new ArgumentNullException(nameof(notification)); } MenuNotificationViewModel notificationVm = new MenuNotificationViewModel(notification); notificationVm.RequestClose += (s, e) => Remove(s as MenuNotificationViewModel); notificationVm.Notification_ReadStatusChanged += Notification_OnReadStatusChanged; Program.MainWindow.Invoke(() => { notifications.Add(notificationVm); }); //notification.IsDirty = true; NotificationCollectionChanged?.Invoke(this, new NotificationCollectionChangedEventArgs(NotificationCollectionChangedAction.Add, notification)); }