예제 #1
0
 public void PopupNotification(OverlayNotification notification)
 {
     if (Settings.Default.EnableOverlay)
     {
         try
         {
             Dispatcher.Invoke(() =>
             {
                 if (notification.UniqueID != null &&
                     StackNotifications.GetChildObjects()
                     .Any(
                         toast => (toast as OverlayToast)?.BaseNotification.UniqueID == notification.UniqueID))
                 {
                     return;
                 }
                 var popupNotification = new OverlayToast(notification);
                 popupNotification.NotificationCompleted += (sender, args) =>
                 {
                     StackNotifications.Children.Remove(popupNotification);
                     popupNotification = null;
                 };
                 StackNotifications.Children.Add(popupNotification);
             });
         }
         catch (ThreadAbortException)
         {
         }
     }
예제 #2
0
        public OverlayToast(OverlayNotification notification)
        {
            BaseNotification = notification;
            _duration        = notification.Duration;
            _fadeIn          = notification.FadeIn;
            _fadeOut         = notification.FadeOut;

            InitializeComponent();
            if (notification.Image != null)
            {
                ImageIcon.Source = notification.Image;
            }
            else
            {
                ImageIcon.Source = OverlayIcons.Random();
            }

            NotificationHeader.Text = notification.Header;
            NotificationText.Text   = notification.Content;
            UpdateLayout();
            Dispatcher.Invoke(FadeIn);
            new Thread(() =>
            {
                Thread.Sleep(_duration);
                try
                {
                    Dispatcher.Invoke(FadeOut);
                } catch { }
            }).Start();
        }
예제 #3
0
        public void PopupNotification(OverlayNotification notification)
        {
            if (!IsRunning)
            {
                return;
            }

            Log.WriteLine($"Show notification: {notification.Header}: {notification.Content}");
            _overlay.PopupNotification(notification);
        }