SDRSharper/Plugins/SDRSharper.FrequencyScanner/SDRSharp.FrequencyScanner/SortableBindingList.cs
SDRSharpR c07e6e6034 SDRSharper (SDRSharp Remake) Full Source (VS2017)
SDRSharper (SDRSharp Remake) Full Source (VS2017)
2018-03-26 14:02:05 -07:00

41 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.ComponentModel;
namespace SDRSharp.FrequencyScanner
{
public class SortableBindingList<T> : BindingList<T>
{
private bool _isSorted;
private PropertyDescriptor _sortProperty;
private ListSortDirection _sortDirection;
protected override bool SupportsSortingCore => true;
protected override ListSortDirection SortDirectionCore => this._sortDirection;
protected override PropertyDescriptor SortPropertyCore => this._sortProperty;
protected override bool IsSortedCore => this._isSorted;
protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
{
List<T> list = (List<T>)base.Items;
if (list != null)
{
SortableBindingListComparer<T> comparer = new SortableBindingListComparer<T>(property.Name, direction);
list.Sort(comparer);
this._isSorted = true;
}
else
{
this._isSorted = false;
}
this._sortProperty = property;
this._sortDirection = direction;
this.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
}
}
}