From 7658a8546a9c33a76376dff3ab646f2aceaf0a01 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 17 Jun 2018 19:06:13 +0300 Subject: Working on PPC !!! --- .../Notifications/INotificationProvider.cs | 42 +++++++++++++ .../Notifications/NotificationItem.cs | 69 ++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs index 9fc42c155..303392a68 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media; +using Tango.Core.Commands; namespace Tango.PPC.Common.Notifications { @@ -14,6 +15,16 @@ namespace Tango.PPC.Common.Notifications /// public interface INotificationProvider { + /// + /// Gets the collection of notification items. + /// + ObservableCollection NotificationItems { get; } + + /// + /// Gets a value indicating whether this instance has notification items. + /// + bool HasNotificationItems { get; } + /// /// Gets the current message box. /// @@ -47,5 +58,36 @@ namespace Tango.PPC.Common.Notifications /// /// The message. Task ShowQuestion(String message); + + /// + /// Inserts the notification item to the bottom of the notifications collection. + /// + /// The item. + NotificationItem PushNotification(NotificationItem item); + + /// + /// Inserts the notification item to the bottom of the notifications collection. + /// + /// 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) + NotificationItem PushNotification(NotificationItem item, Func condition, bool autoCheck = true, TimeSpan? checkInterval = null); + + /// + /// Removed the specified notification item. + /// + /// The item. + void PopNotification(NotificationItem item); + + /// + /// Invokes the notification items conditions. + /// + void InvokeNotificationItemsConditions(); + + /// + /// Gets the pop notification command. + /// + RelayCommand PopNotificationCommand { get; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs new file mode 100644 index 000000000..f5e319fa0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Timers; +using System.Windows.Media; +using Tango.Core; + +namespace Tango.PPC.Common.Notifications +{ + /// + /// Represents a base notification item. + /// + /// + public abstract class NotificationItem : ExtendedObject, IDisposable + { + /// + /// Gets or sets the condition. + /// + internal Func Condition { get; set; } + + /// + /// Gets or sets a value indicating whether [automatic check]. + /// + internal bool AutoCheck { get; set; } + + /// + /// Gets or sets the automatic check interval. + /// + internal TimeSpan AutoCheckInterval { get; set; } + + /// + /// Gets or sets the remove action. + /// + internal Action RemoveAction { get; set; } + + /// + /// Gets or sets the check timer. + /// + internal Timer Timer { get; set; } + + private String _message; + /// + /// Gets or sets the notification message. + /// + public String Message + { + get { return _message; } + set { _message = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the type of the view associated with this notification item. + /// + public abstract Type ViewType { get; } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + if (RemoveAction != null) + { + RemoveAction(); + } + } + } +} -- cgit v1.3.1