diff --git a/AppScaffolding/AppScaffolding.csproj b/AppScaffolding/AppScaffolding.csproj
index c1fd33b4..9df8e828 100644
--- a/AppScaffolding/AppScaffolding.csproj
+++ b/AppScaffolding/AppScaffolding.csproj
@@ -3,7 +3,7 @@
net6.0-windows
- 7.0.1.1
+ 7.1.0.1
diff --git a/ApplicationServices/LibraryCommands.cs b/ApplicationServices/LibraryCommands.cs
index a108b530..d966d8d9 100644
--- a/ApplicationServices/LibraryCommands.cs
+++ b/ApplicationServices/LibraryCommands.cs
@@ -72,6 +72,8 @@ namespace ApplicationServices
}
}
+ public static event EventHandler ScanBegin;
+ public static event EventHandler ScanEnd;
#region FULL LIBRARY scan and import
public static async Task<(int totalCount, int newCount)> ImportAccountAsync(Func> apiExtendedfunc, params Account[] accounts)
{
@@ -82,6 +84,8 @@ namespace ApplicationServices
try
{
+ ScanBegin?.Invoke(null, accounts.Length);
+
logTime($"pre {nameof(scanAccountsAsync)} all");
var importItems = await scanAccountsAsync(apiExtendedfunc, accounts, LibraryOptions.ResponseGroupOptions.ALL_OPTIONS);
logTime($"post {nameof(scanAccountsAsync)} all");
@@ -127,6 +131,7 @@ namespace ApplicationServices
{
stop();
var putBreakPointHere = logOutput;
+ ScanEnd?.Invoke(null, null);
}
}
diff --git a/LibationWinForms/Dialogs/IndexLibraryDialog.Designer.cs b/LibationWinForms/Dialogs/IndexLibraryDialog.Designer.cs
deleted file mode 100644
index 4b4126ba..00000000
--- a/LibationWinForms/Dialogs/IndexLibraryDialog.Designer.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-namespace LibationWinForms.Dialogs
-{
- partial class IndexLibraryDialog
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(28, 24);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(263, 13);
- this.label1.TabIndex = 0;
- this.label1.Text = "Scanning Audible library. This may take a few minutes";
- //
- // IndexLibraryDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(440, 63);
- this.Controls.Add(this.label1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "IndexLibraryDialog";
- this.ShowIcon = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "Scan Library";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Label label1;
- }
-}
\ No newline at end of file
diff --git a/LibationWinForms/Dialogs/IndexLibraryDialog.cs b/LibationWinForms/Dialogs/IndexLibraryDialog.cs
deleted file mode 100644
index ca30ecd8..00000000
--- a/LibationWinForms/Dialogs/IndexLibraryDialog.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Windows.Forms;
-using ApplicationServices;
-using AudibleUtilities;
-using LibationWinForms.Login;
-
-namespace LibationWinForms.Dialogs
-{
- public partial class IndexLibraryDialog : Form
- {
- private Account[] _accounts { get; }
-
- public int NewBooksAdded { get; private set; }
- public int TotalBooksProcessed { get; private set; }
-
- public IndexLibraryDialog(params Account[] accounts)
- {
- _accounts = accounts;
- InitializeComponent();
- this.Shown += IndexLibraryDialog_Shown;
- }
-
- private async void IndexLibraryDialog_Shown(object sender, EventArgs e)
- {
- if (_accounts is not null && _accounts.Length > 0)
- {
- this.label1.Text
- = (_accounts.Length == 1)
- ? "Scanning Audible library. This may take a few minutes."
- : $"Scanning Audible library: {_accounts.Length} accounts. This may take a few minutes per account.";
-
- try
- {
- (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.ImportAccountAsync(account => ApiExtended.CreateAsync(account, new WinformLoginChoiceEager(account)), _accounts);
- }
- catch (Exception ex)
- {
- MessageBoxAlertAdmin.Show(
- "Error importing library. Please try again. If this still happens after 2 or 3 tries, stop and contact administrator",
- "Error importing library",
- ex);
- }
- }
-
- this.Close();
- }
- }
-}
diff --git a/LibationWinForms/Dialogs/IndexLibraryDialog.resx b/LibationWinForms/Dialogs/IndexLibraryDialog.resx
deleted file mode 100644
index e8ae276d..00000000
--- a/LibationWinForms/Dialogs/IndexLibraryDialog.resx
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/LibationWinForms/Form1.Designer.cs b/LibationWinForms/Form1.Designer.cs
index 67f1d0cb..52e891c4 100644
--- a/LibationWinForms/Form1.Designer.cs
+++ b/LibationWinForms/Form1.Designer.cs
@@ -55,14 +55,15 @@
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.accountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.basicSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
+ this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.visibleCountLbl = new System.Windows.Forms.ToolStripStatusLabel();
this.springLbl = new System.Windows.Forms.ToolStripStatusLabel();
this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
this.addFilterBtn = new System.Windows.Forms.Button();
- this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
- this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.scanningToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -119,7 +120,8 @@
this.liberateToolStripMenuItem,
this.exportToolStripMenuItem,
this.quickFiltersToolStripMenuItem,
- this.settingsToolStripMenuItem});
+ this.settingsToolStripMenuItem,
+ this.scanningToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
@@ -280,17 +282,29 @@
// accountsToolStripMenuItem
//
this.accountsToolStripMenuItem.Name = "accountsToolStripMenuItem";
- this.accountsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.accountsToolStripMenuItem.Size = new System.Drawing.Size(133, 22);
this.accountsToolStripMenuItem.Text = "&Accounts...";
this.accountsToolStripMenuItem.Click += new System.EventHandler(this.accountsToolStripMenuItem_Click);
//
// basicSettingsToolStripMenuItem
//
this.basicSettingsToolStripMenuItem.Name = "basicSettingsToolStripMenuItem";
- this.basicSettingsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.basicSettingsToolStripMenuItem.Size = new System.Drawing.Size(133, 22);
this.basicSettingsToolStripMenuItem.Text = "&Settings...";
this.basicSettingsToolStripMenuItem.Click += new System.EventHandler(this.basicSettingsToolStripMenuItem_Click);
//
+ // toolStripSeparator2
+ //
+ this.toolStripSeparator2.Name = "toolStripSeparator2";
+ this.toolStripSeparator2.Size = new System.Drawing.Size(130, 6);
+ //
+ // aboutToolStripMenuItem
+ //
+ this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
+ this.aboutToolStripMenuItem.Size = new System.Drawing.Size(133, 22);
+ this.aboutToolStripMenuItem.Text = "A&bout...";
+ this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
+ //
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -340,17 +354,15 @@
this.addFilterBtn.UseVisualStyleBackColor = true;
this.addFilterBtn.Click += new System.EventHandler(this.AddFilterBtn_Click);
//
- // toolStripSeparator2
+ // scanningToolStripMenuItem
//
- this.toolStripSeparator2.Name = "toolStripSeparator2";
- this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
- //
- // aboutToolStripMenuItem
- //
- this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
- this.aboutToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.aboutToolStripMenuItem.Text = "A&bout...";
- this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
+ this.scanningToolStripMenuItem.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
+ this.scanningToolStripMenuItem.Enabled = false;
+ this.scanningToolStripMenuItem.Image = global::LibationWinForms.Properties.Resources.import_16x16;
+ this.scanningToolStripMenuItem.Name = "scanningToolStripMenuItem";
+ this.scanningToolStripMenuItem.Size = new System.Drawing.Size(93, 20);
+ this.scanningToolStripMenuItem.Text = "Scanning...";
+ this.scanningToolStripMenuItem.Visible = false;
//
// Form1
//
@@ -415,5 +427,6 @@
private System.Windows.Forms.ToolStripMenuItem removeSomeAccountsToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem scanningToolStripMenuItem;
}
}
diff --git a/LibationWinForms/Form1.cs b/LibationWinForms/Form1.cs
index 597bab13..cb9df32e 100644
--- a/LibationWinForms/Form1.cs
+++ b/LibationWinForms/Form1.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using System.Windows.Forms;
using ApplicationServices;
using AudibleUtilities;
@@ -35,6 +36,8 @@ namespace LibationWinForms
LibraryCommands.LibrarySizeChanged += reloadGridAndUpdateBottomNumbers;
LibraryCommands.BookUserDefinedItemCommitted += setBackupCounts;
QuickFilters.Updated += updateFiltersMenu;
+ LibraryCommands.ScanBegin += LibraryCommands_ScanBegin;
+ LibraryCommands.ScanEnd += LibraryCommands_ScanEnd;
var format = System.Drawing.Imaging.ImageFormat.Jpeg;
PictureStorage.SetDefaultImage(PictureSize._80x80, Properties.Resources.default_cover_80x80.ToBytes(format));
@@ -256,21 +259,21 @@ namespace LibationWinForms
new AccountsDialog(this).ShowDialog();
}
- private void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e)
- {
- using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
- var firstAccount = persister.AccountsSettings.GetAll().FirstOrDefault();
- scanLibraries(firstAccount);
- }
+ private async void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
+ var firstAccount = persister.AccountsSettings.GetAll().FirstOrDefault();
+ await scanLibrariesAsync(firstAccount);
+ }
- private void scanLibraryOfAllAccountsToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void scanLibraryOfAllAccountsToolStripMenuItem_Click(object sender, EventArgs e)
{
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
var allAccounts = persister.AccountsSettings.GetAll();
- scanLibraries(allAccounts);
+ await scanLibrariesAsync(allAccounts);
}
- private void scanLibraryOfSomeAccountsToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void scanLibraryOfSomeAccountsToolStripMenuItem_Click(object sender, EventArgs e)
{
using var scanAccountsDialog = new ScanAccountsDialog(this);
@@ -280,7 +283,7 @@ namespace LibationWinForms
if (!scanAccountsDialog.CheckedAccounts.Any())
return;
- scanLibraries(scanAccountsDialog.CheckedAccounts);
+ await scanLibrariesAsync(scanAccountsDialog.CheckedAccounts);
}
private void removeLibraryBooksToolStripMenuItem_Click(object sender, EventArgs e)
@@ -326,21 +329,28 @@ namespace LibationWinForms
dialog.ShowDialog();
}
- private void scanLibraries(IEnumerable accounts) => scanLibraries(accounts.ToArray());
- private void scanLibraries(params Account[] accounts)
+ private async Task scanLibrariesAsync(IEnumerable accounts) => await scanLibrariesAsync(accounts.ToArray());
+ private async Task scanLibrariesAsync(params Account[] accounts)
{
- using var dialog = new IndexLibraryDialog(accounts);
- dialog.ShowDialog();
+ try
+ {
+ var (totalProcessed, newAdded) = await LibraryCommands.ImportAccountAsync(account => ApiExtended.CreateAsync(account, new Login.WinformLoginChoiceEager(account)), accounts);
- var totalProcessed = dialog.TotalBooksProcessed;
- var newAdded = dialog.NewBooksAdded;
-
- if (Configuration.Instance.ShowImportedStats)
- MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}");
+ // this is here instead of ScanEnd so that the following is only possible when it's user-initiated, not automatic loop
+ if (Configuration.Instance.ShowImportedStats && newAdded > 0)
+ MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}");
+ }
+ catch (Exception ex)
+ {
+ MessageBoxAlertAdmin.Show(
+ "Error importing library. Please try again. If this still happens after 2 or 3 tries, stop and contact administrator",
+ "Error importing library",
+ ex);
+ }
}
#endregion
- #region liberate menu
+ #region Liberate menu
private async void beginBookBackupsToolStripMenuItem_Click(object sender, EventArgs e)
=> await BookLiberation.ProcessorAutomationController.BackupAllBooksAsync();
@@ -401,7 +411,7 @@ namespace LibationWinForms
}
#endregion
- #region quick filters menu
+ #region Quick Filters menu
private void FirstFilterIsDefaultToolStripMenuItem_Click(object sender, EventArgs e)
{
firstFilterIsDefaultToolStripMenuItem.Checked = !firstFilterIsDefaultToolStripMenuItem.Checked;
@@ -448,13 +458,37 @@ namespace LibationWinForms
private void EditQuickFiltersToolStripMenuItem_Click(object sender, EventArgs e) => new EditQuickFilters(this).ShowDialog();
#endregion
- #region settings menu
+ #region Settings menu
private void accountsToolStripMenuItem_Click(object sender, EventArgs e) => new AccountsDialog(this).ShowDialog();
private void basicSettingsToolStripMenuItem_Click(object sender, EventArgs e) => new SettingsDialog().ShowDialog();
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
=> MessageBox.Show($"Running Libation version {AppScaffolding.LibationScaffolding.BuildVersion}", $"Libation v{AppScaffolding.LibationScaffolding.BuildVersion}");
- #endregion
- }
+ #endregion
+
+ #region Scanning label
+ private void LibraryCommands_ScanBegin(object sender, int accountsLength)
+ {
+ scanLibraryToolStripMenuItem.Enabled = false;
+ scanLibraryOfAllAccountsToolStripMenuItem.Enabled = false;
+ scanLibraryOfSomeAccountsToolStripMenuItem.Enabled = false;
+
+ this.scanningToolStripMenuItem.Visible = true;
+ this.scanningToolStripMenuItem.Text
+ = (accountsLength == 1)
+ ? "Scanning..."
+ : $"Scanning {accountsLength} accounts...";
+ }
+
+ private void LibraryCommands_ScanEnd(object sender, EventArgs e)
+ {
+ scanLibraryToolStripMenuItem.Enabled = true;
+ scanLibraryOfAllAccountsToolStripMenuItem.Enabled = true;
+ scanLibraryOfSomeAccountsToolStripMenuItem.Enabled = true;
+
+ this.scanningToolStripMenuItem.Visible = false;
+ }
+ #endregion
+ }
}
diff --git a/LibationWinForms/Properties/Resources.Designer.cs b/LibationWinForms/Properties/Resources.Designer.cs
index 5d51d0b3..468d9e4d 100644
--- a/LibationWinForms/Properties/Resources.Designer.cs
+++ b/LibationWinForms/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace LibationWinForms.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -130,6 +130,16 @@ namespace LibationWinForms.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap import_16x16 {
+ get {
+ object obj = ResourceManager.GetObject("import_16x16", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/LibationWinForms/Properties/Resources.resx b/LibationWinForms/Properties/Resources.resx
index 01504f95..0a1ae67a 100644
--- a/LibationWinForms/Properties/Resources.resx
+++ b/LibationWinForms/Properties/Resources.resx
@@ -112,12 +112,12 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
..\Resources\img-coverart-prod-unavailable_300x300.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -139,6 +139,9 @@
..\Resources\edit-tags-50x50.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\import_16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
..\Resources\liberate_green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/LibationWinForms/Resources/import_16x16.png b/LibationWinForms/Resources/import_16x16.png
new file mode 100644
index 00000000..40b582b1
Binary files /dev/null and b/LibationWinForms/Resources/import_16x16.png differ