コード例 #1
0
        public void Show(string message, NotificationType type)
        {
            if (NotificationMessages.Any() == false)
            {
                InternalStartTimer();
                IsOpen = true;
            }

            if (MaximumNotificationCount != UnlimitedNotifications)
            {
                if (NotificationMessages.Count >= MaximumNotificationCount)
                {
                    int removeCount = (int)(NotificationMessages.Count - MaximumNotificationCount) + 1;

                    var itemsToRemove = NotificationMessages.OrderBy(x => x.CreateTime)
                                        .Take(removeCount)
                                        .Select(x => x.Id)
                                        .ToList();
                    foreach (var id in itemsToRemove)
                    {
                        Hide(id);
                    }
                }
            }

            NotificationMessages.Add(new NotificationViewModel
            {
                Message = message,
                Type    = type
            });
        }