aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs
diff options
context:
space:
mode:
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.cs74
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();
+ }
+ }
+}