diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-03-04 02:26:30 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-03-04 02:26:30 +0200 |
| commit | 485f8da4b55ae19f0a21792314ae2b096d48dab4 (patch) | |
| tree | 5a7402d91175f409330c052980c596a77e813d7a /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications | |
| parent | 9dedf143c3ac44ca593e735861f4e1e2e6f947c9 (diff) | |
| download | Tango-485f8da4b55ae19f0a21792314ae2b096d48dab4.tar.gz Tango-485f8da4b55ae19f0a21792314ae2b096d48dab4.zip | |
Implemented Embroidery Editor.
Implemented Create job from embroidery file.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs | 51 |
1 files changed, 51 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 4dd17b500..a07c0ef13 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -142,6 +142,57 @@ 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, Action<VM> onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM + { + var view = Activator.CreateInstance<View>(); + 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> |
