Ejemplo n.º 1
0
        private void UpdateListWithNewSong(string newWindowTitle)
        {
            //Set finish time in last song
            if (CurrentSong != null)             //If there is a last song and it doesn't have a finish time
            {
                SongInfo curSong = CurrentSong.GetValueOrDefault();

                _songs[_songs.Count - 1] = new SongInfo(
                    artist: curSong.Artist,
                    songName: curSong.SongName,
                    startTime: curSong.StartTime,
                    endTime: DateTime.Now,
                    isSong: curSong.IsSong
                    );
            }

            //Add the new song
            if (!string.IsNullOrEmpty(newWindowTitle))             //Don't add a song when Spotify isn't running (or similar situations)
            {
                _songs.Add(
                    new SongInfo(
                        spotifySongInfo: new SpotifySongInfo(newWindowTitle, this.SongClassificationInfo),
                        timeStarted: DateTime.Now,
                        timeStopped: null
                        )
                    );
            }
            ;

            //Remove the first song if MaxSongs has been reached
            if (MaxSongs >= 0 && _songs.Count > MaxSongs)
            {
                _songs.RemoveAt(0);                 //Inefficient but I can't think of a more efficient EASY way to do this
            }
        }