public FilteredTracks(LibraryFilter library, TrackDanceFilter filter, bool isDefault = false) { Library = library; IsDefault = isDefault; Filter = filter; Tracks.AddRange(Filter.Apply(LibraryTracks)); Filter.PropertyChanged += FilterPropertyChangeHandler; Filter.Dances.CollectionChanged += (s, e) => Refresh(); if (!IsDefault) { Library.DefaultFilter.PropertyChanged += FilterOrTrackChangeHandler; } }
public FilteredTracks AddFilter(TrackDanceFilter filter) { if (string.IsNullOrEmpty(filter.Name)) { throw new ApplicationException("Filter name must be specified."); } var fi = new FilteredTracks(this, filter); _allFilters.Add(fi); if (!String.IsNullOrEmpty(fi.FilterGroup)) { var fg = _filterGroups.SingleOrDefault((g) => g.Name.Equals(fi.FilterGroup, StringComparison.InvariantCultureIgnoreCase)); if (fg == null) { fg = new FilterGroup(fi.FilterGroup); _filterGroups.Add(fg); } fg.Add(fi); } return(fi); }
public LibraryFilter(Library library, TrackDanceFilter defaultFilter = null) { Library = library; DefaultFilter = new FilteredTracks(this, defaultFilter ?? new TrackDanceFilter(), true); FilterGroups = new ReadOnlyObservableCollection <FilterGroup>(_filterGroups); }