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 +++------------------- .../EmptyCartridgesNotification.cs | 34 ------------ .../EmptyCartridgesNotificationView.xaml | 15 ------ .../EmptyCartridgesNotificationView.xaml.cs | 28 ---------- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 8 --- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 1 - .../PPC/Tango.PPC.UI/Views/MainView.xaml | 10 ++-- 7 files changed, 14 insertions(+), 143 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI') 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. /// 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 LiquidTypes { get; set; } - - public EmptyCartridgesNotification() - { - Message = "Cartridges are empty, please replace cartridges"; - } - - public EmptyCartridgesNotification(IEnumerable 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 @@ - - - - - - - - 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 -{ - /// - /// Interaction logic for EmptyCartridgesNotification.xaml - /// - public partial class EmptyCartridgesNotificationView : UserControl - { - public EmptyCartridgesNotificationView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 2e344bdc9..dc3745bef 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -121,10 +121,6 @@ - - - EmptyCartridgesNotificationView.xaml - @@ -161,10 +157,6 @@ MainWindow.xaml Code - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index b3a0c5b1a..11bef4827 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -9,7 +9,6 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; -using Tango.PPC.UI.Notifications.NotificationItems; using Tango.PPC.UI.ViewsContracts; using Tango.SharedUI; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index dcb19dbee..f333ea2e8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -27,10 +27,12 @@ CurrentDialog="{Binding NotificationProvider.CurrentDialog}"> - - - - + + + + + + -- cgit v1.3.1