mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-13 14:17:15 -04:00
WinForms gets the same per-row button and dialog Chardonnay has, and its scan picker lists an account's marketplaces for the same reason. list-accounts grows an 'Also scans' column, because printing one locale for an account that reads three misreports what a scan will do. It appears only when some account has more than one marketplace, so the ordinary table is unchanged; --bare always emits the field, last, so a script reading the first five keeps working. Compile-checked only for WinForms: it builds on Linux via EnableWindowsTargeting but cannot run there, so the new dialog's layout still needs a look on Windows. Co-authored-by: rmcrackan <rmcrackan@gmail.com>
71 lines
1.6 KiB
C#
71 lines
1.6 KiB
C#
using AudibleUtilities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
|
|
namespace LibationWinForms.Dialogs;
|
|
|
|
public partial class ScanAccountsDialog : Form
|
|
{
|
|
public List<Account> CheckedAccounts { get; } = new List<Account>();
|
|
|
|
public ScanAccountsDialog()
|
|
{
|
|
InitializeComponent();
|
|
this.SetLibationIcon();
|
|
}
|
|
|
|
private class listItem
|
|
{
|
|
public Account? Account { get; set; }
|
|
public string? Text { get; set; }
|
|
public override string? ToString() => Text;
|
|
}
|
|
private void ScanAccountsDialog_Load(object sender, EventArgs e)
|
|
{
|
|
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
|
var accounts = persister.AccountsSettings.Accounts;
|
|
|
|
foreach (var account in accounts)
|
|
{
|
|
var item = new listItem
|
|
{
|
|
Account = account,
|
|
// lists every marketplace: one checkbox here can scan more than one
|
|
Text = LibationUiBase.MarketplacesUi.ScanPickerText(account)
|
|
};
|
|
this.accountsClb.Items.Add(item, account.LibraryScan);
|
|
}
|
|
}
|
|
|
|
private void editBtn_Click(object sender, EventArgs e)
|
|
{
|
|
if (new AccountsDialog().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)
|
|
{
|
|
foreach (listItem item in accountsClb.CheckedItems)
|
|
{
|
|
if (item.Account != null)
|
|
CheckedAccounts.Add(item.Account);
|
|
}
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
|
|
private void cancelBtn_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
}
|