/// <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); }); }
public void HandleBroadcast(object sender, EventArgs e) { if (InvokeRequired) { BeginInvoke(new HandleBroadcastCallback(HandleBroadcast), sender, e); } else { try { var eventData = (WCFService.EventDataType)sender; playlist = eventData.EventMessage.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); }); } catch (Exception ex) { } } }