예제 #1
0
        /// <summary>
        /// Showing the current playlist in PlaylistGridView
        /// </summary>
        private void GetPlaylist()
        {
            playlist = _service.GetAllSongs(_dataStorage.CurrentSelectedPartyId).OrderByDescending(aux => aux.rating).ToList();

            _currentPlaylist.Clear();

            if (PlaylistGridView.InvokeRequired)
            {
                PlaylistGridView.Invoke(new MethodInvoker(delegate { PlaylistGridView.Rows.Clear(); }));
            }
            else
            {
                PlaylistGridView.Rows.Clear();
            }

            playlist.ForEach(song =>
            {
                var index     = PlaylistGridView.Rows.Add();
                var row       = PlaylistGridView.Rows[index];
                var fullTrack = _spotify.GetTrack(song.songURL.Substring(14, song.songURL.Length - 14));

                _currentPlaylist.Add(fullTrack.Uri);

                row.Cells["Rating"].Value = song.rating;
                row.Cells["Title"].Value  = fullTrack.Name;
                row.Cells["Artist"].Value = ArtistsToString(fullTrack.Artists);
            });
        }
예제 #2
0
        private void getSongsBtn_Click(object sender, EventArgs e)
        {
            var playlist  = _service.GetAllSongs(_dataStorage.CurrentSelectedPartyId).OrderByDescending(aux => aux.rating).ToList();
            var userVotes = _service.GetAllRatings(_dataStorage.CurrentSelectedPartyId, _dataStorage.UserId).ToList();

            RefreshSpotifyPlaylist(playlist);

            if (getSongsResultLB.InvokeRequired)
            {
                getSongsResultLB.Invoke(new MethodInvoker(delegate { getSongsResultLB.Items.Clear(); }));
            }
            else
            {
                getSongsResultLB.Items.Clear();
            }


            _existingPlaylist          = new List <string>();
            _existingFullTrackPlaylist = new List <string>();
            _collectionOfVotes         = new List <SongRatingFromPartyTable>();
            // _existingFullList = new List<WCFService.SongsForPartyTable>();

            userVotes.ForEach(vote =>
            {
                SongRatingFromPartyTable songRating = new SongRatingFromPartyTable
                {
                    partyID  = vote.partyID,
                    songURL  = vote.songURL,
                    voteType = vote.voteType,
                    userID   = vote.userID
                };
                _collectionOfVotes.Add(songRating);
            }
                              );

            playlist.ForEach(song =>
            {
                //addTrack(newPlaylist,song.songURL);

                string myArtists      = null;
                SongsForPartyTable sp = new SongsForPartyTable
                {
                    partyID = song.partyID,
                    songURL = song.songURL,
                    rating  = song.rating
                };
                _existingFullTrackPlaylist.Add(sp.songURL);
                // _existingFullList.Add(sp);
                var fullTrack = _spotify.GetTrack(song.songURL.Substring(14, song.songURL.Length - 14));

                var list = fullTrack.Artists;
                list.ForEach(artist => {
                    if (myArtists == null)
                    {
                        myArtists = artist.Name;
                    }
                    else
                    {
                        myArtists += ", " + artist.Name;
                    }
                });
                _existingPlaylist.Add(fullTrack.Uri);
                if (getSongsResultLB.InvokeRequired)
                {
                    getSongsResultLB.Invoke(new MethodInvoker(delegate { getSongsResultLB.Items.Add($"{fullTrack.Name } : { myArtists}"); }));
                }
                else
                {
                    getSongsResultLB.Items.Add($"{fullTrack.Name } : { myArtists}");
                }
            });
        }