Accounts are editable from ScanAccountsDialog via new edit button

This commit is contained in:
Robert McRackan 2020-08-27 11:36:38 -04:00
parent 0025825d5c
commit 99cc6a6425
9 changed files with 67 additions and 20 deletions

View File

@ -13,7 +13,7 @@
<!-- <PublishSingleFile>true</PublishSingleFile> --> <!-- <PublishSingleFile>true</PublishSingleFile> -->
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Version>3.1.12.299</Version> <Version>3.1.12.300</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -15,8 +15,12 @@ namespace LibationWinForms.Dialogs
const string COL_AccountName = nameof(AccountName); const string COL_AccountName = nameof(AccountName);
const string COL_Locale = nameof(Locale); const string COL_Locale = nameof(Locale);
public AccountsDialog() Form1 _parent { get; }
public AccountsDialog(Form1 parent)
{ {
_parent = parent;
InitializeComponent(); InitializeComponent();
dataGridView1.Columns[COL_AccountName].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView1.Columns[COL_AccountName].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
@ -111,6 +115,7 @@ namespace LibationWinForms.Dialogs
persister.CommitTransation(); persister.CommitTransation();
_parent.RefreshImportMenu();
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;
this.Close(); this.Close();
} }

View File

@ -55,6 +55,7 @@ namespace LibationWinForms.Dialogs
QuickFilters.ReplaceAll(list); QuickFilters.ReplaceAll(list);
_parent.UpdateFilterDropDown(); _parent.UpdateFilterDropDown();
this.DialogResult = DialogResult.OK;
this.Close(); this.Close();
} }

View File

@ -32,6 +32,7 @@
this.accountsClb = new System.Windows.Forms.CheckedListBox(); this.accountsClb = new System.Windows.Forms.CheckedListBox();
this.importBtn = new System.Windows.Forms.Button(); this.importBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button();
this.editBtn = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// accountsLbl // accountsLbl
@ -61,7 +62,7 @@
this.importBtn.Location = new System.Drawing.Point(396, 125); this.importBtn.Location = new System.Drawing.Point(396, 125);
this.importBtn.Name = "importBtn"; this.importBtn.Name = "importBtn";
this.importBtn.Size = new System.Drawing.Size(75, 23); this.importBtn.Size = new System.Drawing.Size(75, 23);
this.importBtn.TabIndex = 2; this.importBtn.TabIndex = 3;
this.importBtn.Text = "Import"; this.importBtn.Text = "Import";
this.importBtn.UseVisualStyleBackColor = true; this.importBtn.UseVisualStyleBackColor = true;
this.importBtn.Click += new System.EventHandler(this.importBtn_Click); this.importBtn.Click += new System.EventHandler(this.importBtn_Click);
@ -73,11 +74,22 @@
this.cancelBtn.Location = new System.Drawing.Point(497, 125); this.cancelBtn.Location = new System.Drawing.Point(497, 125);
this.cancelBtn.Name = "cancelBtn"; this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(75, 23); this.cancelBtn.Size = new System.Drawing.Size(75, 23);
this.cancelBtn.TabIndex = 3; this.cancelBtn.TabIndex = 4;
this.cancelBtn.Text = "Cancel"; this.cancelBtn.Text = "Cancel";
this.cancelBtn.UseVisualStyleBackColor = true; this.cancelBtn.UseVisualStyleBackColor = true;
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click); this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
// //
// editBtn
//
this.editBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.editBtn.Location = new System.Drawing.Point(12, 125);
this.editBtn.Name = "editBtn";
this.editBtn.Size = new System.Drawing.Size(90, 23);
this.editBtn.TabIndex = 2;
this.editBtn.Text = "Edit accounts";
this.editBtn.UseVisualStyleBackColor = true;
this.editBtn.Click += new System.EventHandler(this.editBtn_Click);
//
// ScanAccountsDialog // ScanAccountsDialog
// //
this.AcceptButton = this.importBtn; this.AcceptButton = this.importBtn;
@ -85,6 +97,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelBtn; this.CancelButton = this.cancelBtn;
this.ClientSize = new System.Drawing.Size(584, 160); this.ClientSize = new System.Drawing.Size(584, 160);
this.Controls.Add(this.editBtn);
this.Controls.Add(this.cancelBtn); this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.importBtn); this.Controls.Add(this.importBtn);
this.Controls.Add(this.accountsClb); this.Controls.Add(this.accountsClb);
@ -103,5 +116,6 @@
private System.Windows.Forms.CheckedListBox accountsClb; private System.Windows.Forms.CheckedListBox accountsClb;
private System.Windows.Forms.Button importBtn; private System.Windows.Forms.Button importBtn;
private System.Windows.Forms.Button cancelBtn; private System.Windows.Forms.Button cancelBtn;
private System.Windows.Forms.Button editBtn;
} }
} }

