* Bug fix: grid doesn't update correctly if all books are removed

* Beginning (incomplete) new menu for batch actions on visible books
This commit is contained in:
Robert McRackan 2022-05-11 10:13:07 -04:00
parent e368e4669b
commit c3871d3bca
4 changed files with 177 additions and 115 deletions

View File

@ -259,12 +259,11 @@ namespace ApplicationServices
LibrarySizeChanged?.Invoke(null, null); LibrarySizeChanged?.Invoke(null, null);
} }
/// <summary>Occurs when books are added or removed from library</summary> /// <summary>Occurs when the size of the library changes. ie: books are added or removed</summary>
public static event EventHandler LibrarySizeChanged; public static event EventHandler LibrarySizeChanged;
/// <summary> /// <summary>
/// Occurs when <see cref="UserDefinedItem.Tags"/>, <see cref="UserDefinedItem.BookStatus"/>, or <see cref="UserDefinedItem.PdfStatus"/> /// Occurs when the size of the library does not change but book(s) details do. Especially when <see cref="UserDefinedItem.Tags"/>, <see cref="UserDefinedItem.BookStatus"/>, or <see cref="UserDefinedItem.PdfStatus"/> changed values are successfully persisted.
/// changed values are successfully persisted.
/// </summary> /// </summary>
public static event EventHandler BookUserDefinedItemCommitted; public static event EventHandler BookUserDefinedItemCommitted;

View File

