From 3535156ea5e5eeb1bc47cb2c491cbfe379d620bf Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 16 May 2022 12:47:50 -0600 Subject: [PATCH] Edit --- .../grid/FilterableSortableBindingList.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Source/LibationWinForms/grid/FilterableSortableBindingList.cs b/Source/LibationWinForms/grid/FilterableSortableBindingList.cs index e0f83776..4552d5bb 100644 --- a/Source/LibationWinForms/grid/FilterableSortableBindingList.cs +++ b/Source/LibationWinForms/grid/FilterableSortableBindingList.cs @@ -22,12 +22,9 @@ namespace LibationWinForms internal class FilterableSortableBindingList : SortableBindingList, IBindingListView { /// - /// Items that were removed from the list due to filtering + /// Items that were removed from the base list due to filtering /// private readonly List FilterRemoved = new(); - /// - /// Tracks all items in the list, both filtered and not. - /// private string FilterString; private Action Sort; public FilterableSortableBindingList(IEnumerable enumeration) : base(enumeration) @@ -44,8 +41,7 @@ namespace LibationWinForms #region Unused - Advanced Filtering public bool SupportsAdvancedSorting => false; - - //This ApplySort overload is only called is SupportsAdvancedSorting is true. + //This ApplySort overload if only called is SupportsAdvancedSorting is true. //Otherwise BindingList.ApplySort() is used public void ApplySort(ListSortDescriptionCollection sorts) => throw new NotImplementedException(); @@ -58,6 +54,7 @@ namespace LibationWinForms base.Remove(entry); } + /// All items in the list, including those filtered out. public List AllItems() => Items.Concat(FilterRemoved).ToList(); private void ApplyFilter(string filterString) @@ -68,7 +65,7 @@ namespace LibationWinForms FilterString = filterString; var searchResults = SearchEngineCommands.Search(filterString); - var filteredOut = Items.ExceptBy(searchResults.Docs.Select(d=>d.ProductId), ge=>ge.AudibleProductId); + var filteredOut = Items.ExceptBy(searchResults.Docs.Select(d => d.ProductId), ge => ge.AudibleProductId); for (int i = Items.Count - 1; i >= 0; i--) { @@ -84,7 +81,7 @@ namespace LibationWinForms public void RemoveFilter() { if (FilterString is null) return; - + for (int i = 0; i < FilterRemoved.Count; i++) base.InsertItem(i, FilterRemoved[i]); @@ -94,7 +91,7 @@ namespace LibationWinForms Sort(); else //No user-defined sort is applied, so do default sorting by date added, descending - ((List)Items).Sort((i1,i2) =>i2.LibraryBook.DateAdded.CompareTo(i1.LibraryBook.DateAdded)); + ((List)Items).Sort((i1, i2) => i2.LibraryBook.DateAdded.CompareTo(i1.LibraryBook.DateAdded)); FilterString = null; }