Exemplo n.º 1
0
 void HandleNotificationAdded(NotificationAdded notificationAdded)
 {
     if (NotificationsListBox.Items.Count == 0)
     {
         return;
     }
     NotificationsListBox.ScrollIntoView(NotificationsListBox.Items[NotificationsListBox.Items.Count - 1]);
 }
Exemplo n.º 2
0
        public void Add(INotification notification)
        {
            lock (_syncRoot)
            {
                if (_notifications.Count == MaximumNotificationCount)
                {
                    _notifications.RemoveAt(0);
                }

                _notifications.Add(notification);
            }

            NotificationAdded?.Invoke(notification);
        }
Exemplo n.º 3
0
        protected void OnNotificationAdded(object source, Notification notification)
        {
            //update database with new notification
            NotificationDAL notificationDal = new NotificationDAL {
                taskId = notification.Producer.ID,
                time   = notification.Time
            };

            INotificationRepository notificationRepo = notificationRepositoryFactory.New();

            notificationRepo.Add(notificationDal);

            ITaskItemRepository taskRepo = taskItemRepositoryFactory.New();
            List <TaskItemDAL>  tasks    = new List <TaskItemDAL>(taskRepo.GetAll());

            if (notification.Producer is TaskItem task)
            {
                //update the notifications producer in the database
                TaskItemDAL taskItemDAL = tasks.Find(t => t.id == task.ID);
                taskItemDAL.lastNotificationTime = task.LastNotificationTime;
                if (taskRepo.Update(taskItemDAL) == false)
                {
                    //could not update task in database
                }

                //create DTO to invoke NotificationAdded with
                NotificationDTO dto = new NotificationDTO()
                {
                    TaskId = task.ID,
                    Time   = notification.Time,
                    Title  = notification.Producer.Title,
                    R      = task.Colour.R,
                    G      = task.Colour.G,
                    B      = task.Colour.B
                };

                //invoked event delegates
                NotificationAdded?.Invoke(source, dto);
            }

            taskRepo.Save();
            notificationRepo.Save();
        }
Exemplo n.º 4
0
        private void RaiseNotificationEvent(NotificationAttributeCollection attributes)
        {
            NotificationSourceData sourceData = Notifications[attributes.NotificationUID];

            switch (sourceData.EventId)
            {
            case EventID.NotificationAdded:
                NotificationAdded?.Invoke(this, new AppleNotificationEventArgs(sourceData, attributes));
                break;

            case EventID.NotificationModified:
                NotificationModified?.Invoke(this, new AppleNotificationEventArgs(sourceData, attributes));
                break;

            case EventID.NotificationRemoved:
                // Has been handled, but just in case..
                NotificationRemoved?.Invoke(this, sourceData);
                break;
            }

            // Remove the notification from the list
            Notifications.Remove(sourceData.NotificationUID);
        }
Exemplo n.º 5
0
 protected void OnNotificationAdded(Notification notification)
 {
     NotificationAdded?.Invoke(this, notification);
 }