account management UI
This commit is contained in:
parent
e9e380dbe6
commit
743644c4e9
8 changed files with 132 additions and 84 deletions
|
|
@ -35,8 +35,8 @@
|
|||
this.DeleteAccount = new System.Windows.Forms.DataGridViewButtonColumn();
|
||||
this.LibraryScan = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.AccountId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.AccountName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Locale = new System.Windows.Forms.DataGridViewComboBoxColumn();
|
||||
this.AccountName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
|
@ -75,8 +75,8 @@
|
|||
this.DeleteAccount,
|
||||
this.LibraryScan,
|
||||
this.AccountId,
|
||||
this.AccountName,
|
||||
this.Locale});
|
||||
this.Locale,
|
||||
this.AccountName});
|
||||
this.dataGridView1.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView1.MultiSelect = false;
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
|
|
@ -118,18 +118,18 @@
|
|||
this.AccountId.Name = "AccountId";
|
||||
this.AccountId.Width = 111;
|
||||
//
|
||||
// AccountName
|
||||
//
|
||||
this.AccountName.HeaderText = "Account nickname (optional)";
|
||||
this.AccountName.Name = "AccountName";
|
||||
this.AccountName.Width = 152;
|
||||
//
|
||||
// Locale
|
||||
//
|
||||
this.Locale.HeaderText = "Locale";
|
||||
this.Locale.Name = "Locale";
|
||||
this.Locale.Width = 45;
|
||||
//
|
||||
// AccountName
|
||||
//
|
||||
this.AccountName.HeaderText = "Account nickname (optional)";
|
||||
this.AccountName.Name = "AccountName";
|
||||
this.AccountName.Width = 152;
|
||||
//
|
||||
// AccountsDialog
|
||||
//
|
||||
this.AcceptButton = this.saveBtn;
|
||||
|
|
@ -156,7 +156,7 @@
|
|||
private System.Windows.Forms.DataGridViewButtonColumn DeleteAccount;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn LibraryScan;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn AccountId;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn AccountName;
|
||||
private System.Windows.Forms.DataGridViewComboBoxColumn Locale;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn AccountName;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +1,99 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using AudibleApi;
|
||||
using FileManager;
|
||||
using InternalUtilities;
|
||||
|
||||
namespace LibationWinForms.Dialogs
|
||||
{
|
||||
public partial class AccountsDialog : Form
|
||||
{
|
||||
const string COL_Original = "Original";
|
||||
const string COL_Delete = "Delete";
|
||||
const string COL_Filter = "Filter";
|
||||
const string COL_MoveUp = "MoveUp";
|
||||
const string COL_MoveDown = "MoveDown";
|
||||
const string NON_BREAKING_SPACE = "\u00a0";
|
||||
|
||||
const string COL_Original = nameof(Original);
|
||||
const string COL_Delete = nameof(DeleteAccount);
|
||||
const string COL_LibraryScan = nameof(LibraryScan);
|
||||
const string COL_AccountId = nameof(AccountId);
|
||||
const string COL_AccountName = nameof(AccountName);
|
||||
const string COL_Locale = nameof(Locale);
|
||||
|
||||
public AccountsDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
dataGridView1.Columns[COL_AccountName].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
populateDropDown();
|
||||
|
||||
populateGridValues();
|
||||
}
|
||||
|
||||
private void populateDropDown()
|
||||
=> (dataGridView1.Columns[COL_Locale] as DataGridViewComboBoxColumn).DataSource
|
||||
= Localization.Locales
|
||||
.Select(l => l.Name)
|
||||
.OrderBy(a => a).ToList();
|
||||
|
||||
private void populateGridValues()
|
||||
{
|
||||
var accounts = AudibleApiStorage.GetAccounts().AccountsSettings;
|
||||
if (!accounts.Any())
|
||||
return;
|
||||
|
||||
foreach (var account in accounts)
|
||||
dataGridView1.Rows.Add(
|
||||
new { account.AccountId, account.Locale.Name },
|
||||
"X",
|
||||
account.LibraryScan,
|
||||
account.AccountId,
|
||||
account.Locale.Name,
|
||||
account.AccountName);
|
||||
}
|
||||
|
||||
private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
|
||||
{
|
||||
e.Row.Cells[COL_Delete].Value = "X";
|
||||
e.Row.Cells[COL_LibraryScan].Value = true;
|
||||
}
|
||||
|
||||
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var dgv = (DataGridView)sender;
|
||||
|
||||
var col = dgv.Columns[e.ColumnIndex];
|
||||
if (col is DataGridViewButtonColumn && e.RowIndex >= 0)
|
||||
{
|
||||
var row = dgv.Rows[e.RowIndex];
|
||||
switch (col.Name)
|
||||
{
|
||||
case COL_Delete:
|
||||
// if final/edit row: do nothing
|
||||
if (e.RowIndex < dgv.RowCount - 1)
|
||||
dgv.Rows.Remove(row);
|
||||
break;
|
||||
//case COL_MoveUp:
|
||||
// // if top: do nothing
|
||||
// if (e.RowIndex < 1)
|
||||
// break;
|
||||
// dgv.Rows.Remove(row);
|
||||
// dgv.Rows.Insert(e.RowIndex - 1, row);
|
||||
// break;
|
||||
//case COL_MoveDown:
|
||||
// // if final/edit row or bottom filter row: do nothing
|
||||
// if (e.RowIndex >= dgv.RowCount - 2)
|
||||
// break;
|
||||
// dgv.Rows.Remove(row);
|
||||
// dgv.Rows.Insert(e.RowIndex + 1, row);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelBtn_Click(object sender, EventArgs e) => this.Close();
|
||||
|
||||
#region TEMP
|
||||
|
||||
private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
//e.Row.Cells["Region"].Value = "WA";
|
||||
//e.Row.Cells["CustomerID"].Value = NewCustomerId();
|
||||
}
|
||||
|
||||
private void saveBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
|
@ -65,39 +128,6 @@ namespace LibationWinForms.Dialogs
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
//var dgv = (DataGridView)sender;
|
||||
|
||||
//var col = dgv.Columns[e.ColumnIndex];
|
||||
//if (col is DataGridViewButtonColumn && e.RowIndex >= 0)
|
||||
//{
|
||||
// var row = dgv.Rows[e.RowIndex];
|
||||
// switch (col.Name)
|
||||
// {
|
||||
// case COL_Delete:
|
||||
// // if final/edit row: do nothing
|
||||
// if (e.RowIndex < dgv.RowCount - 1)
|
||||
// dgv.Rows.Remove(row);
|
||||
// break;
|
||||
// case COL_MoveUp:
|
||||
// // if top: do nothing
|
||||
// if (e.RowIndex < 1)
|
||||
// break;
|
||||
// dgv.Rows.Remove(row);
|
||||
// dgv.Rows.Insert(e.RowIndex - 1, row);
|
||||
// break;
|
||||
// case COL_MoveDown:
|
||||
// // if final/edit row or bottom filter row: do nothing
|
||||
// if (e.RowIndex >= dgv.RowCount - 2)
|
||||
// break;
|
||||
// dgv.Rows.Remove(row);
|
||||
// dgv.Rows.Insert(e.RowIndex + 1, row);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@
|
|||
this.dataGridView1.Size = new System.Drawing.Size(776, 397);
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView1_CellContentClick);
|
||||
this.dataGridView1.DefaultValuesNeeded += new System.Windows.Forms.DataGridViewRowEventHandler(this.dataGridView1_DefaultValuesNeeded);
|
||||
//
|
||||
// Original
|
||||
//
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ namespace LibationWinForms.Dialogs
|
|||
const string BLACK_UP_POINTING_TRIANGLE = "\u25B2";
|
||||
const string BLACK_DOWN_POINTING_TRIANGLE = "\u25BC";
|
||||
|
||||
const string COL_Original = "Original";
|
||||
const string COL_Delete = "Delete";
|
||||
const string COL_Filter = "Filter";
|
||||
const string COL_MoveUp = "MoveUp";
|
||||
const string COL_MoveDown = "MoveDown";
|
||||
const string COL_Original = nameof(Original);
|
||||
const string COL_Delete = nameof(Delete);
|
||||
const string COL_Filter = nameof(Filter);
|
||||
const string COL_MoveUp = nameof(MoveUp);
|
||||
const string COL_MoveDown = nameof(MoveDown);
|
||||
|
||||
Form1 _parent { get; }
|
||||
|
||||
|
|
@ -26,10 +26,10 @@ namespace LibationWinForms.Dialogs
|
|||
|
||||
dataGridView1.Columns[COL_Filter].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
populateFilters();
|
||||
populateGridValues();
|
||||
}
|
||||
|
||||
private void populateFilters()
|
||||
private void populateGridValues()
|
||||
{
|
||||
var filters = QuickFilters.Filters;
|
||||
if (!filters.Any())
|
||||
|
|
@ -39,6 +39,13 @@ namespace LibationWinForms.Dialogs
|
|||
dataGridView1.Rows.Add(filter, "X", filter, BLACK_UP_POINTING_TRIANGLE, BLACK_DOWN_POINTING_TRIANGLE);
|
||||
}
|
||||
|
||||
private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
|
||||
{
|
||||
e.Row.Cells[COL_Delete].Value = "X";
|
||||
e.Row.Cells[COL_MoveUp].Value = BLACK_UP_POINTING_TRIANGLE;
|
||||
e.Row.Cells[COL_MoveDown].Value = BLACK_DOWN_POINTING_TRIANGLE;
|
||||
}
|
||||
|
||||
private void saveBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
var list = dataGridView1.Rows
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue