Add sorting to library view

- Issue MatterHackers/MCCentral#2475
This commit is contained in:
John Lewin 2018-02-14 09:44:37 -08:00
parent 9b6f8498d2
commit 9e13da5def

View file

@ -135,6 +135,15 @@ namespace MatterHackers.MatterControl.CustomWidgets
public IEnumerable<ListViewItem> Items => items;
public enum SortKey
{
Name,
CreatedDate,
ModifiedDate
}
public SortKey ActiveSort { get; set; } = SortKey.Name;
/// <summary>
/// Empties the list children and repopulates the list with the source container content
/// </summary>
@ -191,6 +200,18 @@ namespace MatterHackers.MatterControl.CustomWidgets
&& this.ItemFilter(item)
select item;
filteredResults = filteredResults.OrderBy(item =>
{
switch (ActiveSort)
{
case SortKey.Name:
return item.Name;
default:
return item.Name;
}
});
foreach (var item in filteredResults)
{
var listViewItem = new ListViewItem(item, this);