aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-05-28 10:31:15 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-05-28 10:31:15 +0300
commit0159af4cc40ef8ba9c89516ced41ce69322c6bf7 (patch)
tree5c7931aa8d18a2e46eea96452baa5dbecf7e9368 /Software/Visual_Studio/PPC/Tango.PPC.Common/Notification/DialogViewVM.cs
parent2843ce67c6ae76e1dd02d7c7cd1f611ca893f46f (diff)
parentf7424796d093009adc95df6cbb2d54d6bce57592 (diff)
downloadTango-0159af4cc40ef8ba9c89516ced41ce69322c6bf7.tar.gz
Tango-0159af4cc40ef8ba9c89516ced41ce69322c6bf7.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
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();
+ }
+ }
+}