Add binding source at design time
This commit is contained in:
parent
593fe57ea1
commit
440550ded9
@ -21,7 +21,7 @@ namespace LibationWinForms
|
|||||||
{
|
{
|
||||||
if (rowIndex >= 0 && DataGridView.GetBoundItem<GridEntry>(rowIndex) is SeriesEntry)
|
if (rowIndex >= 0 && DataGridView.GetBoundItem<GridEntry>(rowIndex) is SeriesEntry)
|
||||||
{
|
{
|
||||||
base.Paint(graphics, clipBounds, cellBounds, rowIndex, DataGridViewElementStates.None, null, null, null, cellStyle, advancedBorderStyle, DataGridViewPaintParts.Background | DataGridViewPaintParts.Border);
|
base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, null, null, null, cellStyle, advancedBorderStyle, DataGridViewPaintParts.Background | DataGridViewPaintParts.Border);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,13 +25,11 @@ namespace LibationWinForms
|
|||||||
if (status.IsSeries)
|
if (status.IsSeries)
|
||||||
{
|
{
|
||||||
var imageName = status.Expanded ? "minus" : "plus";
|
var imageName = status.Expanded ? "minus" : "plus";
|
||||||
var text = status.Expanded ? "Click to Collpase" : "Click to Expand";
|
|
||||||
|
|
||||||
var bmp = (Bitmap)Properties.Resources.ResourceManager.GetObject(imageName);
|
var bmp = (Bitmap)Properties.Resources.ResourceManager.GetObject(imageName);
|
||||||
DrawButtonImage(graphics, bmp, cellBounds);
|
DrawButtonImage(graphics, bmp, cellBounds);
|
||||||
|
|
||||||
ToolTipText = text;
|
ToolTipText = status.Expanded ? "Click to Collpase" : "Click to Expand";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -53,7 +53,6 @@
|
|||||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.Name = "ProductsDisplay";
|
this.Name = "ProductsDisplay";
|
||||||
this.Size = new System.Drawing.Size(1510, 380);
|
this.Size = new System.Drawing.Size(1510, 380);
|
||||||
this.Load += new System.EventHandler(this.ProductsDisplay_Load);
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,23 +14,18 @@ namespace LibationWinForms
|
|||||||
{
|
{
|
||||||
public partial class ProductsDisplay : UserControl
|
public partial class ProductsDisplay : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler<LibraryBook> LiberateClicked;
|
|
||||||
/// <summary>Number of visible rows has changed</summary>
|
/// <summary>Number of visible rows has changed</summary>
|
||||||
public event EventHandler<int> VisibleCountChanged;
|
public event EventHandler<int> VisibleCountChanged;
|
||||||
|
public event EventHandler<LibraryBook> LiberateClicked;
|
||||||
|
public event EventHandler InitialLoaded;
|
||||||
|
|
||||||
|
private bool hasBeenDisplayed;
|
||||||
|
|
||||||
public ProductsDisplay()
|
public ProductsDisplay()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProductsDisplay_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (DesignMode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region Button controls
|
#region Button controls
|
||||||
|
|
||||||
private ImageDisplay imageDisplay;
|
private ImageDisplay imageDisplay;
|
||||||
@ -76,7 +71,6 @@ namespace LibationWinForms
|
|||||||
displayWindow.Show(this);
|
displayWindow.Show(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void productsGrid_DetailsClicked(LibraryBookEntry liveGridEntry)
|
private void productsGrid_DetailsClicked(LibraryBookEntry liveGridEntry)
|
||||||
{
|
{
|
||||||
var bookDetailsForm = new BookDetailsDialog(liveGridEntry.LibraryBook);
|
var bookDetailsForm = new BookDetailsDialog(liveGridEntry.LibraryBook);
|
||||||
@ -88,8 +82,6 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
#region UI display functions
|
#region UI display functions
|
||||||
|
|
||||||
private bool hasBeenDisplayed;
|
|
||||||
public event EventHandler InitialLoaded;
|
|
||||||
public void Display()
|
public void Display()
|
||||||
{
|
{
|
||||||
// don't return early if lib size == 0. this will not update correctly if all books are removed
|
// don't return early if lib size == 0. this will not update correctly if all books are removed
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
this.gridEntryDataGridView = new System.Windows.Forms.DataGridView();
|
this.gridEntryDataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.liberateGVColumn = new LibationWinForms.LiberateDataGridViewImageButtonColumn();
|
this.liberateGVColumn = new LibationWinForms.LiberateDataGridViewImageButtonColumn();
|
||||||
this.coverGVColumn = new System.Windows.Forms.DataGridViewImageColumn();
|
this.coverGVColumn = new System.Windows.Forms.DataGridViewImageColumn();
|
||||||
@ -46,7 +46,11 @@
|
|||||||
this.miscGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.miscGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.tagAndDetailsGVColumn = new LibationWinForms.EditTagsDataGridViewImageButtonColumn();
|
this.tagAndDetailsGVColumn = new LibationWinForms.EditTagsDataGridViewImageButtonColumn();
|
||||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.syncBindingSource = new LibationWinForms.SyncBindingSource(this.components);
|
||||||
|
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.syncBindingSource)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// gridEntryDataGridView
|
// gridEntryDataGridView
|
||||||
@ -55,6 +59,7 @@
|
|||||||
this.gridEntryDataGridView.AllowUserToDeleteRows = false;
|
this.gridEntryDataGridView.AllowUserToDeleteRows = false;
|
||||||
this.gridEntryDataGridView.AllowUserToOrderColumns = true;
|
this.gridEntryDataGridView.AllowUserToOrderColumns = true;
|
||||||
this.gridEntryDataGridView.AllowUserToResizeRows = false;
|
this.gridEntryDataGridView.AllowUserToResizeRows = false;
|
||||||
|
this.gridEntryDataGridView.AutoGenerateColumns = false;
|
||||||
this.gridEntryDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.gridEntryDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.gridEntryDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
this.gridEntryDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
this.liberateGVColumn,
|
this.liberateGVColumn,
|
||||||
@ -72,14 +77,15 @@
|
|||||||
this.miscGVColumn,
|
this.miscGVColumn,
|
||||||
this.tagAndDetailsGVColumn});
|
this.tagAndDetailsGVColumn});
|
||||||
this.gridEntryDataGridView.ContextMenuStrip = this.contextMenuStrip1;
|
this.gridEntryDataGridView.ContextMenuStrip = this.contextMenuStrip1;
|
||||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
this.gridEntryDataGridView.DataSource = this.syncBindingSource;
|
||||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
|
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
|
||||||
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
|
dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||||
this.gridEntryDataGridView.DefaultCellStyle = dataGridViewCellStyle1;
|
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
|
this.gridEntryDataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
||||||
this.gridEntryDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.gridEntryDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.gridEntryDataGridView.Location = new System.Drawing.Point(0, 0);
|
this.gridEntryDataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
this.gridEntryDataGridView.Name = "gridEntryDataGridView";
|
this.gridEntryDataGridView.Name = "gridEntryDataGridView";
|
||||||
@ -90,7 +96,6 @@
|
|||||||
this.gridEntryDataGridView.TabIndex = 0;
|
this.gridEntryDataGridView.TabIndex = 0;
|
||||||
this.gridEntryDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellContentClick);
|
this.gridEntryDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellContentClick);
|
||||||
this.gridEntryDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.gridEntryDataGridView_CellToolTipTextNeeded);
|
this.gridEntryDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.gridEntryDataGridView_CellToolTipTextNeeded);
|
||||||
this.gridEntryDataGridView.ColumnDisplayIndexChanged += new System.Windows.Forms.DataGridViewColumnEventHandler(this.gridEntryDataGridView_ColumnDisplayIndexChanged);
|
|
||||||
//
|
//
|
||||||
// liberateGVColumn
|
// liberateGVColumn
|
||||||
//
|
//
|
||||||
@ -209,6 +214,14 @@
|
|||||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
|
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
|
||||||
//
|
//
|
||||||
|
// syncBindingSource
|
||||||
|
//
|
||||||
|
this.syncBindingSource.DataSource = this.bindingSource;
|
||||||
|
//
|
||||||
|
// bindingSource
|
||||||
|
//
|
||||||
|
this.bindingSource.DataSource = typeof(LibationWinForms.GridEntry);
|
||||||
|
//
|
||||||
// ProductsGrid
|
// ProductsGrid
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
@ -219,6 +232,8 @@
|
|||||||
this.Size = new System.Drawing.Size(1510, 380);
|
this.Size = new System.Drawing.Size(1510, 380);
|
||||||
this.Load += new System.EventHandler(this.ProductsGrid_Load);
|
this.Load += new System.EventHandler(this.ProductsGrid_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.syncBindingSource)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -241,5 +256,7 @@
|
|||||||
private System.Windows.Forms.DataGridViewTextBoxColumn myRatingGVColumn;
|
private System.Windows.Forms.DataGridViewTextBoxColumn myRatingGVColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn miscGVColumn;
|
private System.Windows.Forms.DataGridViewTextBoxColumn miscGVColumn;
|
||||||
private EditTagsDataGridViewImageButtonColumn tagAndDetailsGVColumn;
|
private EditTagsDataGridViewImageButtonColumn tagAndDetailsGVColumn;
|
||||||
|
private SyncBindingSource syncBindingSource;
|
||||||
|
private System.Windows.Forms.BindingSource bindingSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,15 +24,14 @@ namespace LibationWinForms.grid
|
|||||||
public new event EventHandler<ScrollEventArgs> Scroll;
|
public new event EventHandler<ScrollEventArgs> Scroll;
|
||||||
|
|
||||||
private FilterableSortableBindingList bindingList;
|
private FilterableSortableBindingList bindingList;
|
||||||
private SyncBindingSource gridEntryBindingSource;
|
internal IEnumerable<LibraryBookEntry> GetVisible()
|
||||||
|
=> bindingList
|
||||||
|
.LibraryBooks();
|
||||||
|
|
||||||
public ProductsGrid()
|
public ProductsGrid()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
EnableDoubleBuffering();
|
EnableDoubleBuffering();
|
||||||
//There a bug in designer that causes errors if you add BindingSource to the DataGridView at design time.
|
|
||||||
gridEntryBindingSource = new SyncBindingSource();
|
|
||||||
gridEntryDataGridView.DataSource = gridEntryBindingSource;
|
|
||||||
gridEntryDataGridView.Scroll += (_, s) => Scroll?.Invoke(this, s);
|
gridEntryDataGridView.Scroll += (_, s) => Scroll?.Invoke(this, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,14 +104,14 @@ namespace LibationWinForms.grid
|
|||||||
|
|
||||||
bindingList = new FilterableSortableBindingList(geList.OrderByDescending(e => e.DateAdded));
|
bindingList = new FilterableSortableBindingList(geList.OrderByDescending(e => e.DateAdded));
|
||||||
bindingList.CollapseAll();
|
bindingList.CollapseAll();
|
||||||
gridEntryBindingSource.DataSource = bindingList;
|
syncBindingSource.DataSource = bindingList;
|
||||||
VisibleCountChanged?.Invoke(this, bindingList.LibraryBooks().Count());
|
VisibleCountChanged?.Invoke(this, bindingList.LibraryBooks().Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateGrid(List<LibraryBook> dbBooks)
|
internal void UpdateGrid(List<LibraryBook> dbBooks)
|
||||||
{
|
{
|
||||||
int visibleCount = bindingList.Count;
|
int visibleCount = bindingList.Count;
|
||||||
string existingFilter = gridEntryBindingSource.Filter;
|
string existingFilter = syncBindingSource.Filter;
|
||||||
|
|
||||||
//Add absent books to grid, or update current books
|
//Add absent books to grid, or update current books
|
||||||
|
|
||||||
@ -206,9 +205,9 @@ namespace LibationWinForms.grid
|
|||||||
int visibleCount = bindingList.Count;
|
int visibleCount = bindingList.Count;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(searchString))
|
if (string.IsNullOrEmpty(searchString))
|
||||||
gridEntryBindingSource.RemoveFilter();
|
syncBindingSource.RemoveFilter();
|
||||||
else
|
else
|
||||||
gridEntryBindingSource.Filter = searchString;
|
syncBindingSource.Filter = searchString;
|
||||||
|
|
||||||
if (visibleCount != bindingList.Count)
|
if (visibleCount != bindingList.Count)
|
||||||
VisibleCountChanged?.Invoke(this, bindingList.LibraryBooks().Count());
|
VisibleCountChanged?.Invoke(this, bindingList.LibraryBooks().Count());
|
||||||
@ -217,13 +216,15 @@ namespace LibationWinForms.grid
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
internal IEnumerable<LibraryBookEntry> GetVisible()
|
#region Column Customizations
|
||||||
=> bindingList
|
|
||||||
.LibraryBooks();
|
|
||||||
|
|
||||||
private void ProductsGrid_Load(object sender, EventArgs e)
|
private void ProductsGrid_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
//https://stackoverflow.com/a/4498512/3335599
|
||||||
|
if (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime) return;
|
||||||
|
|
||||||
gridEntryDataGridView.ColumnWidthChanged += gridEntryDataGridView_ColumnWidthChanged;
|
gridEntryDataGridView.ColumnWidthChanged += gridEntryDataGridView_ColumnWidthChanged;
|
||||||
|
gridEntryDataGridView.ColumnDisplayIndexChanged += gridEntryDataGridView_ColumnDisplayIndexChanged;
|
||||||
|
|
||||||
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());
|
||||||
@ -272,6 +273,7 @@ namespace LibationWinForms.grid
|
|||||||
column.DisplayIndex = displayIndices.GetValueOrDefault(itemName, column.Index);
|
column.DisplayIndex = displayIndices.GetValueOrDefault(itemName, column.Index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideMenuItem_Click(object sender, EventArgs e)
|
private void HideMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var menuItem = sender as ToolStripMenuItem;
|
var menuItem = sender as ToolStripMenuItem;
|
||||||
@ -319,5 +321,7 @@ namespace LibationWinForms.grid
|
|||||||
var dictionary = config.GridColumnsWidths;
|
var dictionary = config.GridColumnsWidths;
|
||||||
dictionary[e.Column.DataPropertyName] = e.Column.Width;
|
dictionary[e.Column.DataPropertyName] = e.Column.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,15 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>171, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="syncBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>326, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>326, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
@ -14,17 +14,41 @@ namespace LibationWinForms
|
|||||||
{
|
{
|
||||||
public List<LibraryBookEntry> Children { get; set; }
|
public List<LibraryBookEntry> Children { get; set; }
|
||||||
public override DateTime DateAdded => Children.Max(c => c.DateAdded);
|
public override DateTime DateAdded => Children.Max(c => c.DateAdded);
|
||||||
public override string ProductRating { get; protected set; }
|
public override string ProductRating
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var productAverageRating = new Rating(Children.Average(c => c.LibraryBook.Book.Rating.OverallRating), Children.Average(c => c.LibraryBook.Book.Rating.PerformanceRating), Children.Average(c => c.LibraryBook.Book.Rating.StoryRating));
|
||||||
|
return productAverageRating.ToStarString()?.DefaultIfNullOrWhiteSpace("");
|
||||||
|
}
|
||||||
|
protected set => throw new NotImplementedException();
|
||||||
|
}
|
||||||
public override string PurchaseDate { get; protected set; }
|
public override string PurchaseDate { get; protected set; }
|
||||||
public override string MyRating { get; protected set; }
|
public override string MyRating
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var myAverageRating = new Rating(Children.Average(c => c.LibraryBook.Book.UserDefinedItem.Rating.OverallRating), Children.Average(c => c.LibraryBook.Book.UserDefinedItem.Rating.PerformanceRating), Children.Average(c => c.LibraryBook.Book.UserDefinedItem.Rating.StoryRating));
|
||||||
|
return myAverageRating.ToStarString()?.DefaultIfNullOrWhiteSpace("");
|
||||||
|
}
|
||||||
|
protected set => throw new NotImplementedException();
|
||||||
|
}
|
||||||
public override string Series { get; protected set; }
|
public override string Series { get; protected set; }
|
||||||
public override string Title { get; protected set; }
|
public override string Title { get; protected set; }
|
||||||
public override string Length { get; protected set; }
|
public override string Length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int bookLenMins = Children.Sum(c => c.LibraryBook.Book.LengthInMinutes);
|
||||||
|
return bookLenMins == 0 ? "" : $"{bookLenMins / 60} hr {bookLenMins % 60} min";
|
||||||
|
}
|
||||||
|
protected set => throw new NotImplementedException();
|
||||||
|
}
|
||||||
public override string Authors { get; protected set; }
|
public override string Authors { get; protected set; }
|
||||||
public override string Narrators { get; protected set; }
|
public override string Narrators { get; protected set; }
|
||||||
public override string Category { get; protected set; }
|
public override string Category { get; protected set; }
|
||||||
public override string Misc { get; protected set; }
|
public override string Misc { get; protected set; } = string.Empty;
|
||||||
public override string Description { get; protected set; }
|
public override string Description { get; protected set; } = string.Empty;
|
||||||
public override string DisplayTags { get; } = string.Empty;
|
public override string DisplayTags { get; } = string.Empty;
|
||||||
|
|
||||||
public override LiberateStatus Liberate => _liberate;
|
public override LiberateStatus Liberate => _liberate;
|
||||||
@ -34,6 +58,7 @@ namespace LibationWinForms
|
|||||||
private SeriesBook SeriesBook { get; set; }
|
private SeriesBook SeriesBook { get; set; }
|
||||||
|
|
||||||
private LiberateStatus _liberate = new LiberateStatus { IsSeries = true };
|
private LiberateStatus _liberate = new LiberateStatus { IsSeries = true };
|
||||||
|
|
||||||
public void setSeriesBook(SeriesBook seriesBook)
|
public void setSeriesBook(SeriesBook seriesBook)
|
||||||
{
|
{
|
||||||
SeriesBook = seriesBook;
|
SeriesBook = seriesBook;
|
||||||
@ -42,18 +67,9 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
// Immutable properties
|
// Immutable properties
|
||||||
{
|
{
|
||||||
int bookLenMins = Children.Sum(c => c.LibraryBook.Book.LengthInMinutes);
|
|
||||||
|
|
||||||
var myAverageRating = new Rating(Children.Average(c => c.LibraryBook.Book.UserDefinedItem.Rating.OverallRating), Children.Average(c => c.LibraryBook.Book.UserDefinedItem.Rating.PerformanceRating), Children.Average(c => c.LibraryBook.Book.UserDefinedItem.Rating.StoryRating));
|
|
||||||
var productAverageRating = new Rating(Children.Average(c => c.LibraryBook.Book.Rating.OverallRating), Children.Average(c => c.LibraryBook.Book.Rating.PerformanceRating), Children.Average(c => c.LibraryBook.Book.Rating.StoryRating));
|
|
||||||
|
|
||||||
|
|
||||||
Title = SeriesBook.Series.Name;
|
Title = SeriesBook.Series.Name;
|
||||||
Series = SeriesBook.Series.Name;
|
Series = SeriesBook.Series.Name;
|
||||||
Length = bookLenMins == 0 ? "" : $"{bookLenMins / 60} hr {bookLenMins % 60} min";
|
|
||||||
MyRating = myAverageRating.ToStarString()?.DefaultIfNullOrWhiteSpace("");
|
|
||||||
PurchaseDate = Children.Min(c => c.LibraryBook.DateAdded).ToString("d");
|
PurchaseDate = Children.Min(c => c.LibraryBook.DateAdded).ToString("d");
|
||||||
ProductRating = productAverageRating.ToStarString()?.DefaultIfNullOrWhiteSpace("");
|
|
||||||
Authors = Book.AuthorNames();
|
Authors = Book.AuthorNames();
|
||||||
Narrators = Book.NarratorNames();
|
Narrators = Book.NarratorNames();
|
||||||
Category = string.Join(" > ", Book.CategoriesNames());
|
Category = string.Join(" > ", Book.CategoriesNames());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user