Edit
This commit is contained in:
parent
89059510fd
commit
3535156ea5
@ -22,12 +22,9 @@ namespace LibationWinForms
|
|||||||
internal class FilterableSortableBindingList : SortableBindingList<GridEntry>, IBindingListView
|
internal class FilterableSortableBindingList : SortableBindingList<GridEntry>, IBindingListView
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Items that were removed from the list due to filtering
|
/// Items that were removed from the base list due to filtering
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<GridEntry> FilterRemoved = new();
|
private readonly List<GridEntry> FilterRemoved = new();
|
||||||
/// <summary>
|
|
||||||
/// Tracks all items in the list, both filtered and not.
|
|
||||||
/// </summary>
|
|
||||||
private string FilterString;
|
private string FilterString;
|
||||||
private Action Sort;
|
private Action Sort;
|
||||||
public FilterableSortableBindingList(IEnumerable<GridEntry> enumeration) : base(enumeration)
|
public FilterableSortableBindingList(IEnumerable<GridEntry> enumeration) : base(enumeration)
|
||||||
@ -44,8 +41,7 @@ namespace LibationWinForms
|
|||||||
#region Unused - Advanced Filtering
|
#region Unused - Advanced Filtering
|
||||||
public bool SupportsAdvancedSorting => false;
|
public bool SupportsAdvancedSorting => false;
|
||||||
|
|
||||||
|
//This ApplySort overload if only called is SupportsAdvancedSorting is true.
|
||||||
//This ApplySort overload is only called is SupportsAdvancedSorting is true.
|
|
||||||
//Otherwise BindingList.ApplySort() is used
|
//Otherwise BindingList.ApplySort() is used
|
||||||
public void ApplySort(ListSortDescriptionCollection sorts) => throw new NotImplementedException();
|
public void ApplySort(ListSortDescriptionCollection sorts) => throw new NotImplementedException();
|
||||||
|
|
||||||
@ -58,6 +54,7 @@ namespace LibationWinForms
|
|||||||
base.Remove(entry);
|
base.Remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <returns>All items in the list, including those filtered out.</returns>
|
||||||
public List<GridEntry> AllItems() => Items.Concat(FilterRemoved).ToList();
|
public List<GridEntry> AllItems() => Items.Concat(FilterRemoved).ToList();
|
||||||
|
|
||||||
private void ApplyFilter(string filterString)
|
private void ApplyFilter(string filterString)
|
||||||
@ -68,7 +65,7 @@ namespace LibationWinForms
|
|||||||
FilterString = filterString;
|
FilterString = filterString;
|
||||||
|
|
||||||
var searchResults = SearchEngineCommands.Search(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--)
|
for (int i = Items.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -94,7 +91,7 @@ namespace LibationWinForms
|
|||||||
Sort();
|
Sort();
|
||||||
else
|
else
|
||||||
//No user-defined sort is applied, so do default sorting by date added, descending
|
//No user-defined sort is applied, so do default sorting by date added, descending
|
||||||
((List<GridEntry>)Items).Sort((i1,i2) =>i2.LibraryBook.DateAdded.CompareTo(i1.LibraryBook.DateAdded));
|
((List<GridEntry>)Items).Sort((i1, i2) => i2.LibraryBook.DateAdded.CompareTo(i1.LibraryBook.DateAdded));
|
||||||
|
|
||||||
FilterString = null;
|
FilterString = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user