View File

@ -12,8 +12,12 @@ namespace LibationWinForms.Dialogs
{ {
public List<Account> CheckedAccounts { get; } = new List<Account>(); public List<Account> CheckedAccounts { get; } = new List<Account>();
public ScanAccountsDialog() Form1 _parent { get; }
public ScanAccountsDialog(Form1 parent)
{ {
_parent = parent;
InitializeComponent(); InitializeComponent();
} }
@ -25,6 +29,8 @@ namespace LibationWinForms.Dialogs
} }
private void ScanAccountsDialog_Load(object sender, EventArgs e) private void ScanAccountsDialog_Load(object sender, EventArgs e)
{ {
// DO NOT dispose of this connection.
// Here we (clumsily) connect to the persistent file. Accounts returned from here are used throughout library scan INCLUDING updates. eg: identity tokens
var accounts = AudibleApiStorage.GetPersistentAccountsSettings().Accounts; var accounts = AudibleApiStorage.GetPersistentAccountsSettings().Accounts;
foreach (var account in accounts) foreach (var account in accounts)
@ -34,6 +40,18 @@ namespace LibationWinForms.Dialogs
} }
} }
private void editBtn_Click(object sender, EventArgs e)
{
if (new AccountsDialog(_parent).ShowDialog()== DialogResult.OK)
{
// clear grid
this.accountsClb.Items.Clear();
// reload grid and default checkboxes
ScanAccountsDialog_Load(sender, e);
}
}
private void importBtn_Click(object sender, EventArgs e) private void importBtn_Click(object sender, EventArgs e)
{ {
foreach (listItem item in accountsClb.CheckedItems) foreach (listItem item in accountsClb.CheckedItems)

View File

@ -43,7 +43,7 @@ namespace LibationWinForms
PictureStorage.SetDefaultImage(PictureSize._300x300, Properties.Resources.default_cover_300x300.ToBytes(format)); PictureStorage.SetDefaultImage(PictureSize._300x300, Properties.Resources.default_cover_300x300.ToBytes(format));
PictureStorage.SetDefaultImage(PictureSize._500x500, Properties.Resources.default_cover_500x500.ToBytes(format)); PictureStorage.SetDefaultImage(PictureSize._500x500, Properties.Resources.default_cover_500x500.ToBytes(format));
setImportMenu(); RefreshImportMenu();
setVisibleCount(null, 0); setVisibleCount(null, 0);
@ -182,7 +182,7 @@ namespace LibationWinForms
#endregion #endregion
#region filter #region filter
private void filterHelpBtn_Click(object sender, EventArgs e) => new Dialogs.SearchSyntaxDialog().ShowDialog(); private void filterHelpBtn_Click(object sender, EventArgs e) => new SearchSyntaxDialog().ShowDialog();
private void AddFilterBtn_Click(object sender, EventArgs e) private void AddFilterBtn_Click(object sender, EventArgs e)
{ {
@ -229,7 +229,7 @@ namespace LibationWinForms
#endregion #endregion
#region Import menu #region Import menu
private void setImportMenu() public void RefreshImportMenu()
{ {
var count = AudibleApiStorage.GetPersistentAccountsSettings().Accounts.Count; var count = AudibleApiStorage.GetPersistentAccountsSettings().Accounts.Count;
@ -242,7 +242,7 @@ namespace LibationWinForms
private void noAccountsYetAddAccountToolStripMenuItem_Click(object sender, EventArgs e) private void noAccountsYetAddAccountToolStripMenuItem_Click(object sender, EventArgs e)
{ {
MessageBox.Show("To load your Audible library, come back here to the Import menu after adding your account"); MessageBox.Show("To load your Audible library, come back here to the Import menu after adding your account");
accountsToolStripMenuItem_Click(sender, e); new AccountsDialog(this).ShowDialog();
} }
private void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e) private void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e)
@ -259,7 +259,7 @@ namespace LibationWinForms
private void scanLibraryOfSomeAccountsToolStripMenuItem_Click(object sender, EventArgs e) private void scanLibraryOfSomeAccountsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
using var scanAccountsDialog = new ScanAccountsDialog(); using var scanAccountsDialog = new ScanAccountsDialog(this);
if (scanAccountsDialog.ShowDialog() != DialogResult.OK) if (scanAccountsDialog.ShowDialog() != DialogResult.OK)
return; return;
@ -341,15 +341,11 @@ namespace LibationWinForms
} }
} }
private void EditQuickFiltersToolStripMenuItem_Click(object sender, EventArgs e) => new Dialogs.EditQuickFilters(this).ShowDialog(); private void EditQuickFiltersToolStripMenuItem_Click(object sender, EventArgs e) => new EditQuickFilters(this).ShowDialog();
#endregion #endregion
#region settings menu #region settings menu
private void accountsToolStripMenuItem_Click(object sender, EventArgs e) private void accountsToolStripMenuItem_Click(object sender, EventArgs e) => new AccountsDialog(this).ShowDialog();
{
new AccountsDialog().ShowDialog();
setImportMenu();
}
private void basicSettingsToolStripMenuItem_Click(object sender, EventArgs e) => new SettingsDialog().ShowDialog(); private void basicSettingsToolStripMenuItem_Click(object sender, EventArgs e) => new SettingsDialog().ShowDialog();

