aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs61
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs34
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml15
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs28
4 files changed, 8 insertions, 130 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
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs
deleted file mode 100644
index 49a0c03eb..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.BL.Entities;
-using Tango.BL.Enumerations;
-using Tango.PPC.Common.Notifications;
-
-namespace Tango.PPC.UI.Notifications.NotificationItems
-{
- public class EmptyCartridgesNotification : NotificationItem
- {
- public List<LiquidType> LiquidTypes { get; set; }
-
- public EmptyCartridgesNotification()
- {
- Message = "Cartridges are empty, please replace cartridges";
- }
-
- public EmptyCartridgesNotification(IEnumerable<LiquidType> liquidTypes) : this()
- {
- LiquidTypes = liquidTypes.ToList();
- }
-
- public override Type ViewType
- {
- get
- {
- return typeof(EmptyCartridgesNotificationView);
- }
- }
- }
-}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml
deleted file mode 100644
index ccb6618e7..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml
+++ /dev/null
@@ -1,15 +0,0 @@
-<UserControl x:Class="Tango.PPC.UI.Notifications.NotificationItems.EmptyCartridgesNotificationView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:Tango.PPC.UI.Notifications.NotificationItems"
- mc:Ignorable="d"
- d:DesignHeight="60" d:DesignWidth="400" MinHeight="50" Background="Transparent" Foreground="#FF7777" d:DataContext="{d:DesignInstance Type=local:EmptyCartridgesNotification, IsDesignTimeCreatable=True}">
- <Grid Margin="10">
- <DockPanel>
- <Image Source="/Images/warning-test.png" Margin="5" />
- <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Message}"></TextBlock>
- </DockPanel>
- </Grid>
-</UserControl>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs
deleted file mode 100644
index 5fab4ab44..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace Tango.PPC.UI.Notifications.NotificationItems
-{
- /// <summary>
- /// Interaction logic for EmptyCartridgesNotification.xaml
- /// </summary>
- public partial class EmptyCartridgesNotificationView : UserControl
- {
- public EmptyCartridgesNotificationView()
- {
- InitializeComponent();
- }
- }
-}