public IconItemSource() { foreach (IconItem item in Items) { FilteredItems.Add(item); if (item.IsSymbol) { FilteredSymbolItems.Add(item); } } }
private void FilterData() { FilteredItems.Clear(); foreach (var item in Items) { if (item.Name.Contains(filter) || filter.Equals("allValues")) { FilteredItems.Add(item); } } }
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); } } } }
/// <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); } }); }
private void OnDependencyPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) { T item = (T)(LiveShapingItem <T>)dependencyObject; switch (GetCategoryOfDependencyProperty(args.Property)) { case LiveShapingCategory.Sorting: int originalBinarySearchIndex = InternalBinarySearchWithEqualityCheck(item); int actualIndex; int targetIndex; if (originalBinarySearchIndex >= 0) { Debug.Assert(BackingList[originalBinarySearchIndex].Equals(item)); actualIndex = originalBinarySearchIndex; targetIndex = FindCorrectLocation(item); } else { actualIndex = LinearSearch(item); targetIndex = ~originalBinarySearchIndex; } LiveShapingItems[item].IsSortDirty = false; if (actualIndex >= 0) { // adjust targetIndex if the item at actualIndex will no longer be there if (actualIndex < targetIndex) { targetIndex--; } if (targetIndex != actualIndex) { BackingList.Move(actualIndex, targetIndex); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, item, targetIndex, actualIndex)); } } break; case LiveShapingCategory.Filtering: var passesFilter = PassesFilter(item); if (passesFilter) { if (FilteredItems.Remove(item)) { var insertionIndex = base.Add(item); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, insertionIndex)); } } else { if (!FilteredItems.Contains(item)) { var removalIndex = IndexOf(item); // It is possible that the liveshapingitem has been registered but the item has not yet been added to this collection (causing index = -1), in which case this is a noop if (removalIndex >= 0) { base.RemoveAt(removalIndex); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, removalIndex)); FilteredItems.Add(item); } } } break; default: throw new ArgumentOutOfRangeException(); } /* Debug.WriteLine(args.Property + " " + string.Join(", ", * BackingList.OfType<GameFolderPair>() * .Select( * folderPair => { * if (folderPair.DestinationEntry == null) return "-99"; * * return SizeToStringConverter.Instance.Convert(folderPair.DestinationEntry?.Size) + (LiveShapingItems[folderPair as T].IsSortDirty ? "" : "✓"); + }) + ));*/ }
private void AddFilteredItem(T item) => FilteredItems.Add(item);