private Mediafile GetNextOrPrevSongInGroup(bool prev = false) { //get current group (the group in which current song is playing). Grouping <IGroupKey, Mediafile> currentGroup = TracksCollection.GetCurrentlyPlayingGroup(); //get the index of the song playing in the currentGroup (with reference to the currentGroup) int currentSongIndex = currentGroup.GetPlayingSongIndexInGroup(); //get next song index (depending on the parameters). int nextSongIndex = prev ? currentSongIndex - 1 : currentSongIndex + 1; //get condition for next/prev group. bool nextGroupCondition = nextSongIndex.Equals(prev ? -1 : currentGroup.Count); //get next/prev group index int nextGroupIndex = prev ? TracksCollection.IndexOf(currentGroup) - 1 : TracksCollection.IndexOf(currentGroup) + 1; //get next/prev group. Grouping <IGroupKey, Mediafile> nextGroup = nextGroupCondition ? TracksCollection.ElementAt(nextGroupIndex) : currentGroup; //get nextSong index depending on if the group is new or old. int toPlaySongIndex = nextGroup.Equals(currentGroup) ? nextSongIndex : 0; return(nextGroup.ElementAt(toPlaySongIndex)); }
public override bool Equals(object obj) { GroupingTag other = obj as GroupingTag; return(other != null && Grouping.Equals(other.Grouping) && Group.Equals(other.Group)); }
public override bool Equals(object obj) { var result = base.Equals(obj); if (result) { var query = obj as QueryInfo; if (query != null) { result = (IterationEntryListIds == null && query.IterationEntryListIds == null) || (IterationEntryListIds != null && query.IterationEntryListIds != null && IterationEntryListIds.OrderBy(id => id).SequenceEqual(query.IterationEntryListIds.OrderBy(id => id))); result = (FlatteningEntryListIds == null && query.FlatteningEntryListIds == null) || (FlatteningEntryListIds != null && query.FlatteningEntryListIds != null && FlatteningEntryListIds.OrderBy(id => id).SequenceEqual(query.FlatteningEntryListIds.OrderBy(id => id))); result = result && ((RelationshipFields == null && query.RelationshipFields == null) || (RelationshipFields != null && query.RelationshipFields != null && RelationshipFields.OrderBy(id => id).SequenceEqual(query.RelationshipFields.OrderBy(id => id)))); result = result && ((EntryDetailsRelationshipFields == null && query.EntryDetailsRelationshipFields == null) || (EntryDetailsRelationshipFields != null && query.EntryDetailsRelationshipFields != null && EntryDetailsRelationshipFields.OrderBy(id => id).SequenceEqual(query.EntryDetailsRelationshipFields.OrderBy(id => id)))); result = result && ((PrimaryFilters == null && query.PrimaryFilters == null) || (PrimaryFilters != null && query.PrimaryFilters != null && PrimaryFilters.SequenceEqual(query.PrimaryFilters))); // NOTE: need to be same order result = result && ((SecondaryFilters == null && query.SecondaryFilters == null) || (SecondaryFilters != null && query.SecondaryFilters != null && SecondaryFilters.OrderBy(f => f.ColumnId).SequenceEqual(query.SecondaryFilters.OrderBy(f => f.ColumnId)))); result = result && ((Grouping == null && query.Grouping == null) || (Grouping != null && query.Grouping != null && Grouping.Equals(query.Grouping))); result = result && ((Sorting == null && query.Sorting == null) || (Sorting != null && query.Sorting != null && Sorting.Equals(query.Sorting))); result = result && ((Paging == null && query.Paging == null) || (Paging != null && query.Paging != null && Paging.Equals(query.Paging))); result = result && ((Columns == null && query.Columns == null) || (Columns != null && query.Columns != null && Columns.Equals(query.Columns))); result = result && IncludeRecordsCount == query.IncludeRecordsCount; result = result && IsMultisortingEnabled == query.IsMultisortingEnabled; result = result && IsSecondaryColumnsFilterEnabled == query.IsSecondaryColumnsFilterEnabled; } else { result = false; } } return(result); }