From 53db041e636bb3802dbe3cb911de6ef6ef41446c Mon Sep 17 00:00:00 2001 From: Roy Date: Sun, 24 Dec 2017 02:27:16 +0200 Subject: Continue for last commit. --- .../Notifications/DialogViewVM.cs | 47 ++++++++++++++++++++++ .../Notifications/INotificationProvider.cs | 6 +-- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs new file mode 100644 index 000000000..e5e4cac78 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs @@ -0,0 +1,47 @@ +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 +{ + public abstract class DialogViewVM : ViewModel + { + public event Action Accepted; + public event Action Canceled; + + public DialogViewVM() + { + CanClose = true; + CloseCommand = new RelayCommand(Cancel, (x) => CanClose); + } + + private bool _canClose; + + public bool CanClose + { + get { return _canClose; } + set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public RelayCommand CloseCommand { get; set; } + + public virtual void OnShow() + { + + } + + protected virtual void Accept() + { + Accepted?.Invoke(); + } + + protected virtual void Cancel() + { + Canceled?.Invoke(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs index a45f9a847..937a39ec2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs @@ -24,11 +24,11 @@ namespace Tango.MachineStudio.Common.Notifications void PopTaskItem(TaskItem taskItem); - bool? ShowModalWindow(Window window); + void ShowModalDialog(Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM; - bool ShowModalWindow(PackIconKind icon, String title, object context) where T : FrameworkElement; + void ShowModalDialog(Action onAccept, Action onCancel) where VM : DialogViewVM; - bool ShowModalWindow(PackIconKind icon, String title, FrameworkElement content, object context); + void ShowModalDialog(Action onAccept) where VM : DialogViewVM; bool? ShowDialog(PackIconKind icon, Brush iconColor, String message, bool hasCancel); -- cgit v1.3.1