From e571f20e27c4fca6bb6efe03d6427a1f332f9830 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 27 May 2018 19:33:15 +0300 Subject: Working on panel pc. --- .../Tango.PPC.Common/Notification/DialogViewVM.cs | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs') 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 +{ + /// + /// 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); + OKCommand = new RelayCommand(Accept, (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; } + + /// + /// Gets or sets the ok command. + /// + public RelayCommand OKCommand { 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(); + } + } +} -- cgit v1.3.1