@ -35,8 +35,8 @@
this.filterSearchTb = new System.Windows.Forms.TextBox(); this.filterSearchTb = new System.Windows.Forms.TextBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.noAccountsYetAddAccountToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoScanLibraryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.autoScanLibraryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.noAccountsYetAddAccountToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scanLibraryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.scanLibraryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -65,6 +65,11 @@
this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel(); this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel(); this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
this.addFilterBtn = new System.Windows.Forms.Button(); this.addFilterBtn = new System.Windows.Forms.Button();
this.visibleBooksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.liberateToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.replaceTagsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.setDownloadedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -74,18 +79,18 @@
this.gridPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.gridPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.gridPanel.Location = new System.Drawing.Point(14, 65); this.gridPanel.Location = new System.Drawing.Point(34, 178);
this.gridPanel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.gridPanel.Margin = new System.Windows.Forms.Padding(10, 8, 10, 8);
this.gridPanel.Name = "gridPanel"; this.gridPanel.Name = "gridPanel";
this.gridPanel.Size = new System.Drawing.Size(979, 445); this.gridPanel.Size = new System.Drawing.Size(2378, 1216);
this.gridPanel.TabIndex = 5; this.gridPanel.TabIndex = 5;
// //
// filterHelpBtn // filterHelpBtn
// //
this.filterHelpBtn.Location = new System.Drawing.Point(14, 31); this.filterHelpBtn.Location = new System.Drawing.Point(34, 85);
this.filterHelpBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.filterHelpBtn.Margin = new System.Windows.Forms.Padding(10, 8, 10, 8);
this.filterHelpBtn.Name = "filterHelpBtn"; this.filterHelpBtn.Name = "filterHelpBtn";
this.filterHelpBtn.Size = new System.Drawing.Size(26, 27); this.filterHelpBtn.Size = new System.Drawing.Size(63, 74);
this.filterHelpBtn.TabIndex = 3; this.filterHelpBtn.TabIndex = 3;
this.filterHelpBtn.Text = "?"; this.filterHelpBtn.Text = "?";
this.filterHelpBtn.UseVisualStyleBackColor = true; this.filterHelpBtn.UseVisualStyleBackColor = true;
@ -94,10 +99,10 @@
// filterBtn // filterBtn
// //
this.filterBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.filterBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.filterBtn.Location = new System.Drawing.Point(905, 31); this.filterBtn.Location = new System.Drawing.Point(2198, 85);
this.filterBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.filterBtn.Margin = new System.Windows.Forms.Padding(10, 8, 10, 8);
this.filterBtn.Name = "filterBtn"; this.filterBtn.Name = "filterBtn";
this.filterBtn.Size = new System.Drawing.Size(88, 27); this.filterBtn.Size = new System.Drawing.Size(214, 74);
this.filterBtn.TabIndex = 2; this.filterBtn.TabIndex = 2;
this.filterBtn.Text = "Filter"; this.filterBtn.Text = "Filter";
this.filterBtn.UseVisualStyleBackColor = true; this.filterBtn.UseVisualStyleBackColor = true;
@ -107,26 +112,28 @@
// //
this.filterSearchTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.filterSearchTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.filterSearchTb.Location = new System.Drawing.Point(217, 33); this.filterSearchTb.Location = new System.Drawing.Point(527, 90);
this.filterSearchTb.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.filterSearchTb.Margin = new System.Windows.Forms.Padding(10, 8, 10, 8);
this.filterSearchTb.Name = "filterSearchTb"; this.filterSearchTb.Name = "filterSearchTb";
this.filterSearchTb.Size = new System.Drawing.Size(681, 23); this.filterSearchTb.Size = new System.Drawing.Size(1648, 47);
this.filterSearchTb.TabIndex = 1; this.filterSearchTb.TabIndex = 1;
this.filterSearchTb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.filterSearchTb_KeyPress); this.filterSearchTb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.filterSearchTb_KeyPress);
// //
// menuStrip1 // menuStrip1
// //
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(40, 40);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.importToolStripMenuItem, this.importToolStripMenuItem,
this.liberateToolStripMenuItem, this.liberateToolStripMenuItem,
this.exportToolStripMenuItem, this.exportToolStripMenuItem,
this.quickFiltersToolStripMenuItem, this.quickFiltersToolStripMenuItem,
this.settingsToolStripMenuItem, this.scanningToolStripMenuItem,
this.scanningToolStripMenuItem}); this.visibleBooksToolStripMenuItem,
this.settingsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); this.menuStrip1.Padding = new System.Windows.Forms.Padding(17, 5, 0, 5);
this.menuStrip1.Size = new System.Drawing.Size(1007, 24); this.menuStrip1.Size = new System.Drawing.Size(2446, 58);
this.menuStrip1.TabIndex = 0; this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
@ -140,41 +147,41 @@
this.scanLibraryOfSomeAccountsToolStripMenuItem, this.scanLibraryOfSomeAccountsToolStripMenuItem,
this.removeLibraryBooksToolStripMenuItem}); this.removeLibraryBooksToolStripMenuItem});
this.importToolStripMenuItem.Name = "importToolStripMenuItem"; this.importToolStripMenuItem.Name = "importToolStripMenuItem";
this.importToolStripMenuItem.Size = new System.Drawing.Size(55, 20); this.importToolStripMenuItem.Size = new System.Drawing.Size(132, 48);
this.importToolStripMenuItem.Text = "&Import"; this.importToolStripMenuItem.Text = "&Import";
// //
// noAccountsYetAddAccountToolStripMenuItem
//
this.noAccountsYetAddAccountToolStripMenuItem.Name = "noAccountsYetAddAccountToolStripMenuItem";
this.noAccountsYetAddAccountToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
this.noAccountsYetAddAccountToolStripMenuItem.Text = "No accounts yet. A&dd Account...";
this.noAccountsYetAddAccountToolStripMenuItem.Click += new System.EventHandler(this.noAccountsYetAddAccountToolStripMenuItem_Click);
//
// autoScanLibraryToolStripMenuItem // autoScanLibraryToolStripMenuItem
// //
this.autoScanLibraryToolStripMenuItem.Name = "autoScanLibraryToolStripMenuItem"; this.autoScanLibraryToolStripMenuItem.Name = "autoScanLibraryToolStripMenuItem";
this.autoScanLibraryToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.autoScanLibraryToolStripMenuItem.Size = new System.Drawing.Size(613, 54);
this.autoScanLibraryToolStripMenuItem.Text = "A&uto Scan Library"; this.autoScanLibraryToolStripMenuItem.Text = "A&uto Scan Library";
this.autoScanLibraryToolStripMenuItem.Click += new System.EventHandler(this.autoScanLibraryToolStripMenuItem_Click); this.autoScanLibraryToolStripMenuItem.Click += new System.EventHandler(this.autoScanLibraryToolStripMenuItem_Click);
// //
// noAccountsYetAddAccountToolStripMenuItem
//
this.noAccountsYetAddAccountToolStripMenuItem.Name = "noAccountsYetAddAccountToolStripMenuItem";
this.noAccountsYetAddAccountToolStripMenuItem.Size = new System.Drawing.Size(613, 54);
this.noAccountsYetAddAccountToolStripMenuItem.Text = "No accounts yet. A&dd Account...";
this.noAccountsYetAddAccountToolStripMenuItem.Click += new System.EventHandler(this.noAccountsYetAddAccountToolStripMenuItem_Click);
//
// scanLibraryToolStripMenuItem // scanLibraryToolStripMenuItem
// //
this.scanLibraryToolStripMenuItem.Name = "scanLibraryToolStripMenuItem"; this.scanLibraryToolStripMenuItem.Name = "scanLibraryToolStripMenuItem";
this.scanLibraryToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.scanLibraryToolStripMenuItem.Size = new System.Drawing.Size(613, 54);
this.scanLibraryToolStripMenuItem.Text = "Scan &Library"; this.scanLibraryToolStripMenuItem.Text = "Scan &Library";
this.scanLibraryToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryToolStripMenuItem_Click); this.scanLibraryToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryToolStripMenuItem_Click);
// //
// scanLibraryOfAllAccountsToolStripMenuItem // scanLibraryOfAllAccountsToolStripMenuItem
// //
this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem"; this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem";
this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(613, 54);
this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts"; this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts";
this.scanLibraryOfAllAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfAllAccountsToolStripMenuItem_Click); this.scanLibraryOfAllAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfAllAccountsToolStripMenuItem_Click);
// //
// scanLibraryOfSomeAccountsToolStripMenuItem // scanLibraryOfSomeAccountsToolStripMenuItem
// //
this.scanLibraryOfSomeAccountsToolStripMenuItem.Name = "scanLibraryOfSomeAccountsToolStripMenuItem"; this.scanLibraryOfSomeAccountsToolStripMenuItem.Name = "scanLibraryOfSomeAccountsToolStripMenuItem";
this.scanLibraryOfSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.scanLibraryOfSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(613, 54);
this.scanLibraryOfSomeAccountsToolStripMenuItem.Text = "Scan Library of &Some Accounts..."; this.scanLibraryOfSomeAccountsToolStripMenuItem.Text = "Scan Library of &Some Accounts...";
this.scanLibraryOfSomeAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfSomeAccountsToolStripMenuItem_Click); this.scanLibraryOfSomeAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfSomeAccountsToolStripMenuItem_Click);
// //
@ -184,21 +191,21 @@
this.removeAllAccountsToolStripMenuItem, this.removeAllAccountsToolStripMenuItem,
this.removeSomeAccountsToolStripMenuItem}); this.removeSomeAccountsToolStripMenuItem});
this.removeLibraryBooksToolStripMenuItem.Name = "removeLibraryBooksToolStripMenuItem"; this.removeLibraryBooksToolStripMenuItem.Name = "removeLibraryBooksToolStripMenuItem";
this.removeLibraryBooksToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.removeLibraryBooksToolStripMenuItem.Size = new System.Drawing.Size(613, 54);
this.removeLibraryBooksToolStripMenuItem.Text = "Remove Library Books"; this.removeLibraryBooksToolStripMenuItem.Text = "Remove Library Books";
this.removeLibraryBooksToolStripMenuItem.Click += new System.EventHandler(this.removeLibraryBooksToolStripMenuItem_Click); this.removeLibraryBooksToolStripMenuItem.Click += new System.EventHandler(this.removeLibraryBooksToolStripMenuItem_Click);
// //
// removeAllAccountsToolStripMenuItem // removeAllAccountsToolStripMenuItem
// //
this.removeAllAccountsToolStripMenuItem.Name = "removeAllAccountsToolStripMenuItem"; this.removeAllAccountsToolStripMenuItem.Name = "removeAllAccountsToolStripMenuItem";
this.removeAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(157, 22); this.removeAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(448, 54);
this.removeAllAccountsToolStripMenuItem.Text = "All Accounts"; this.removeAllAccountsToolStripMenuItem.Text = "All Accounts";
this.removeAllAccountsToolStripMenuItem.Click += new System.EventHandler(this.removeAllAccountsToolStripMenuItem_Click); this.removeAllAccountsToolStripMenuItem.Click += new System.EventHandler(this.removeAllAccountsToolStripMenuItem_Click);
// //
// removeSomeAccountsToolStripMenuItem // removeSomeAccountsToolStripMenuItem
// //
this.removeSomeAccountsToolStripMenuItem.Name = "removeSomeAccountsToolStripMenuItem"; this.removeSomeAccountsToolStripMenuItem.Name = "removeSomeAccountsToolStripMenuItem";
this.removeSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(157, 22); this.removeSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(448, 54);
this.removeSomeAccountsToolStripMenuItem.Text = "Some Accounts"; this.removeSomeAccountsToolStripMenuItem.Text = "Some Accounts";
this.removeSomeAccountsToolStripMenuItem.Click += new System.EventHandler(this.removeSomeAccountsToolStripMenuItem_Click); this.removeSomeAccountsToolStripMenuItem.Click += new System.EventHandler(this.removeSomeAccountsToolStripMenuItem_Click);
// //
@ -209,28 +216,28 @@
this.beginPdfBackupsToolStripMenuItem, this.beginPdfBackupsToolStripMenuItem,
this.convertAllM4bToMp3ToolStripMenuItem}); this.convertAllM4bToMp3ToolStripMenuItem});
this.liberateToolStripMenuItem.Name = "liberateToolStripMenuItem"; this.liberateToolStripMenuItem.Name = "liberateToolStripMenuItem";
this.liberateToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.liberateToolStripMenuItem.Size = new System.Drawing.Size(148, 48);
this.liberateToolStripMenuItem.Text = "&Liberate"; this.liberateToolStripMenuItem.Text = "&Liberate";
// //
// beginBookBackupsToolStripMenuItem // beginBookBackupsToolStripMenuItem
// //
this.beginBookBackupsToolStripMenuItem.Name = "beginBookBackupsToolStripMenuItem"; this.beginBookBackupsToolStripMenuItem.Name = "beginBookBackupsToolStripMenuItem";
this.beginBookBackupsToolStripMenuItem.Size = new System.Drawing.Size(293, 22); this.beginBookBackupsToolStripMenuItem.Size = new System.Drawing.Size(728, 54);
this.beginBookBackupsToolStripMenuItem.Text = "Begin &Book and PDF Backups: {0}"; this.beginBookBackupsToolStripMenuItem.Text = "Begin &Book and PDF Backups: {0}";
this.beginBookBackupsToolStripMenuItem.Click += new System.EventHandler(this.beginBookBackupsToolStripMenuItem_Click); this.beginBookBackupsToolStripMenuItem.Click += new System.EventHandler(this.beginBookBackupsToolStripMenuItem_Click);
// //
// beginPdfBackupsToolStripMenuItem // beginPdfBackupsToolStripMenuItem
// //
this.beginPdfBackupsToolStripMenuItem.Name = "beginPdfBackupsToolStripMenuItem"; this.beginPdfBackupsToolStripMenuItem.Name = "beginPdfBackupsToolStripMenuItem";
this.beginPdfBackupsToolStripMenuItem.Size = new System.Drawing.Size(293, 22); this.beginPdfBackupsToolStripMenuItem.Size = new System.Drawing.Size(728, 54);
this.beginPdfBackupsToolStripMenuItem.Text = "Begin &PDF Only Backups: {0}"; this.beginPdfBackupsToolStripMenuItem.Text = "Begin &PDF Only Backups: {0}";
this.beginPdfBackupsToolStripMenuItem.Click += new System.EventHandler(this.beginPdfBackupsToolStripMenuItem_Click); this.beginPdfBackupsToolStripMenuItem.Click += new System.EventHandler(this.beginPdfBackupsToolStripMenuItem_Click);
// //
// convertAllM4bToMp3ToolStripMenuItem // convertAllM4bToMp3ToolStripMenuItem
// //
this.convertAllM4bToMp3ToolStripMenuItem.Name = "convertAllM4bToMp3ToolStripMenuItem"; this.convertAllM4bToMp3ToolStripMenuItem.Name = "convertAllM4bToMp3ToolStripMenuItem";
this.convertAllM4bToMp3ToolStripMenuItem.Size = new System.Drawing.Size(293, 22); this.convertAllM4bToMp3ToolStripMenuItem.Size = new System.Drawing.Size(728, 54);
this.convertAllM4bToMp3ToolStripMenuItem.Text = "Convert all M4b to Mp3 [Long-running]..."; this.convertAllM4bToMp3ToolStripMenuItem.Text = "Convert all &M4b to Mp3 [Long-running]...";
this.convertAllM4bToMp3ToolStripMenuItem.Click += new System.EventHandler(this.convertAllM4bToMp3ToolStripMenuItem_Click); this.convertAllM4bToMp3ToolStripMenuItem.Click += new System.EventHandler(this.convertAllM4bToMp3ToolStripMenuItem_Click);
// //
// exportToolStripMenuItem // exportToolStripMenuItem
@ -238,13 +245,13 @@
this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportLibraryToolStripMenuItem}); this.exportLibraryToolStripMenuItem});
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.Size = new System.Drawing.Size(53, 20); this.exportToolStripMenuItem.Size = new System.Drawing.Size(127, 48);
this.exportToolStripMenuItem.Text = "E&xport"; this.exportToolStripMenuItem.Text = "E&xport";
// //
// exportLibraryToolStripMenuItem // exportLibraryToolStripMenuItem
// //
this.exportLibraryToolStripMenuItem.Name = "exportLibraryToolStripMenuItem"; this.exportLibraryToolStripMenuItem.Name = "exportLibraryToolStripMenuItem";
this.exportLibraryToolStripMenuItem.Size = new System.Drawing.Size(156, 22); this.exportLibraryToolStripMenuItem.Size = new System.Drawing.Size(448, 54);
this.exportLibraryToolStripMenuItem.Text = "E&xport Library..."; this.exportLibraryToolStripMenuItem.Text = "E&xport Library...";
this.exportLibraryToolStripMenuItem.Click += new System.EventHandler(this.exportLibraryToolStripMenuItem_Click); this.exportLibraryToolStripMenuItem.Click += new System.EventHandler(this.exportLibraryToolStripMenuItem_Click);
// //
@ -255,27 +262,27 @@
this.editQuickFiltersToolStripMenuItem, this.editQuickFiltersToolStripMenuItem,
this.toolStripSeparator1}); this.toolStripSeparator1});
this.quickFiltersToolStripMenuItem.Name = "quickFiltersToolStripMenuItem"; this.quickFiltersToolStripMenuItem.Name = "quickFiltersToolStripMenuItem";
this.quickFiltersToolStripMenuItem.Size = new System.Drawing.Size(84, 20); this.quickFiltersToolStripMenuItem.Size = new System.Drawing.Size(204, 48);
this.quickFiltersToolStripMenuItem.Text = "Quick &Filters"; this.quickFiltersToolStripMenuItem.Text = "Quick &Filters";
// //
// firstFilterIsDefaultToolStripMenuItem // firstFilterIsDefaultToolStripMenuItem
// //
this.firstFilterIsDefaultToolStripMenuItem.Name = "firstFilterIsDefaultToolStripMenuItem"; this.firstFilterIsDefaultToolStripMenuItem.Name = "firstFilterIsDefaultToolStripMenuItem";
this.firstFilterIsDefaultToolStripMenuItem.Size = new System.Drawing.Size(256, 22); this.firstFilterIsDefaultToolStripMenuItem.Size = new System.Drawing.Size(639, 54);
this.firstFilterIsDefaultToolStripMenuItem.Text = "Start Libation with 1st filter &Default"; this.firstFilterIsDefaultToolStripMenuItem.Text = "Start Libation with 1st filter &Default";
this.firstFilterIsDefaultToolStripMenuItem.Click += new System.EventHandler(this.FirstFilterIsDefaultToolStripMenuItem_Click); this.firstFilterIsDefaultToolStripMenuItem.Click += new System.EventHandler(this.FirstFilterIsDefaultToolStripMenuItem_Click);
// //
// editQuickFiltersToolStripMenuItem // editQuickFiltersToolStripMenuItem
// //
this.editQuickFiltersToolStripMenuItem.Name = "editQuickFiltersToolStripMenuItem"; this.editQuickFiltersToolStripMenuItem.Name = "editQuickFiltersToolStripMenuItem";
this.editQuickFiltersToolStripMenuItem.Size = new System.Drawing.Size(256, 22); this.editQuickFiltersToolStripMenuItem.Size = new System.Drawing.Size(639, 54);
this.editQuickFiltersToolStripMenuItem.Text = "&Edit quick filters..."; this.editQuickFiltersToolStripMenuItem.Text = "&Edit quick filters...";
this.editQuickFiltersToolStripMenuItem.Click += new System.EventHandler(this.EditQuickFiltersToolStripMenuItem_Click); this.editQuickFiltersToolStripMenuItem.Click += new System.EventHandler(this.EditQuickFiltersToolStripMenuItem_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(253, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(636, 6);
// //
// settingsToolStripMenuItem // settingsToolStripMenuItem
// //
@ -285,32 +292,32 @@
this.toolStripSeparator2, this.toolStripSeparator2,
this.aboutToolStripMenuItem}); this.aboutToolStripMenuItem});
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.settingsToolStripMenuItem.Size = new System.Drawing.Size(149, 48);
this.settingsToolStripMenuItem.Text = "&Settings"; this.settingsToolStripMenuItem.Text = "&Settings";
// //
// accountsToolStripMenuItem // accountsToolStripMenuItem
// //
this.accountsToolStripMenuItem.Name = "accountsToolStripMenuItem"; this.accountsToolStripMenuItem.Name = "accountsToolStripMenuItem";
this.accountsToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.accountsToolStripMenuItem.Size = new System.Drawing.Size(448, 54);
this.accountsToolStripMenuItem.Text = "&Accounts..."; this.accountsToolStripMenuItem.Text = "&Accounts...";
this.accountsToolStripMenuItem.Click += new System.EventHandler(this.accountsToolStripMenuItem_Click); this.accountsToolStripMenuItem.Click += new System.EventHandler(this.accountsToolStripMenuItem_Click);
// //
// basicSettingsToolStripMenuItem // basicSettingsToolStripMenuItem
// //
this.basicSettingsToolStripMenuItem.Name = "basicSettingsToolStripMenuItem"; this.basicSettingsToolStripMenuItem.Name = "basicSettingsToolStripMenuItem";
this.basicSettingsToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.basicSettingsToolStripMenuItem.Size = new System.Drawing.Size(448, 54);
this.basicSettingsToolStripMenuItem.Text = "&Settings..."; this.basicSettingsToolStripMenuItem.Text = "&Settings...";
this.basicSettingsToolStripMenuItem.Click += new System.EventHandler(this.basicSettingsToolStripMenuItem_Click); this.basicSettingsToolStripMenuItem.Click += new System.EventHandler(this.basicSettingsToolStripMenuItem_Click);
// //
// toolStripSeparator2 // toolStripSeparator2
// //
this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(130, 6); this.toolStripSeparator2.Size = new System.Drawing.Size(445, 6);
// //
// aboutToolStripMenuItem // aboutToolStripMenuItem
// //
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.aboutToolStripMenuItem.Size = new System.Drawing.Size(448, 54);
this.aboutToolStripMenuItem.Text = "A&bout..."; this.aboutToolStripMenuItem.Text = "A&bout...";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
// //
@ -320,64 +327,104 @@
this.scanningToolStripMenuItem.Enabled = false; this.scanningToolStripMenuItem.Enabled = false;
this.scanningToolStripMenuItem.Image = global::LibationWinForms.Properties.Resources.import_16x16; this.scanningToolStripMenuItem.Image = global::LibationWinForms.Properties.Resources.import_16x16;
this.scanningToolStripMenuItem.Name = "scanningToolStripMenuItem"; this.scanningToolStripMenuItem.Name = "scanningToolStripMenuItem";
this.scanningToolStripMenuItem.Size = new System.Drawing.Size(93, 20); this.scanningToolStripMenuItem.Size = new System.Drawing.Size(224, 48);
this.scanningToolStripMenuItem.Text = "Scanning..."; this.scanningToolStripMenuItem.Text = "Scanning...";
this.scanningToolStripMenuItem.Visible = false; this.scanningToolStripMenuItem.Visible = false;
// //
// statusStrip1 // statusStrip1
// //
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(40, 40);
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.visibleCountLbl, this.visibleCountLbl,
this.springLbl, this.springLbl,
this.backupsCountsLbl, this.backupsCountsLbl,
this.pdfsCountsLbl}); this.pdfsCountsLbl});
this.statusStrip1.Location = new System.Drawing.Point(0, 517); this.statusStrip1.Location = new System.Drawing.Point(0, 1419);
this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0); this.statusStrip1.Padding = new System.Windows.Forms.Padding(2, 0, 39, 0);
this.statusStrip1.Size = new System.Drawing.Size(1007, 22); this.statusStrip1.Size = new System.Drawing.Size(2446, 54);
this.statusStrip1.TabIndex = 6; this.statusStrip1.TabIndex = 6;
this.statusStrip1.Text = "statusStrip1"; this.statusStrip1.Text = "statusStrip1";
// //
// visibleCountLbl // visibleCountLbl
// //
this.visibleCountLbl.Name = "visibleCountLbl"; this.visibleCountLbl.Name = "visibleCountLbl";
this.visibleCountLbl.Size = new System.Drawing.Size(53, 17); this.visibleCountLbl.Size = new System.Drawing.Size(136, 41);
this.visibleCountLbl.Text = "Visible: 0"; this.visibleCountLbl.Text = "Visible: 0";
// //
// springLbl // springLbl
// //
this.springLbl.Name = "springLbl"; this.springLbl.Name = "springLbl";
this.springLbl.Size = new System.Drawing.Size(548, 17); this.springLbl.Size = new System.Drawing.Size(1299, 41);
this.springLbl.Spring = true; this.springLbl.Spring = true;
// //
// backupsCountsLbl // backupsCountsLbl
// //
this.backupsCountsLbl.Name = "backupsCountsLbl"; this.backupsCountsLbl.Name = "backupsCountsLbl";
this.backupsCountsLbl.Size = new System.Drawing.Size(218, 17); this.backupsCountsLbl.Size = new System.Drawing.Size(544, 41);
this.backupsCountsLbl.Text = "[Calculating backed up book quantities]"; this.backupsCountsLbl.Text = "[Calculating backed up book quantities]";
// //
// pdfsCountsLbl // pdfsCountsLbl
// //
this.pdfsCountsLbl.Name = "pdfsCountsLbl"; this.pdfsCountsLbl.Name = "pdfsCountsLbl";
this.pdfsCountsLbl.Size = new System.Drawing.Size(171, 17); this.pdfsCountsLbl.Size = new System.Drawing.Size(426, 41);
this.pdfsCountsLbl.Text = "| [Calculating backed up PDFs]"; this.pdfsCountsLbl.Text = "| [Calculating backed up PDFs]";
// //
// addFilterBtn // addFilterBtn
// //
this.addFilterBtn.Location = new System.Drawing.Point(47, 31); this.addFilterBtn.Location = new System.Drawing.Point(114, 85);
this.addFilterBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.addFilterBtn.Margin = new System.Windows.Forms.Padding(10, 8, 10, 8);
this.addFilterBtn.Name = "addFilterBtn"; this.addFilterBtn.Name = "addFilterBtn";
this.addFilterBtn.Size = new System.Drawing.Size(163, 27); this.addFilterBtn.Size = new System.Drawing.Size(396, 74);
this.addFilterBtn.TabIndex = 4; this.addFilterBtn.TabIndex = 4;
this.addFilterBtn.Text = "Add To Quick Filters"; this.addFilterBtn.Text = "Add To Quick Filters";
this.addFilterBtn.UseVisualStyleBackColor = true; this.addFilterBtn.UseVisualStyleBackColor = true;
this.addFilterBtn.Click += new System.EventHandler(this.AddFilterBtn_Click); this.addFilterBtn.Click += new System.EventHandler(this.AddFilterBtn_Click);
// //
// visibleBooksToolStripMenuItem
//
this.visibleBooksToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.liberateToolStripMenuItem1,
this.replaceTagsToolStripMenuItem,
this.setDownloadedToolStripMenuItem,
this.removeToolStripMenuItem});
this.visibleBooksToolStripMenuItem.Name = "visibleBooksToolStripMenuItem";
this.visibleBooksToolStripMenuItem.Size = new System.Drawing.Size(218, 48);
this.visibleBooksToolStripMenuItem.Text = "&Visible Books";
//
// liberateToolStripMenuItem1
//
this.liberateToolStripMenuItem1.Name = "liberateToolStripMenuItem1";
this.liberateToolStripMenuItem1.Size = new System.Drawing.Size(525, 54);
this.liberateToolStripMenuItem1.Text = "&Liberate";
this.liberateToolStripMenuItem1.Click += new System.EventHandler(this.liberateToolStripMenuItem1_Click);
//
// replaceTagsToolStripMenuItem
//
this.replaceTagsToolStripMenuItem.Name = "replaceTagsToolStripMenuItem";
this.replaceTagsToolStripMenuItem.Size = new System.Drawing.Size(525, 54);
this.replaceTagsToolStripMenuItem.Text = "Replace &Tags...";
this.replaceTagsToolStripMenuItem.Click += new System.EventHandler(this.replaceTagsToolStripMenuItem_Click);
//
// setDownloadedToolStripMenuItem
//
this.setDownloadedToolStripMenuItem.Name = "setDownloadedToolStripMenuItem";
this.setDownloadedToolStripMenuItem.Size = new System.Drawing.Size(525, 54);
this.setDownloadedToolStripMenuItem.Text = "Set \'&Downloaded\' status...";
this.setDownloadedToolStripMenuItem.Click += new System.EventHandler(this.setDownloadedToolStripMenuItem_Click);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(525, 54);
this.removeToolStripMenuItem.Text = "&Remove from library...";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(17F, 41F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1007, 539); this.ClientSize = new System.Drawing.Size(2446, 1473);
this.Controls.Add(this.filterBtn); this.Controls.Add(this.filterBtn);
this.Controls.Add(this.addFilterBtn); this.Controls.Add(this.addFilterBtn);
this.Controls.Add(this.filterSearchTb); this.Controls.Add(this.filterSearchTb);
@ -387,7 +434,7 @@
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.Margin = new System.Windows.Forms.Padding(10, 8, 10, 8);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Libation: Liberate your Library"; this.Text = "Libation: Liberate your Library";
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
@ -438,5 +485,10 @@
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem scanningToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem scanningToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoScanLibraryToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem autoScanLibraryToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem visibleBooksToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem liberateToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem replaceTagsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem setDownloadedToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
} }
} }

