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. --- .../Tango.PPC.Common/Notifications/AppBarItem.cs | 65 +----------------- .../Notifications/INotificationProvider.cs | 26 ++------ .../PPC/Tango.PPC.Common/Notifications/ItemBase.cs | 77 ++++++++++++++++++++++ .../Notifications/NotificationItem.cs | 52 +-------------- 4 files changed, 86 insertions(+), 134 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs index e35164cf7..1c47d2a97 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs @@ -11,71 +11,8 @@ namespace Tango.PPC.Common.Notifications /// /// Represents an AppBar item that can be inserted into the application header. /// - /// - public abstract class AppBarItem : IDisposable + public abstract class AppBarItem : ItemBase { - /// - /// Occurs when the AppBar item has been closed. - /// - public event EventHandler Closed; - /// - /// Occurs when the AppBar item has been pressed. - /// - public event EventHandler Preesed; - - /// - /// Gets or sets the remove action. - /// - internal Action RemoveAction { get; set; } - - /// - /// Gets or sets the AppBar view type. - /// - public abstract Type ViewType { get; } - - /// - /// Gets or sets the close command. - /// - public RelayCommand CloseCommand { get; set; } - - /// - /// Gets or sets the pressed command. - /// - /// Initializes a new instance of the class. - /// - public AppBarItem() - { - CloseCommand = new RelayCommand(Close); - PressedCommand = new RelayCommand(OnPreesed); - } - - /// - /// Called when the AppBar item has been pressed. - /// - protected virtual void OnPreesed() - { - Preesed?.Invoke(this, new EventArgs()); - } - - /// - /// Called after the close command has been raised. - /// - public virtual void Close() - { - RemoveAction?.Invoke(); - Closed?.Invoke(this, new EventArgs()); - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - Close(); - } } } 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 9063cef36..39cf2879f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs @@ -87,6 +87,13 @@ namespace Tango.PPC.Common.Notifications /// The item. NotificationItem PushNotification(NotificationItem item); + /// + /// Pushes the notification. + /// + /// + /// + NotificationItem PushNotification() where T : NotificationItem; + /// /// Displays the specified dialog in a modal design. /// @@ -114,31 +121,12 @@ namespace Tango.PPC.Common.Notifications /// Task ShowDialog() where VM : DialogViewVM; - /// - /// 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; } - /// /// Gets a value indicating whether this instance is in global busy state. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs new file mode 100644 index 000000000..12369948b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Commands; + +namespace Tango.PPC.Common.Notifications +{ + public abstract class ItemBase : ExtendedObject, IDisposable + { + /// + /// Occurs when the item has been closed. + /// + public event EventHandler Closed; + + /// + /// Occurs when the item has been pressed. + /// + public event EventHandler Pressed; + + /// + /// Gets or sets the remove action. + /// + internal Action RemoveAction { get; set; } + + /// + /// Gets or sets the view type. + /// + public abstract Type ViewType { get; } + + /// + /// Gets or sets the close command. + /// + public RelayCommand CloseCommand { get; set; } + + /// + /// Gets or sets the pressed command. + /// + /// Initializes a new instance of the class. + /// + public ItemBase() + { + CloseCommand = new RelayCommand(Close); + PressedCommand = new RelayCommand(OnPreesed); + } + + /// + /// Called when the item has been pressed. + /// + protected virtual void OnPreesed() + { + Pressed?.Invoke(this, new EventArgs()); + } + + /// + /// Called after the close command has been raised. + /// + public virtual void Close() + { + RemoveAction?.Invoke(); + Closed?.Invoke(this, new EventArgs()); + } + + /// + /// Disposes the item. + /// + public void Dispose() + { + Close(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs index f5e319fa0..e1832090e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs @@ -12,58 +12,8 @@ namespace Tango.PPC.Common.Notifications /// /// Represents a base notification item. /// - /// - public abstract class NotificationItem : ExtendedObject, IDisposable + public abstract class NotificationItem : ItemBase { - /// - /// 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