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
{
/// <summary>
/// Represents a base notification item class.
/// </summary>
/// <seealso cref="Tango.Core.ExtendedObject" />
/// <seealso cref="System.IDisposable" />
public abstract class ItemBase : ExtendedObject, IDisposable
{
/// <summary>
/// Occurs when the item has been closed.
/// </summary>
public event EventHandler Closed;
/// <summary>
/// Occurs when the item has been pressed.
/// </summary>
public event EventHandler Pressed;
/// <summary>
/// Gets or sets the remove action.
/// </summary>
internal Action RemoveAction { get; set; }
/// <summary>
/// Gets or sets the view type.
/// </summary>
public abstract Type ViewType { get; }
/// <summary>
/// Gets or sets the close command.
/// </summary>
public RelayCommand CloseCommand { get; set; }
/// <summary>
/// Gets or sets the pressed command.
/// </summary
public RelayCommand PressedCommand { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ItemBase"/> class.
/// </summary>
public ItemBase()
{
CloseCommand = new RelayCommand(Close);
PressedCommand = new RelayCommand(OnPreesed);
}
/// <summary>
/// Called when the item has been pressed.
/// </summary>
protected virtual void OnPreesed()
{
Pressed?.Invoke(this, new EventArgs());
}
/// <summary>
/// Called after the close command has been raised.
/// </summary>
public virtual void Close()
{
RemoveAction?.Invoke();
Closed?.Invoke(this, new EventArgs());
}
/// <summary>
/// Disposes the item.
/// </summary>
public void Dispose()
{
Close();
}
}
}