using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core; using Tango.Core.Commands; using Tango.Core.DI; namespace Tango.PPC.Common.Notifications { /// /// Represents an app button that will be displayed in the layout view. /// /// public abstract class AppButton : ExtendedObject { /// /// Occurs when the button has been pressed. /// public event Action Pressed; private String _text; /// /// Gets or sets the text. /// public String Text { get { return _text; } set { _text = value; RaisePropertyChangedAuto(); } } private bool _isEnabled; /// /// Gets or sets a value indicating whether this instance is enabled. /// public bool IsEnabled { get { return _isEnabled; } set { _isEnabled = value; RaisePropertyChangedAuto(); } } private RelayCommand _command; /// /// Gets or sets the command. /// public RelayCommand Command { get { return _command; } set { _command = value; RaisePropertyChangedAuto(); } } /// /// Initializes a new instance of the class. /// public AppButton() { } /// /// Initializes a new instance of the class. /// /// The text. /// if set to true [is enabled]. /// The on execute. /// The can execute. public AppButton(String text, bool isEnabled) : this() { Text = text; IsEnabled = isEnabled; Command = new RelayCommand(() => { Pressed?.Invoke(); }); } /// /// Initializes a new instance of the class. /// /// The text. /// The command. public AppButton(String text, RelayCommand command) : this(text, true) { Command = command; } /// /// Invalidates the button state. /// public void RaiseCanExecute() { Command.RaiseCanExecuteChanged(); } /// /// Pops this instance. /// public void Pop() { TangoIOC.Default.GetInstance().PopAppButton(this); } /// /// Pushes this instance. /// public void Push() { TangoIOC.Default.GetInstance().PushAppButton(this); } } }