From 64bcf92608faae31b7cd31ac3da5c7d1d7ebcd0b Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 14 Jul 2018 21:27:57 +0300 Subject: Implemented job completed notification item. --- .../Notifications/DefaultNotificationProvider.cs | 61 +++------------------- 1 file changed, 8 insertions(+), 53 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index 647fc1ef1..0ff9982ee 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -212,43 +212,20 @@ namespace Tango.PPC.UI.Notifications /// public NotificationItem PushNotification(NotificationItem item) { - return PushNotification(item, null, false, null); + item.RemoveAction = () => { PopNotification(item); }; + NotificationItems.Insert(0, item); + RaisePropertyChanged(nameof(HasNotificationItems)); + return item; } /// - /// Inserts the notification item to the bottom of the notifications collection. + /// Pushes the notification. /// - /// The item. - /// A condition which determines if this item is still relevant. - /// Determines whether to perform automatic checking of the condition. - /// Determines how frequently the condition function will be invoked. (Default 1 second) + /// /// - public NotificationItem PushNotification(NotificationItem item, Func condition, bool autoCheck = true, TimeSpan? checkInterval = default(TimeSpan?)) + public NotificationItem PushNotification() where T : NotificationItem { - item.Condition = condition; - item.AutoCheck = autoCheck; - item.AutoCheckInterval = checkInterval != null ? checkInterval.Value : TimeSpan.FromSeconds(1); - item.RemoveAction = () => { PopNotification(item); }; - NotificationItems.Insert(0, item); - - if (autoCheck && condition != null) - { - Timer timer = new Timer(); - item.Timer = timer; - timer.Interval = item.AutoCheckInterval.TotalMilliseconds; - timer.Elapsed += (x, y) => - { - if (!item.Condition()) - { - PopNotification(item); - } - }; - timer.Start(); - } - - RaisePropertyChanged(nameof(HasNotificationItems)); - - return item; + return PushNotification(Activator.CreateInstance()); } /// @@ -257,32 +234,10 @@ namespace Tango.PPC.UI.Notifications /// The item. public void PopNotification(NotificationItem item) { - if (item.Timer != null) - { - item.Timer.Stop(); - } - NotificationItems.Remove(item); - RaisePropertyChanged(nameof(HasNotificationItems)); } - /// - /// Invokes the notification items conditions. - /// - public void InvokeNotificationItemsConditions() - { - var list = NotificationItems.ToList(); - - foreach (var item in list.Where(x => x.Condition != null)) - { - if (!item.Condition()) - { - PopNotification(item); - } - } - } - /// /// Gets a value indicating whether this instance has notification items. /// -- cgit v1.3.1