public static MusicCollection GetSongs(this Client client) { IXPFile request = new IXPFile(); request.NetworkFunction = "com.projectgame.music.music.getsongs"; IXPFile response = client.IXPRequest(request); MusicCollection musicCollection = new MusicCollection(); int artistCount = int.Parse(response.GetInfoValue("artist_count")); for(int currentArtistIndex = 0; currentArtistIndex < artistCount; currentArtistIndex++) { int artistID = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_id")); string artistName = response.GetInfoValue("artist_" + currentArtistIndex + "_name"); Artist artist = new Artist(artistID, artistName); musicCollection.Artists.Add(artist); int albumCount = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_count")); for(int currentAlbumIndex = 0; currentAlbumIndex < albumCount; currentAlbumIndex++) { int albumID = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_id")); string albumName = response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_name"); Album album = new Album(albumID, albumName); artist.Albums.Add(album); int songCount = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_song_count")); for(int currentSongIndex = 0; currentSongIndex < songCount; currentSongIndex++) { int songID = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_song_" + currentSongIndex + "_id")); string songName = response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_song_" + currentSongIndex + "_name"); Song song = new Song(songID, songName); album.Songs.Add(song); } } } return musicCollection; }
private void btnRefresh_Click(object sender, EventArgs e) { _musicCollection = _client.GetSongs(); _musicCollection.Sort(); lbArtists.Items.Clear(); lbAlbums.Items.Clear(); lbSongs.Items.Clear(); for(int i = 0; i < _musicCollection.Artists.Count; i++) { lbArtists.Items.Add(_musicCollection.Artists[i].Name); } }