示例#1
0
        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;
 }
示例#3
0
        private void Unsubscribe(IShuffleCollection shuffle)
        {
            if (shuffle == null)
            {
                return;
            }

            shuffle.Changed -= OnShuffleCollectionChanged;
        }
示例#4
0
        public void SetShuffleType(ShuffleType type)
        {
            if (type == Shuffle.Type)
            {
                return;
            }

            Shuffle = CreateShuffle(type, Parent?.CurrentSong);
        }
示例#5
0
        private void Subscribe(IShuffleCollection shuffle)
        {
            if (shuffle == null)
            {
                return;
            }

            shuffle.Changed += Shuffle_Changed;
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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;
        }
示例#9
0
 public SongCollection()
 {
     list    = new List <Song>();
     Shuffle = new ShuffleOffCollection(this);
 }
示例#10
0
 public void SetShuffleType(ShuffleType type)
 {
     Shuffle = new SimpleShuffleCollection(this, type);
 }