예제 #1
0
        protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
        {
            _SortDirection = direction;
            _SortProperty  = property;
            var comparer = new PropertyComparer <T>(property, direction);

            ApplySortInternal(comparer);
        }
예제 #2
0
        void IBindingListView.ApplySort(ListSortDescriptionCollection sorts)
        {
            _SortProperty     = null;
            _SortDescriptions = sorts;
            var comparer = new PropertyComparer <T>(sorts);

            ApplySortInternal(comparer);
        }
예제 #3
0
        private void ApplySortInternal(PropertyComparer <T> comparer)
        {
            if (_OriginalCollection.Count == 0)
            {
                _OriginalCollection.AddRange(this);
            }
            var listRef = Items as List <T>;

            if (listRef == null)
            {
                return;
            }
            listRef.Sort(comparer);
            _Sorted = true;
            OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
        }
        protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
        {
            List <T> itemsList = (List <T>) this.Items;

            Type propertyType = property.PropertyType;
            PropertyComparer <T> comparer;

            if (!this.comparers.TryGetValue(propertyType, out comparer))
            {
                comparer = new PropertyComparer <T>(property, direction);
                this.comparers.Add(propertyType, comparer);
            }

            comparer.SetPropertyAndDirection(property, direction);
            itemsList.Sort(comparer);

            this.propertyDescriptor = property;
            this.listSortDirection  = direction;
            this.isSorted           = true;

            this.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
        }