aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-03-06 12:11:22 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-03-06 12:11:22 +0200
commit99715aa1c659a3d5d7709cb16d5dfe1b1c29a135 (patch)
treed003fe1c07117036039294ffc8b6ba51096938d4 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
parentce68bf700e2e6535e1ed155fe2806c1ed6030edd (diff)
parent7e6c673cc8b04086fa3c78cd1bf5e31085fd8cc8 (diff)
downloadTango-99715aa1c659a3d5d7709cb16d5dfe1b1c29a135.tar.gz
Tango-99715aa1c659a3d5d7709cb16d5dfe1b1c29a135.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
index a07c0ef13..1c9b8732f 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
@@ -193,6 +193,56 @@ namespace Tango.MachineStudio.UI.Notifications
}
/// <summary>
+ /// Shows the specified view with the specified view model as it's data context.
+ /// </summary>
+ /// <typeparam name="VM">The type of the mm.</typeparam>
+ /// <typeparam name="View">The type of the view.</typeparam>
+ /// <param name="vm">The view model.</param>
+ /// <param name="view">The view.</param>
+ /// <param name="onAccept">The accept action.</param>
+ /// <param name="onCancel">The cancel action.</param>
+ public void ShowModalDialog<VM, View>(VM vm, View view, Action<VM> onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM
+ {
+ DialogWindow dialog = new DialogWindow();
+ dialog.Owner = Application.Current.MainWindow;
+ dialog.InnerContent = view;
+ MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible;
+ view.Loaded += (x, y) =>
+ {
+ VM context = vm;
+ dialog.DataContext = context;
+
+ Action onAcceptAction = null;
+ onAcceptAction = new Action(() =>
+ {
+ dialog.Close();
+ onAccept(context);
+ context.Accepted -= onAcceptAction;
+ });
+
+ Action onCancelAction = null;
+ onCancelAction = new Action(() =>
+ {
+ dialog.Close();
+
+ if (onCancel != null)
+ {
+ onCancel();
+ }
+
+ context.Canceled -= onCancelAction;
+ });
+
+ context.Accepted += onAcceptAction;
+ context.Canceled += onCancelAction;
+
+ context.OnShow();
+ };
+ dialog.ShowDialog();
+ MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden;
+ }
+
+ /// <summary>
/// Creates a new view by a naming convention of the specified view model type.
/// </summary>
/// <typeparam name="VM">The type of the view model.</typeparam>