public async Task ShowDialogAsync(object context, IDialogInstance dialog, IDialogSettings settings = null) { // Get the current dialog var metroDialog = await Instance.GetCurrentDialogAsync <BaseMetroDialog>(context); // Perform a very simply check to see if the correct dialog is returned, then show it if (metroDialog is not null && metroDialog.Title == dialog.Title) { await Instance.ShowMetroDialogAsync(context, metroDialog, settings?.ToMetroDialogSettings()); } }
public async void SetConnectionInfo(ConnectionInfoEditorViewModel viewModel) { _options.BaselineServer = viewModel.BaselineServer; _options.BaselineDatabase = viewModel.BaselineDatabase; _options.BaselineSchema = viewModel.BaselineSchema; _options.BaselineUsername = viewModel.BaselineUsername; _options.BaselinePassword = viewModel.BaselinePassword; _options.BenchmarkServer = viewModel.BenchmarkServer; _options.BenchmarkDatabase = viewModel.BenchmarkDatabase; _options.BenchmarkSchema = viewModel.BenchmarkSchema; _options.BenchmarkUsername = viewModel.BenchmarkUsername; _options.BenchmarkPassword = viewModel.BenchmarkPassword; _invalidOptions = false; ShowStatusMessage("Pre InitializeAll"); // now that the options are filled, I can invoke the initialization InitializeAll(); BaseMetroDialog showingDialog = null; showingDialog = await _dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(this); if (showingDialog != null) { await _dialogCoordinator.HideMetroDialogAsync(this, showingDialog); } ShowStatusMessage("Post InitializeAll"); }
/// <summary> /// Shows a <see cref="PackManagementDialog" /> dialog inside the current window. /// </summary> /// <param name="packs">All packs available to choose from.</param> /// <param name="packToEdit">The pack to modify.</param> /// <param name="action">The message to the user. I.e 'edit' will be displayed.</param> /// <returns>The dialog</returns> public async Task <IPackDialog> ShowPackManagementDialogAsync(IEnumerable <Pack> packs, Pack packToEdit, string action) { await dialogCoordinator.ShowMetroDialogAsync(shell, new PackManagementDialog(packs, dialogCoordinator, shell, packToEdit, action)); IPackDialog dialog = await dialogCoordinator.GetCurrentDialogAsync <PackManagementDialog>(shell); return(dialog); }
/// <summary> /// Tweak around mahapps' behaviour with dialogs - Unloaded fires when showing child dialogs as well as when hiding dialog itself. /// We need to wait til dialog itself is close. /// </summary> /// <param name="dialog">Dialog to show.</param> /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns> public virtual async Task ShowAndWaitForClosedAsync(BaseMetroDialog dialog) => await Application.Current.Dispatcher.Invoke(async() => { // Remember where we were before showing. BaseMetroDialog parentDialog = await dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(viewModel); await dialogCoordinator.ShowMetroDialogAsync(viewModel, dialog); BaseMetroDialog currentDialog; do { // Wailt until unload of this dialog (may happen multiple times) await dialog.WaitUntilUnloadedAsync(); // Check if current dialog is the one that we remembered currentDialog = await dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(viewModel); }while (currentDialog != parentDialog); });