This commit is contained in:
Robert McRackan 2022-05-24 15:32:42 -04:00
commit 1b101106e7
3 changed files with 15 additions and 4 deletions

View File

@ -30,6 +30,9 @@ namespace LibationWinForms.GridView
public bool SupportsFiltering => true; public bool SupportsFiltering => true;
public string Filter { get => FilterString; set => ApplyFilter(value); } public string Filter { get => FilterString; set => ApplyFilter(value); }
/// <summary>When true, itms will not be checked filtered by search criteria on item changed<summary>
public bool SuspendFilteringOnUpdate { get; set; }
protected MemberComparer<GridEntry> Comparer { get; } = new(); protected MemberComparer<GridEntry> Comparer { get; } = new();
protected override bool SupportsSortingCore => true; protected override bool SupportsSortingCore => true;
protected override bool SupportsSearchingCore => true; protected override bool SupportsSearchingCore => true;
@ -195,7 +198,7 @@ namespace LibationWinForms.GridView
{ {
if (e.ListChangedType == ListChangedType.ItemChanged) if (e.ListChangedType == ListChangedType.ItemChanged)
{ {
if (Items[e.NewIndex] is LibraryBookEntry lbItem) if (FilterString is not null && !SuspendFilteringOnUpdate && Items[e.NewIndex] is LibraryBookEntry lbItem)
{ {
SearchResults = SearchEngineCommands.Search(FilterString); SearchResults = SearchEngineCommands.Search(FilterString);
if (!SearchResults.Docs.Any(d => d.ProductId == lbItem.AudibleProductId)) if (!SearchResults.Docs.Any(d => d.ProductId == lbItem.AudibleProductId))

View File

@ -63,7 +63,11 @@ namespace LibationWinForms.GridView
} }
#endregion #endregion
public LibraryBookEntry(LibraryBook libraryBook) => setLibraryBook(libraryBook); public LibraryBookEntry(LibraryBook libraryBook)
{
setLibraryBook(libraryBook);
LoadCover();
}
public SeriesEntry Parent { get; init; } public SeriesEntry Parent { get; init; }
public void UpdateLibraryBook(LibraryBook libraryBook) public void UpdateLibraryBook(LibraryBook libraryBook)
@ -80,7 +84,7 @@ namespace LibationWinForms.GridView
{ {
LibraryBook = libraryBook; LibraryBook = libraryBook;
LoadCover(); UserDefinedItem.ItemChanged -= UserDefinedItem_ItemChanged;
// Immutable properties // Immutable properties
{ {

View File

@ -105,6 +105,8 @@ namespace LibationWinForms.GridView
string existingFilter = syncBindingSource.Filter; string existingFilter = syncBindingSource.Filter;
Filter(null); Filter(null);
bindingList.SuspendFilteringOnUpdate = true;
//Add absent books to grid, or update current books //Add absent books to grid, or update current books
var allItmes = bindingList.AllItems().LibraryBooks(); var allItmes = bindingList.AllItems().LibraryBooks();
@ -157,6 +159,8 @@ namespace LibationWinForms.GridView
} }
} }
bindingList.SuspendFilteringOnUpdate = false;
//Re-filter after updating existing / adding new books to capture any changes //Re-filter after updating existing / adding new books to capture any changes
Filter(existingFilter); Filter(existingFilter);