aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs61
1 files changed, 8 insertions, 53 deletions
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
/// <returns></returns>
public NotificationItem PushNotification(NotificationItem item)
{
- return PushNotification(item, null, false, null);
+ item.RemoveAction = () => { PopNotification(item); };
+ NotificationItems.Insert(0, item);
+ RaisePropertyChanged(nameof(HasNotificationItems));
+ return item;
}
/// <summary>
- /// Inserts the notification item to the bottom of the notifications collection.
+ /// Pushes the notification.
/// </summary>
- /// <param name="item">The item.</param>
- /// <param name="condition">A condition which determines if this item is still relevant.</param>
- /// <param name="autoCheck">Determines whether to perform automatic checking of the condition.</param>
- /// <param name="checkInterval">Determines how frequently the condition function will be invoked. (Default 1 second)</param>
+ /// <typeparam name="T"></typeparam>
/// <returns></returns>
- public NotificationItem PushNotification(NotificationItem item, Func<bool> condition, bool autoCheck = true, TimeSpan? checkInterval = default(TimeSpan?))
+ public NotificationItem PushNotification<T>() 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<T>());
}
/// <summary>
@@ -257,33 +234,11 @@ namespace Tango.PPC.UI.Notifications
/// <param name="item">The item.</param>
public void PopNotification(NotificationItem item)
{
- if (item.Timer != null)
- {
- item.Timer.Stop();
- }
-
NotificationItems.Remove(item);
-
RaisePropertyChanged(nameof(HasNotificationItems));
}
/// <summary>
- /// Invokes the notification items conditions.
- /// </summary>
- public void InvokeNotificationItemsConditions()
- {
- var list = NotificationItems.ToList();
-
- foreach (var item in list.Where(x => x.Condition != null))
- {
- if (!item.Condition())
- {
- PopNotification(item);
- }
- }
- }
-
- /// <summary>
/// Gets a value indicating whether this instance has notification items.
/// </summary>
public bool HasNotificationItems