View File

@ -18,10 +18,16 @@ namespace LibationWinForms
private string beginBookBackupsToolStripMenuItem_format { get; } private string beginBookBackupsToolStripMenuItem_format { get; }
private string beginPdfBackupsToolStripMenuItem_format { get; } private string beginPdfBackupsToolStripMenuItem_format { get; }
private ProductsGrid productsGrid { get; }
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
productsGrid = new ProductsGrid { Dock = DockStyle.Fill };
gridPanel.Controls.Add(productsGrid);
productsGrid.VisibleCountChanged += setVisibleCount;
// back up string formats // back up string formats
beginBookBackupsToolStripMenuItem_format = beginBookBackupsToolStripMenuItem.Text; beginBookBackupsToolStripMenuItem_format = beginBookBackupsToolStripMenuItem.Text;
beginPdfBackupsToolStripMenuItem_format = beginPdfBackupsToolStripMenuItem.Text; beginPdfBackupsToolStripMenuItem_format = beginPdfBackupsToolStripMenuItem.Text;
@ -44,6 +50,8 @@ namespace LibationWinForms
configAndInitAutoScan(); configAndInitAutoScan();
configVisibleBooksMenu();
// init default/placeholder cover art // init default/placeholder cover art
var format = System.Drawing.Imaging.ImageFormat.Jpeg; var format = System.Drawing.Imaging.ImageFormat.Jpeg;
PictureStorage.SetDefaultImage(PictureSize._80x80, Properties.Resources.default_cover_80x80.ToBytes(format)); PictureStorage.SetDefaultImage(PictureSize._80x80, Properties.Resources.default_cover_80x80.ToBytes(format));
@ -69,43 +77,15 @@ namespace LibationWinForms
// suppressed filter while init'ing UI // suppressed filter while init'ing UI
var prev_isProcessingGridSelect = isProcessingGridSelect; var prev_isProcessingGridSelect = isProcessingGridSelect;
isProcessingGridSelect = true; isProcessingGridSelect = true;
this.UIThreadSync(setGrid); this.UIThreadSync(() => productsGrid.Display());
isProcessingGridSelect = prev_isProcessingGridSelect; isProcessingGridSelect = prev_isProcessingGridSelect;
// UI init complete. now we can apply filter // UI init complete. now we can apply filter
this.UIThreadAsync(() => doFilter(lastGoodFilter)); this.UIThreadAsync(() => doFilter(lastGoodFilter));
setBackupCounts(null, null); setBackupCounts();
} }
#region reload grid
private ProductsGrid productsGrid;
private void setGrid()
{
SuspendLayout();
{
// previous non-null grid with zero-count removes columns. remove/re-add grid to get columns back
if (productsGrid?.Count == 0)
{
gridPanel.Controls.Remove(productsGrid);
productsGrid.VisibleCountChanged -= setVisibleCount;
productsGrid.Dispose();
productsGrid = null;
}
if (productsGrid is null)
{
productsGrid = new ProductsGrid { Dock = DockStyle.Fill };
productsGrid.VisibleCountChanged += setVisibleCount;
gridPanel.UIThreadSync(() => gridPanel.Controls.Add(productsGrid));
}
productsGrid.Display();
}
ResumeLayout();
}
#endregion
#region bottom: qty books visible #region bottom: qty books visible
private void setVisibleCount(object _, int qty) => visibleCountLbl.Text = string.Format("Visible: {0}", qty); private void setVisibleCount(object _, int qty) => visibleCountLbl.Text = string.Format("Visible: {0}", qty);
#endregion #endregion
@ -114,7 +94,7 @@ namespace LibationWinForms
private System.ComponentModel.BackgroundWorker updateCountsBw; private System.ComponentModel.BackgroundWorker updateCountsBw;
private bool runBackupCountsAgain; private bool runBackupCountsAgain;
private void setBackupCounts(object _, object __) private void setBackupCounts(object _ = null, object __ = null)
{ {
runBackupCountsAgain = true; runBackupCountsAgain = true;
@ -537,6 +517,41 @@ namespace LibationWinForms
private void EditQuickFiltersToolStripMenuItem_Click(object sender, EventArgs e) => new EditQuickFilters(this).ShowDialog(); private void EditQuickFiltersToolStripMenuItem_Click(object sender, EventArgs e) => new EditQuickFilters(this).ShowDialog();
#endregion #endregion
#region Visible Books menu
private void configVisibleBooksMenu()
{
}
private async void liberateToolStripMenuItem1_Click(object sender, EventArgs e)
{
var visibleBooks = productsGrid.GetVisible().ToList();
await BookLiberation.ProcessorAutomationController.BackupAllBooksAsync(visibleBooks);
}
private void replaceTagsToolStripMenuItem_Click(object sender, EventArgs e)
{
var visibleLibraryBooks = productsGrid.GetVisible().ToList();
foreach (var libraryBook in visibleLibraryBooks)
libraryBook.Book.UserDefinedItem.Tags = "ggggg";
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
}
private void setDownloadedToolStripMenuItem_Click(object sender, EventArgs e)
{
var visibleLibraryBooks = productsGrid.GetVisible().ToList();
foreach (var libraryBook in visibleLibraryBooks)
libraryBook.Book.UserDefinedItem.BookStatus = DataLayer.LiberatedStatus.NotLiberated;
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
}
private async void removeToolStripMenuItem_Click(object sender, EventArgs e)
{
var visibleIds = productsGrid.GetVisible().Select(lb => lb.Book.AudibleProductId).ToList();
await LibraryCommands.RemoveBooksAsync(visibleIds);
}
#endregion
#region Settings menu #region Settings menu
private void accountsToolStripMenuItem_Click(object sender, EventArgs e) => new AccountsDialog(this).ShowDialog(); private void accountsToolStripMenuItem_Click(object sender, EventArgs e) => new AccountsDialog(this).ShowDialog();

View File

@ -14,6 +14,7 @@ using LibationWinForms.Dialogs;
namespace LibationWinForms namespace LibationWinForms
{ {
#region // legacy instructions to update data_grid_view
// INSTRUCTIONS TO UPDATE DATA_GRID_VIEW // INSTRUCTIONS TO UPDATE DATA_GRID_VIEW
// - delete current DataGridView // - delete current DataGridView
// - view > other windows > data sources // - view > other windows > data sources
@ -27,7 +28,10 @@ namespace LibationWinForms
// - go to Design view // - go to Design view
// - click on Data Sources > ProductItem. dropdown: DataGridView // - click on Data Sources > ProductItem. dropdown: DataGridView
// - drag/drop ProductItem on design surface // - drag/drop ProductItem on design surface
// AS OF AUGUST 2021 THIS DOES NOT WORK IN VS2019 WITH .NET-5 PROJECTS //
// as of august 2021 this does not work in vs2019 with .net5 projects
// VS has improved since then with .net6+ but I haven't checked again
#endregion
public partial class ProductsGrid : UserControl public partial class ProductsGrid : UserControl
{ {
@ -44,6 +48,8 @@ namespace LibationWinForms
_dataGridView.Sorted += Filter; _dataGridView.Sorted += Filter;
_dataGridView.CellContentClick += DataGridView_CellContentClick; _dataGridView.CellContentClick += DataGridView_CellContentClick;
this.Load += ProductsGrid_Load;
EnableDoubleBuffering(); EnableDoubleBuffering();
} }
@ -122,24 +128,13 @@ namespace LibationWinForms
#region UI display functions #region UI display functions
public int Count { get; private set; }
private SortableBindingList<GridEntry> bindingList; private SortableBindingList<GridEntry> bindingList;
public void Display() public void Display()
{ {
// don't return early if lib size == 0. this will not update correctly if all books are removed
var lib = DbContexts.GetLibrary_Flat_NoTracking(); var lib = DbContexts.GetLibrary_Flat_NoTracking();
Count = lib.Count;
// if no data. hide all columns. return
if (!lib.Any())
{
for (var i = _dataGridView.ColumnCount - 1; i >= 0; i--)
_dataGridView.Columns.RemoveAt(i);
return;
}
var orderedBooks = lib var orderedBooks = lib
// default load order // default load order
.OrderByDescending(lb => lb.DateAdded) .OrderByDescending(lb => lb.DateAdded)
@ -150,10 +145,10 @@ namespace LibationWinForms
.ToList(); .ToList();
// BIND // BIND
if (bindingList is null) if (bindingList?.Count > 0)
bindToGrid(orderedBooks);
else
updateGrid(orderedBooks); updateGrid(orderedBooks);
else
bindToGrid(orderedBooks);
// FILTER // FILTER
Filter(); Filter();
@ -245,7 +240,8 @@ namespace LibationWinForms
#region Column Customizations #region Column Customizations
protected override void OnVisibleChanged(EventArgs e) // to ensure this is only ever called once: Load instead of 'override OnVisibleChanged'
private void ProductsGrid_Load(object sender, EventArgs e)
{ {
contextMenuStrip1.Items.Add(new ToolStripLabel("Show / Hide Columns")); contextMenuStrip1.Items.Add(new ToolStripLabel("Show / Hide Columns"));
contextMenuStrip1.Items.Add(new ToolStripSeparator()); contextMenuStrip1.Items.Add(new ToolStripSeparator());