using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.SharedUI; namespace Tango.MachineStudio.Common.Notifications { /// /// Represents a dialog view model base class. /// /// public abstract class DialogViewVM : ViewModel { public event Action Accepted; public event Action Canceled; /// /// Initializes a new instance of the class. /// public DialogViewVM() { CanClose = true; CloseCommand = new RelayCommand(Cancel, (x) => CanClose); } private bool _canClose; /// /// Gets or sets a value indicating whether this dialog can be closed. /// public bool CanClose { get { return _canClose; } set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } /// /// Gets or sets the close command. /// public RelayCommand CloseCommand { get; set; } /// /// Called when the dialog has been shown. /// public virtual void OnShow() { } /// /// Invokes the event. /// protected virtual void Accept() { Accepted?.Invoke(); } /// /// Invokes the event. /// protected virtual void Cancel() { Canceled?.Invoke(); } } }