Example #1
0
        void Test(bool hasDelay)
        {
            var mockStatusUPdates = new Notification[]
            {
                new Notification(StatusSeverity.Fail, "fail"),
                new Notification(StatusSeverity.Info, "info"),
                new Notification(StatusSeverity.Warn, "warn"),
                new Notification(StatusSeverity.Success, "really long text with a lot of text alsdjfksjadfl;jkasdflkjs;dfjslkjfdskljdfklsj;dfljslkdfjskldfjlsjdfkljsdfjslkdjfkl"),
            };

            var statusFeedDelay = Observable.Create<Notification>(o =>
            {
                var els = new EventLoopScheduler();
                return mockStatusUPdates.ToObservable()//repoObjectsTree.StatusFeed
                    .ObserveOn(els)
                    .Do(x => els.Schedule(() => Thread.Sleep(5 * 1000)))
                    .Subscribe(o);
            });

            var observable = hasDelay
                    ? statusFeedDelay// this one adds them all at once
                    : mockStatusUPdates.ToObservable();// this on

            //observable
            //    .ObserveOn(this)
            //    .DelaySubscription(TimeSpan.FromSeconds(2))
            //    .Subscribe(notifier.Notify);
        }
 /// <summary>Occurs when a new notification has been published.</summary>
 /// <param name="notification">The new notification message.</param>
 void OnNewNotification(Notification notification)
 {
     if (popup != null)
     {
         popup.New(notification, GetPopupLocation());
     }
     Add(notification);
 }
 /// <summary>Updates the text and image for UI, and start expiration timer.</summary>
 void Update(Notification notification)
 {
     if (notification != null)
     {
         Notification = notification;
         Text = notification.Text;
         imgIcon.Image = notification.GetImage();
     }
     else
     {
         Text = string.Empty;
         imgIcon.Image = NotifierHelpers.blank;
     }
     Visible = true;
     hasExpired = false;
     StartExpiration(TimeSpan.FromSeconds(5));
 }
        /// <summary>Sets the current item to the specified <see cref="Notification"/>
        /// and updates the current index.</summary>
        void SetCurrent(Notification value, int index)
        {
            Current = value;
            iCurrent = index;

            if (index == 0)
            {// current element EQUALS newest element
                btnNewest.Enabled = false;
                btnNewer.Enabled = false;
                btnOlder.Enabled = true;
                btnOldest.Enabled = true;
            }
            else if (index == (notificationList.Count - 1))
            {// current element EQUALS oldest element
                btnNewest.Enabled = true;
                btnNewer.Enabled = true;
                btnOlder.Enabled = false;
                btnOldest.Enabled = false;
            }
        }
        /// <summary>Indicates that there is a new, incoming notification.</summary>
        public void New(Notification notificationView, Point point)
        {
            Location = point;
            Show();
            StartFadeIn();

            // "3 of 4"
            btnXofY.Text = string.Format(
                "{0} {1} {2}",
                iCurrent + 1,
                _of.Text,
                notificationList.Count);

            throw new NotImplementedException();
        }
 /// <summary>Publishes a notification.</summary>
 /// <param name="notification"><see cref="Notification"/> to publish.</param>
 public void Notify(Notification notification)
 {
     notification.Notifier = this;
     _notifications.OnNext(notification);
 }
 /// <summary>Adds a notification to the status feed.</summary>
 void Add(Notification notification)
 {
     nNotifications++;
     Update();
 }
 /// <summary>Publishes a notification.</summary>
 /// <param name="notification"><see cref="Notification"/> to publish.</param>
 public void Notify(Notification notification)
 {
     notification.Notifier = this;
     _notifications.OnNext(notification);
 }