Exemplo n.º 1
0
        // Shows a notification based on NotificationEventArgs supplied by the requester.
        public void Show(INotificationRequester sender, NotificationEventArgs e)
        {
            if (!GlobalSettings.Instance.NotificationsEnabled) return;

            this._mainForm.AsyncInvokeHandler(() =>
            {
                if (!this._gotActiveNotification) // if there exists no active notifications.
                {
                    this._trayIcon.Tag = sender; // store the requester in tag, so that if baloon is clicked we can notify the requester back.
                    this._trayIcon.ShowBalloonTip(BalloonDuration, e.Title, e.Text, e.Icon);
                    this._gotActiveNotification = true;

                    if(GlobalSettings.Instance.NotificationSoundsEnabled) NotificationSound.Instance.Play();

                    this._notificationTimer = new System.Timers.Timer(BalloonDuration);
                    this._notificationTimer.Elapsed += BalloonDisappearTimer; // setup a timer so that we can reset oru flags when the balloon disappears.
                    this._notificationTimer.Enabled = true;
                }
                else // if there exists an active notification, add the new notification to archived notifications list.
                {
                    ArchivedNotifications.Instance.Queue.Add(new ArchivedNotification(sender, e));
                    if(!this._archivedNotificationsIcon.Visible) this._archivedNotificationsIcon.Visible = true; // set archived notifications icon on main window visible.
                }
            });
        }
Exemplo n.º 2
0
 public ArchivedNotification(INotificationRequester item, NotificationEventArgs e)
 {
     this.Item = item;
     this.Args = e;
 }