internal bool FilterTreeCDRow(ArtistOverviewCDItem cdItem, bool withTracks) { if (string.IsNullOrEmpty(FilterString)) { return(true); } string filterString = FilterString.ToLower(); if (cdItem.Title.IndexOf(filterString, StringComparison.InvariantCultureIgnoreCase) >= 0) { return(true); } if (withTracks) { foreach (ArtistOverviewTrackItem trackItem in cdItem.Tracks) { if (FilterTrackRow(trackItem)) { return(true); } } } return(false); }
private bool FilterCDRow(object row) { if (string.IsNullOrEmpty(FilterString)) { return(true); } ArtistOverviewCDItem cdItem = row as ArtistOverviewCDItem; if (cdItem != null) { string filterString = FilterString.ToLower(); return(FilterTreeCDRow(cdItem, true)); } ArtistOverviewCDSetItem cdSetItem = row as ArtistOverviewCDSetItem; if (cdSetItem != null) { string filterString = FilterString.ToLower(); return(FilterTreeCDSetRow(cdSetItem, true)); } return(true); }
internal bool FilterTreeRow(ArtistOverviewItem artistRow, string filterString) { if (FilterArtistRow(artistRow)) { return(true); } foreach (object item in artistRow.Items) { ArtistOverviewCDItem cdItem = item as ArtistOverviewCDItem; if (cdItem != null && FilterTreeCDRow(cdItem, true)) { return(true); } } return(false); }
private void TreeView_Expanded(object sender, RoutedEventArgs e) { TreeViewItem item = e.OriginalSource as TreeViewItem; if (item != null && item.DataContext is ArtistOverviewItem) { if (!FilterArtistRow(item.DataContext as ArtistOverviewItem)) { System.ComponentModel.ICollectionView view = CollectionViewSource.GetDefaultView(item.ItemsSource); if (view != null) { view.Filter = new Predicate <object>(FilterCDRow); } } } if (item != null && item.DataContext is ArtistOverviewCDSetItem) { ArtistOverviewCDSetItem cdSetItem = item.DataContext as ArtistOverviewCDSetItem; if (!FilterTreeCDSetRow(cdSetItem, false) && (cdSetItem.Parent == null || !FilterArtistRow(cdSetItem.Parent))) { System.ComponentModel.ICollectionView view = CollectionViewSource.GetDefaultView(item.ItemsSource); if (view != null) { view.Filter = new Predicate <object>(FilterCDRow); } } } if (item != null && item.DataContext is ArtistOverviewCDItem) { ArtistOverviewCDItem cdItem = item.DataContext as ArtistOverviewCDItem; if (cdItem.Tracks == null || cdItem.Tracks.Count == 1 && cdItem.Tracks[0].ID == 0) { CD cd = DataBase.GetCDById(cdItem.ID); cdItem.Tracks.Clear(); foreach (Track track in cd.Tracks) { ArtistOverviewTrackItem trackItem = new ArtistOverviewTrackItem(); trackItem.ID = track.ID; trackItem.Title = GetTrackTitleText(cd, track); trackItem.Soundfile = track.Soundfile; cdItem.Tracks.Add(trackItem); } item.ItemsSource = cdItem.Tracks; } if (!FilterTreeCDRow(cdItem, false) && (cdItem.Parent == null || !FilterArtistRow(cdItem.Parent))) { System.ComponentModel.ICollectionView view = CollectionViewSource.GetDefaultView(item.ItemsSource); if (view != null) { view.Filter = new Predicate <object>(FilterTrackRow); } } } }