public SimpleSongCollection(IShuffleCollection actualShuffleSongs, Song currentSong) { list = new List <Song>(); int currentSongIndex = actualShuffleSongs.IndexOf(currentSong); int startIndex, count; if (actualShuffleSongs.Count < saveSongsCount) { startIndex = 0; count = actualShuffleSongs.Count; } else if (currentSongIndex + saveSongsCount < actualShuffleSongs.Count) { startIndex = currentSongIndex; count = saveSongsCount; } else { startIndex = actualShuffleSongs.Count - saveSongsCount; count = saveSongsCount; } foreach (Song song in actualShuffleSongs.Skip(startIndex).Take(count)) { list.Add(song); } SetShuffleType(actualShuffleSongs.Type); }
internal ShuffleChangedEventArgs(IShuffleCollection oldShuffleSongs, IShuffleCollection newShuffleSongs) { OldShuffleType = oldShuffleSongs?.Type ?? ShuffleType.Off; NewShuffleType = newShuffleSongs?.Type ?? ShuffleType.Off; OldShuffleSongs = oldShuffleSongs; NewShuffleSongs = newShuffleSongs; }
private void Unsubscribe(IShuffleCollection shuffle) { if (shuffle == null) { return; } shuffle.Changed -= OnShuffleCollectionChanged; }
public void SetShuffleType(ShuffleType type) { if (type == Shuffle.Type) { return; } Shuffle = CreateShuffle(type, Parent?.CurrentSong); }
private void Subscribe(IShuffleCollection shuffle) { if (shuffle == null) { return; } shuffle.Changed += Shuffle_Changed; }
public SongCollection(IEnumerable <Song> songs, ShuffleType type, Song currentSong) { list = new List <Song>(songs); foreach (Song song in list) { song.Parent = this; } Shuffle = CreateShuffle(type, currentSong); }
public void ReadXml(XmlReader reader) { ShuffleType shuffleType = (ShuffleType)Enum.Parse(typeof(ShuffleType), reader.GetAttribute("Shuffle")); reader.ReadStartElement(); list = new List <Song>(XmlConverter.DeserializeList <Song>(reader, "Song")); foreach (Song song in list) { song.Parent = this; } Shuffle = new SimpleShuffleCollection(this, shuffleType); }
public void ReadXml(XmlReader reader) { ShuffleType shuffleType = (ShuffleType)Enum.Parse(typeof(ShuffleType), reader.GetAttribute("Shuffle") ?? Enum.GetName(typeof(ShuffleType), ShuffleType.Off)); IShuffleCollection shuffle = GetShuffleType(shuffleType); reader.ReadStartElement(); list = XmlConverter.DeserializeList <Song>(reader, "Song").ToList(); foreach (Song song in list) { song.Parent = this; } shuffle.ReadXml(XmlConverter.GetReader(reader.ReadOuterXml())); Shuffle = shuffle; }
public SongCollection() { list = new List <Song>(); Shuffle = new ShuffleOffCollection(this); }
public void SetShuffleType(ShuffleType type) { Shuffle = new SimpleShuffleCollection(this, type); }