From 36005508a19a4c79142ee682f58cd82cbe473326 Mon Sep 17 00:00:00 2001 From: MBucari Date: Mon, 27 Mar 2023 20:24:15 -0600 Subject: [PATCH] Allow users to cancel walkthrough --- Source/LibationAvalonia/Walkthrough.cs | 12 +++++++++--- Source/LibationWinForms/Walkthrough.cs | 12 ++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/LibationAvalonia/Walkthrough.cs b/Source/LibationAvalonia/Walkthrough.cs index 6e2cab38..8f1a0085 100644 --- a/Source/LibationAvalonia/Walkthrough.cs +++ b/Source/LibationAvalonia/Walkthrough.cs @@ -34,7 +34,9 @@ namespace LibationAvalonia private async Task ShowAccountDialog() { - await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(MainForm, "First, add you Audible account(s).", "Add Accounts")); + var result = await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(MainForm, "First, add you Audible account(s).", "Add Accounts", MessageBoxButtons.OKCancel)); + + if (result is DialogResult.Cancel) return false; await Task.Delay(750); await Dispatcher.UIThread.InvokeAsync(MainForm.settingsToolStripMenuItem.Open); @@ -49,7 +51,9 @@ namespace LibationAvalonia private async Task ShowSettingsDialog() { - await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(MainForm, "Next, adjust Libation's settings", "Change Settings")); + var result = await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(MainForm, "Next, adjust Libation's settings", "Change Settings", MessageBoxButtons.OKCancel)); + + if (result is DialogResult.Cancel) return false; await Task.Delay(750); await Dispatcher.UIThread.InvokeAsync(MainForm.settingsToolStripMenuItem.Open); @@ -112,7 +116,8 @@ namespace LibationAvalonia var accounts = count > 1 ? "accounts" : "account"; var library = count > 1 ? "libraries" : "library"; - await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(MainForm, $"Finally, scan your Audible {accounts} to sync your {library} with Libation", $"Scan {accounts}")); + var result = await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(MainForm, $"Finally, scan your Audible {accounts} to sync your {library} with Libation", $"Scan {accounts}", MessageBoxButtons.OKCancel)); + if (result is DialogResult.Cancel) return false; await Task.Delay(750); await Dispatcher.UIThread.InvokeAsync(MainForm.importToolStripMenuItem.Open); @@ -120,6 +125,7 @@ namespace LibationAvalonia await Dispatcher.UIThread.InvokeAsync(() => (count > 1 ? MainForm.scanLibraryOfAllAccountsToolStripMenuItem : MainForm.scanLibraryToolStripMenuItem).IsSelected = true); await Task.Delay(1000); await Dispatcher.UIThread.InvokeAsync(() => (count > 1 ? MainForm.scanLibraryOfAllAccountsToolStripMenuItem : MainForm.scanLibraryToolStripMenuItem).RaiseEvent(new Avalonia.Interactivity.RoutedEventArgs(MenuItem.ClickEvent))); + await Dispatcher.UIThread.InvokeAsync(MainForm.importToolStripMenuItem.Close); return true; } diff --git a/Source/LibationWinForms/Walkthrough.cs b/Source/LibationWinForms/Walkthrough.cs index db7d610e..ec58ab6f 100644 --- a/Source/LibationWinForms/Walkthrough.cs +++ b/Source/LibationWinForms/Walkthrough.cs @@ -1,5 +1,6 @@ using AudibleUtilities; using Dinah.Core.StepRunner; +using Dinah.Core.WindowsDesktop.Processes; using LibationWinForms.Dialogs; using System; using System.Collections.Generic; @@ -33,7 +34,8 @@ namespace LibationWinForms private async Task ShowAccountDialog() { - MainForm.Invoke(() => MessageBox.Show(MainForm, "First, add you Audible account(s).", "Add Accounts")); + var result = MainForm.Invoke(() => MessageBox.Show(MainForm, "First, add you Audible account(s).", "Add Accounts", MessageBoxButtons.OKCancel)); + if (result is DialogResult.Cancel) return false; await Task.Delay(750); MainForm.Invoke(MainForm.settingsToolStripMenuItem.ShowDropDown); @@ -50,7 +52,8 @@ namespace LibationWinForms private async Task ShowSettingsDialog() { - MainForm.Invoke(() => MessageBox.Show(MainForm, "Next, adjust Libation's settings", "Change Settings")); + var result = MainForm.Invoke(() => MessageBox.Show(MainForm, "Next, adjust Libation's settings", "Change Settings", MessageBoxButtons.OKCancel)); + if (result is DialogResult.Cancel) return false; await Task.Delay(750); MainForm.Invoke(MainForm.settingsToolStripMenuItem.ShowDropDown); @@ -110,8 +113,9 @@ namespace LibationWinForms var accounts = count > 1 ? "accounts" :"account"; var library = count > 1 ? "libraries" : "library"; - MainForm.Invoke(() => MessageBox.Show(MainForm, $"Finally, scan your Audible {accounts} to sync your {library} with Libation", $"Scan {accounts}")); - + var result = MainForm.Invoke(() => MessageBox.Show(MainForm, $"Finally, scan your Audible {accounts} to sync your {library} with Libation", $"Scan {accounts}", MessageBoxButtons.OKCancel)); + if (result is DialogResult.Cancel) return false; + await Task.Delay(750); MainForm.Invoke(MainForm.importToolStripMenuItem.ShowDropDown); await Task.Delay(500);