View File

@ -5,7 +5,7 @@ namespace WinFormsDesigner.Dialogs
{ {
public partial class AccountsDialog : Form public partial class AccountsDialog : Form
{ {
public AccountsDialog() public AccountsDialog(Form1 parent)
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -32,6 +32,7 @@
this.accountsClb = new System.Windows.Forms.CheckedListBox(); this.accountsClb = new System.Windows.Forms.CheckedListBox();
this.importBtn = new System.Windows.Forms.Button(); this.importBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button();
this.editBtn = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// accountsLbl // accountsLbl
@ -61,7 +62,7 @@
this.importBtn.Location = new System.Drawing.Point(396, 125); this.importBtn.Location = new System.Drawing.Point(396, 125);
this.importBtn.Name = "importBtn"; this.importBtn.Name = "importBtn";
this.importBtn.Size = new System.Drawing.Size(75, 23); this.importBtn.Size = new System.Drawing.Size(75, 23);
this.importBtn.TabIndex = 2; this.importBtn.TabIndex = 3;
this.importBtn.Text = "Import"; this.importBtn.Text = "Import";
this.importBtn.UseVisualStyleBackColor = true; this.importBtn.UseVisualStyleBackColor = true;
// //
@ -72,10 +73,20 @@
this.cancelBtn.Location = new System.Drawing.Point(497, 125); this.cancelBtn.Location = new System.Drawing.Point(497, 125);
this.cancelBtn.Name = "cancelBtn"; this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(75, 23); this.cancelBtn.Size = new System.Drawing.Size(75, 23);
this.cancelBtn.TabIndex = 3; this.cancelBtn.TabIndex = 4;
this.cancelBtn.Text = "Cancel"; this.cancelBtn.Text = "Cancel";
this.cancelBtn.UseVisualStyleBackColor = true; this.cancelBtn.UseVisualStyleBackColor = true;
// //
// editBtn
//
this.editBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.editBtn.Location = new System.Drawing.Point(12, 125);
this.editBtn.Name = "editBtn";
this.editBtn.Size = new System.Drawing.Size(90, 23);
this.editBtn.TabIndex = 2;
this.editBtn.Text = "Edit accounts";
this.editBtn.UseVisualStyleBackColor = true;
//
// ScanAccountsDialog // ScanAccountsDialog
// //
this.AcceptButton = this.importBtn; this.AcceptButton = this.importBtn;
@ -83,6 +94,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelBtn; this.CancelButton = this.cancelBtn;
this.ClientSize = new System.Drawing.Size(584, 160); this.ClientSize = new System.Drawing.Size(584, 160);
this.Controls.Add(this.editBtn);
this.Controls.Add(this.cancelBtn); this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.importBtn); this.Controls.Add(this.importBtn);
this.Controls.Add(this.accountsClb); this.Controls.Add(this.accountsClb);
@ -100,5 +112,6 @@
private System.Windows.Forms.CheckedListBox accountsClb; private System.Windows.Forms.CheckedListBox accountsClb;
private System.Windows.Forms.Button importBtn; private System.Windows.Forms.Button importBtn;
private System.Windows.Forms.Button cancelBtn; private System.Windows.Forms.Button cancelBtn;
private System.Windows.Forms.Button editBtn;
} }
} }

View File

@ -12,7 +12,7 @@ namespace WinFormsDesigner.Dialogs
{ {
public partial class ScanAccountsDialog : Form public partial class ScanAccountsDialog : Form
{ {
public ScanAccountsDialog() public ScanAccountsDialog(Form1 parent)
{ {
InitializeComponent(); InitializeComponent();
} }