private void FilterItems()
        {
            IEnumerable source = ItemsSource;

            if (source == null)
            {
                FilteredItems.Clear();
                return;
            }

            IEnumerator enumerator = source.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                FilteredItems.Clear();
                return;
            }

            FilterPredicate    predicate = Predicate;
            FilteredCollection filtered  = new FilteredCollection();

            do
            {
                object item = enumerator.Current;
                if (predicate == null || predicate.Matches(item))
                {
                    filtered.Add(item);
                }
            }while (enumerator.MoveNext());

            FilteredItems = filtered;
        }
 /// <inheritdoc/>
 public override void Clear()
 {
     LiveShapingItems.Values.ForEach(OnLiveShapingItemRemoved);
     LiveShapingItems.Clear();
     FilteredItems.Clear();
     base.Clear();
 }
Exemple #3
0
    protected async Task ApplyFilters()
    {
        IReadOnlyList <T> items         = Items();
        IEnumerable <T>   filteredItems = items;

        foreach (EntityGridFilterBase <T> filter in Filters)
        {
            filter.OnBeforeFilter(items);
        }

        foreach (EntityGridFilterBase <T> filter in Filters)
        {
            filteredItems = filteredItems.Where(filter.Filter);
        }

        FilteredItems.Clear();
        FilteredItems.AddRange(filteredItems);

        if (ItemsGridComponent != null)
        {
            await ItemsGridComponent.UpdateGrid();
        }
        else
        {
            await ItemsGrid.UpdateGrid();
        }
    }
Exemple #4
0
 /// <summary>
 /// Clear the collection
 /// </summary>
 public void Clear()
 {
     if (ContentItems != null && FilteredItems != null)
     {
         ContentItems.Clear();
         FilteredItems.Clear();
     }
 }
Exemple #5
0
 private void ResetView()
 {
     FilteredItems.Clear();
     foreach (var opt in Grid.Children.OfType <IFilterOption>())
     {
         opt.Reset();
     }
     Clear?.Invoke(this, EventArgs.Empty);
 }
Exemple #6
0
 private void FilterData()
 {
     FilteredItems.Clear();
     foreach (var item in Items)
     {
         if (item.Name.Contains(filter) || filter.Equals("allValues"))
         {
             FilteredItems.Add(item);
         }
     }
 }
Exemple #7
0
        private void FilterItems()
        {
            FilteredItems.Clear();
            var query = Items.AsEnumerable();

            if (EventType == EventTypeFilter.Paid)
            {
                query = Items.Where(it => !it.IsFree);
            }
            else if (EventType == EventTypeFilter.Free)
            {
                query = Items.Where(it => it.IsFree);
            }
            foreach (var item in query)
            {
                FilteredItems.Add(item);
            }
        }
        public new void Filter(string search)
        {
            string[] filter = search?.Split(" ");

            FilteredItems.Clear();
            FilteredSymbolItems.Clear();

            foreach (IconItem item in Items)
            {
                if (item.FitsFilter(filter))
                {
                    FilteredItems.Add(item);
                    if (item.IsSymbol)
                    {
                        FilteredSymbolItems.Add(item);
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Filtruoja helpRequest pagal įvestą String, pasirinką kategoriją,
        /// bei per profili gali pasirinkti kad žiūrėtų tik savo
        /// </summary>
        /// <param name="search">Įvestas raktas</param>
        /// <param name="category">Pasirinkta kategorija</param>
        /// <param name="own">Ar tai mano HelpRequest</param>
        void Filter(string search = null, string category = null, bool own = false)
        {
            if (Items == null || LocalUserManager.LocalUser == null) // Dar nėra informacijos
            {
                return;
            }
            List <HelpRequestModel> filtered = Items.ToList();

            FilteredItems.Clear();
            filtered.ForEach((helpRequest) =>
            {
                if ((String.IsNullOrEmpty(category) || category == helpRequest.Category) &&
                    (String.IsNullOrEmpty(search) || helpRequest.Title.ToLower().Contains(search) || helpRequest.Description.ToLower().Contains(search)) &&
                    (!own || helpRequest.Username == LocalUserManager.LocalUser.Username))
                {
                    FilteredItems.Add(helpRequest);
                }
            });
        }
        public void RecalculateFilter()
        {
            if (Filter == null)
            {
                FilteredItems.ForEach(item => InternalAdd(item));
                FilteredItems.Clear();
            }
            else
            {
                // Remove the items that no longer pass the filter
                var itemsRemovedByNewFilter = new List <T>();
                for (int i = BackingList.Count - 1; i >= 0; i--)
                {
                    if (!PassesFilter(BackingList[i]))
                    {
                        itemsRemovedByNewFilter.Add(BackingList[i]);
                        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, BackingList[i], i));
                        base.RemoveAt(i);
                    }
                }

                // Add the previously filtered items that that now pass
                FilteredItems.RemoveWhere(item => {
                    var insertionIndex = InternalAdd(item);
                    if (insertionIndex >= 0)
                    {
                        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, insertionIndex));
                        return(true);
                    }

                    return(false);
                });

                // Don't move items into the filtered list until it has been iterated over
                FilteredItems.UnionWith(itemsRemovedByNewFilter);
            }
        }
Exemple #11
0
 public void RefreshItems()
 {
     FilteredItems.Clear();
     FilteredItems = filter.RestoreItemList(FilteredItems);
 }
 public void Clear()
 {
     FilteredItems.Clear();
     TotalItemsCount = 0;
 }