diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-27 19:33:15 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-27 19:33:15 +0300 |
| commit | e571f20e27c4fca6bb6efe03d6427a1f332f9830 (patch) | |
| tree | b16041b76ea3b4e8368039c9396f9bbf9624dcc2 /Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs | |
| parent | 157e0685abb2e7b22b6584cdc7d6f5838ed0a808 (diff) | |
| download | Tango-e571f20e27c4fca6bb6efe03d6427a1f332f9830.tar.gz Tango-e571f20e27c4fca6bb6efe03d6427a1f332f9830.zip | |
Working on panel pc.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs new file mode 100644 index 000000000..b7a48f259 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs @@ -0,0 +1,74 @@ +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.PPC.Common.Notifications +{ + /// <summary> + /// Represents a dialog view model base class. + /// </summary> + /// <seealso cref="Tango.SharedUI.ViewModel" /> + public abstract class DialogViewVM : ViewModel + { + public event Action Accepted; + public event Action Canceled; + + /// <summary> + /// Initializes a new instance of the <see cref="DialogViewVM"/> class. + /// </summary> + public DialogViewVM() + { + CanClose = true; + CloseCommand = new RelayCommand(Cancel, (x) => CanClose); + OKCommand = new RelayCommand(Accept, (x) => CanClose); + } + + private bool _canClose; + /// <summary> + /// Gets or sets a value indicating whether this dialog can be closed. + /// </summary> + public bool CanClose + { + get { return _canClose; } + set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + /// <summary> + /// Gets or sets the close command. + /// </summary> + public RelayCommand CloseCommand { get; set; } + + /// <summary> + /// Gets or sets the ok command. + /// </summary> + public RelayCommand OKCommand { get; set; } + + /// <summary> + /// Called when the dialog has been shown. + /// </summary> + public virtual void OnShow() + { + + } + + /// <summary> + /// Invokes the <see cref="Accepted"/> event. + /// </summary> + protected virtual void Accept() + { + Accepted?.Invoke(); + } + + /// <summary> + /// Invokes the <see cref="Canceled"/> event. + /// </summary> + protected virtual void Cancel() + { + Canceled?.Invoke(); + } + } +} |
