private void SuccessfullyExecutedMessageBoxClosing(MaterialMessageBoxResult result) { if (result == MaterialMessageBoxResult.Yes) { ImportWindowViewModel.CloseView(); } }
private async Task <MaterialMessageBoxResult> ShowDialog(object view, Func <MaterialMessageBoxResult, object> closingEventHandler) { try { MaterialMessageBoxResult result = Model.MaterialMessageBoxResult.None; await this.UIDispatcher.Invoke(async() => { try { var retval = await DialogHost.Show( view, this.DialogIdentifier, new DialogClosingEventHandler( (sender, eventArgs) => { // if the settin view was closed return if (eventArgs.Parameter.GetType() != typeof(MaterialMessageBoxResult)) { return; } var displayableView = closingEventHandler?.Invoke((MaterialMessageBoxResult)eventArgs.Parameter); if (displayableView != null) { eventArgs.Cancel(); eventArgs.Session.UpdateContent(displayableView); } })); if (retval == null) { result = MaterialMessageBoxResult.None; } else { result = retval.GetType() == typeof(MaterialMessageBoxResult) ? (MaterialMessageBoxResult)retval : MaterialMessageBoxResult.None; } } catch (InvalidOperationException) { // this can happen if the window is closed and the dialog can't be shown } }); return(result); } catch (Exception e) { this.UIDispatcher.Invoke(() => { var n = new Greg.WPF.Utility.ExceptionMessageBox(e, "Unhandled Exception"); n.ShowDialog(); }); throw; } }
private object ConnectionMessageBoxClosingEventHandler(MaterialMessageBoxResult result) { if (result == MaterialMessageBoxResult.No) { Application.Current.Shutdown(); return(null); } // update content of the session return(MainWindowViewModel.GetSettingView()); }