Add guided walkthrough
This commit is contained in:
parent
cdf1a01457
commit
702219ee69
9 changed files with 302 additions and 14 deletions
|
|
@ -1229,7 +1229,7 @@
|
|||
private System.Windows.Forms.CheckBox downloadEpisodesCb;
|
||||
private System.Windows.Forms.CheckBox importEpisodesCb;
|
||||
private System.Windows.Forms.CheckBox splitFilesByChapterCbox;
|
||||
private System.Windows.Forms.TabControl tabControl;
|
||||
public System.Windows.Forms.TabControl tabControl;
|
||||
private System.Windows.Forms.TabPage tab1ImportantSettings;
|
||||
private System.Windows.Forms.GroupBox booksGb;
|
||||
private System.Windows.Forms.TabPage tab2ImportLibrary;
|
||||
|
|
|
|||
12
Source/LibationWinForms/Form1.Designer.cs
generated
12
Source/LibationWinForms/Form1.Designer.cs
generated
|
|
@ -634,7 +634,7 @@
|
|||
|
||||
#endregion
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem;
|
||||
public System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel springLbl;
|
||||
private LibationWinForms.FormattableToolStripStatusLabel visibleCountLbl;
|
||||
|
|
@ -645,16 +645,16 @@
|
|||
private System.Windows.Forms.TextBox filterSearchTb;
|
||||
private System.Windows.Forms.Button filterBtn;
|
||||
private System.Windows.Forms.Button filterHelpBtn;
|
||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem scanLibraryToolStripMenuItem;
|
||||
public System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||
public System.Windows.Forms.ToolStripMenuItem scanLibraryToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem quickFiltersToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem firstFilterIsDefaultToolStripMenuItem;
|
||||
private System.Windows.Forms.Button addQuickFilterBtn;
|
||||
private System.Windows.Forms.ToolStripMenuItem editQuickFiltersToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem basicSettingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem;
|
||||
public System.Windows.Forms.ToolStripMenuItem basicSettingsToolStripMenuItem;
|
||||
public System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem;
|
||||
public System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfSomeAccountsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem noAccountsYetAddAccountToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,22 @@ namespace LibationWinForms
|
|||
this.Load += (_, __) => productsDisplay.Display();
|
||||
LibraryCommands.LibrarySizeChanged += (_, __) => this.UIThreadAsync(() => productsDisplay.Display());
|
||||
}
|
||||
Shown += Form1_Shown;
|
||||
}
|
||||
|
||||
private async void Form1_Shown(object sender, EventArgs e)
|
||||
{
|
||||
if (Configuration.Instance.FirstLaunch)
|
||||
{
|
||||
var result = MessageBox.Show(this, "Would you like a guided tour to get started?", "Libation Walkthrough", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
|
||||
|
||||
if (result is DialogResult.Yes)
|
||||
{
|
||||
await new Walkthrough(this).RunAsync();
|
||||
}
|
||||
|
||||
Configuration.Instance.FirstLaunch = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
|
|
|
|||
124
Source/LibationWinForms/Walkthrough.cs
Normal file
124
Source/LibationWinForms/Walkthrough.cs
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
using AudibleUtilities;
|
||||
using Dinah.Core.StepRunner;
|
||||
using LibationWinForms.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace LibationWinForms
|
||||
{
|
||||
internal class Walkthrough
|
||||
{
|
||||
private static Dictionary<string, string> settingTabMessages = new()
|
||||
{
|
||||
{ "Important settings", "Change where liberated books are stored."},
|
||||
{ "Import library", "Change how your library is scanned, imported, and liberated."},
|
||||
{ "Download/Decrypt", "Control how liberated files and folders are named and stored."},
|
||||
{ "Audio File Options", "Control how audio files are decrypted, including audio format and metadata handling."},
|
||||
};
|
||||
|
||||
private readonly Form1 MainForm;
|
||||
private readonly AsyncStepSequence sequence = new();
|
||||
public Walkthrough(Form1 form1)
|
||||
{
|
||||
MainForm = form1;
|
||||
sequence[nameof(ShowAccountDialog)] = ShowAccountDialog;
|
||||
sequence[nameof(ShowSettingsDialog)] = ShowSettingsDialog;
|
||||
sequence[nameof(ScanAccounts)] = ScanAccounts;
|
||||
}
|
||||
|
||||
public async Task RunAsync() => await sequence.RunAsync();
|
||||
|
||||
private async Task<bool> ShowAccountDialog()
|
||||
{
|
||||
MainForm.Invoke(() => MessageBox.Show(MainForm, "First, add you Audible account(s).", "Add Accounts"));
|
||||
|
||||
await Task.Delay(750);
|
||||
MainForm.Invoke(MainForm.settingsToolStripMenuItem.ShowDropDown);
|
||||
await Task.Delay(500);
|
||||
MainForm.Invoke(MainForm.accountsToolStripMenuItem.Select);
|
||||
await Task.Delay(1000);
|
||||
|
||||
using var accountSettings = MainForm.Invoke(() => new AccountsDialog());
|
||||
accountSettings.StartPosition = FormStartPosition.CenterParent;
|
||||
accountSettings.Shown += (_, _) => MessageBox.Show(accountSettings, "Add your Audible account(s), then save.", "Add an Account");
|
||||
MainForm.Invoke(() => accountSettings.ShowDialog(MainForm));
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task<bool> ShowSettingsDialog()
|
||||
{
|
||||
MainForm.Invoke(() => MessageBox.Show(MainForm, "Next, adjust Libation's settings", "Change Settings"));
|
||||
|
||||
await Task.Delay(750);
|
||||
MainForm.Invoke(MainForm.settingsToolStripMenuItem.ShowDropDown);
|
||||
await Task.Delay(500);
|
||||
MainForm.Invoke(MainForm.basicSettingsToolStripMenuItem.Select);
|
||||
await Task.Delay(1000);
|
||||
|
||||
using var settingsDialog = MainForm.Invoke(() => new SettingsDialog());
|
||||
|
||||
var tabsToVisit = settingsDialog.tabControl.TabPages.Cast<TabPage>().ToList();
|
||||
|
||||
settingsDialog.StartPosition = FormStartPosition.CenterParent;
|
||||
settingsDialog.FormClosing += SettingsDialog_FormClosing;
|
||||
settingsDialog.Shown += TabControl_TabIndexChanged;
|
||||
settingsDialog.tabControl.SelectedIndexChanged += TabControl_TabIndexChanged;
|
||||
|
||||
MainForm.Invoke(() => settingsDialog.ShowDialog(MainForm));
|
||||
|
||||
return true;
|
||||
|
||||
void TabControl_TabIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var selectedTab = settingsDialog.tabControl.SelectedTab;
|
||||
|
||||
tabsToVisit.Remove(selectedTab);
|
||||
|
||||
if (!selectedTab.Visible || !settingTabMessages.ContainsKey(selectedTab.Text)) return;
|
||||
|
||||
MessageBox.Show(selectedTab, settingTabMessages[selectedTab.Text], selectedTab.Text + " Tab", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
settingTabMessages.Remove(selectedTab.Text);
|
||||
}
|
||||
|
||||
void SettingsDialog_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (tabsToVisit.Count > 0)
|
||||
{
|
||||
var nextTab = tabsToVisit[0];
|
||||
tabsToVisit.RemoveAt(0);
|
||||
|
||||
settingsDialog.tabControl.SelectedTab = nextTab;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> ScanAccounts()
|
||||
{
|
||||
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||
var count = persister.AccountsSettings.Accounts.Count;
|
||||
|
||||
if (count < 1)
|
||||
{
|
||||
MainForm.Invoke(() => MessageBox.Show(MainForm, "Add an Audible account, then sync your library through the \"Import\" menu", "Add an Audible Account"));
|
||||
return false;
|
||||
}
|
||||
|
||||
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}"));
|
||||
|
||||
await Task.Delay(750);
|
||||
MainForm.Invoke(MainForm.importToolStripMenuItem.ShowDropDown);
|
||||
await Task.Delay(500);
|
||||
MainForm.Invoke(() => (count > 1 ? MainForm.scanLibraryOfAllAccountsToolStripMenuItem : MainForm.scanLibraryToolStripMenuItem).Select());
|
||||
await Task.Delay(1000);
|
||||
MainForm.Invoke(() => (count > 1 ? MainForm.scanLibraryOfAllAccountsToolStripMenuItem : MainForm.scanLibraryToolStripMenuItem).PerformClick());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue