private void cmdAddSongToPlaylist_Click(object sender, EventArgs e) { String plName = Microsoft.VisualBasic.Interaction.InputBox("Playlist Name:"); String owner = Microsoft.VisualBasic.Interaction.InputBox("Owner:"); PlaylistModel playlistModel = new PlaylistModel(); Playlist thePlaylist = playlistModel.getPlaylist(plName, owner); SongModel songModel = new SongModel(); String artist = Microsoft.VisualBasic.Interaction.InputBox("Search for Artist: "); List<Song> songs = songModel.getSongsByArtist(artist); Song theSong = new Song(); if (songs.Count > 0) { theSong = songs[0]; if (thePlaylist != null) { playlistModel.addSongToPlaylist(thePlaylist, theSong); } } }
private void cmdArtistSongs_Click(object sender, EventArgs e) { String artist = Microsoft.VisualBasic.Interaction.InputBox("Artist Name:"); SongModel songModel = new SongModel(); List<Song> songsForArtist = songModel.getSongsByArtist(artist); ArtistView artistView = new ArtistView(new User(), null); artistView.setupVariables(artist, songsForArtist); artistView.createAlbums(); artistView.Show(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void goToArtist(object sender, EventArgs e) { LinkLabel theLabel = (LinkLabel)sender; String artist = theLabel.Text; pnlOptions.Visible = false; pnlPlaylists.Visible = false; SongModel songModel = new SongModel(); List<Song> songsForArtist = songModel.getSongsByArtist(artist); //Call the method in parent to open artist window, passing data back parent.artistSelected(artist, songsForArtist); this.Hide(); }
//Method when clicking artist private void artistClick(object sender, EventArgs e) { Label theLabel = (Label)sender; int id = int.Parse(theLabel.Tag.ToString()); String artist = artistLabel[id].Text; SongModel songModel = new SongModel(); List<Song> songsForArtist = songModel.getSongsByArtist(artist); //Call the method in parent to open artist window, passing data back parent.artistSelected(artist, songsForArtist); this.Close(); }
public void populateTracks() { //populate database with things SongModel s = new SongModel(); s.populateDB(); }
//Method to load the search window private void btnSearch_Click(object sender, EventArgs e) { hideForms(); //Get user search text String searchText = txtSearchBox.Text; //Create a new song model SongModel songModel = new SongModel(); PlaylistModel playlistModel = new PlaylistModel(); //Populate song list with songs that fit the criteria List<Song> songs = new List<Song>(); Thread songThread = new Thread(() => { songs = songModel.searchSongs(searchText); }); songThread.Start(); //Populate artist list with artists that fir the criteria List<String> artists = new List<String>(); Thread artistThread = new Thread(() => { artists = songModel.searchArtists(searchText.ToLower()); }); artistThread.Start(); //Populate artist list with artists that fir the criteria List<Playlist> playlists = new List<Playlist>(); Thread playlistThread = new Thread(() => { playlists = playlistModel.searchPlaylists(searchText); }); playlistThread.Start(); //Join threads songThread.Join(); artistThread.Join(); playlistThread.Join(); //Call method to load results window loadSearchResults(songs, artists, playlists, searchText); }
private void picRecommend_Click(object sender, EventArgs e) { SongModel songModel = new SongModel(); List<Song> songList = songModel.getAllSongs(); List<Song> songsInPlaylist = thePlaylist.getSongs(); // get all artists List<String> artists = new List<String>(); for (int i = 0; i < thePlaylist.getSongs().Count; i++) { String artist = thePlaylist.getSongs()[i].getArtist(); if (!artists.Contains(artist)) { artists.Add(thePlaylist.getSongs()[i].getArtist()); } } List<Song> suitableSongs = songList.Where(song => artists.Contains(song.getArtist())).ToList(); // get all genres List<String> genres = new List<String>(); for (int i = 0; i < thePlaylist.getSongs().Count; i++) { if (!genres.Contains(thePlaylist.getSongs()[i].getGenre())) { genres.Add(thePlaylist.getSongs()[i].getGenre()); } } List<Song> matchingGenres = songList.Where(song => genres.Contains(song.getGenre())).ToList(); for (int i = 0; i < matchingGenres.Count; i++) { suitableSongs.Add(matchingGenres[i]); } // Remove songs that already exist in playlist for (int j = 0; j < suitableSongs.Count; j++) { for (int i = 0; i < songsInPlaylist.Count; i++) { if (suitableSongs[j].getSongID().Equals(songsInPlaylist[i].getSongID())) { suitableSongs.RemoveAt(j); if (j > 0) { j--; } else { j = -1; } break; } } } // GET SONGS List<Song> selectedSongs = new List<Song>(); while (selectedSongs.Count < 5 && suitableSongs.Count > 0) { Random r = new Random(); bool add = true; int index = r.Next(0, suitableSongs.Count-1); for (int i = 0; i < selectedSongs.Count; i++) { if (selectedSongs[i].getSongID().Equals(suitableSongs[index].getSongID())) { add = false; suitableSongs.RemoveAt(index); break; } } if (add) { selectedSongs.Add(suitableSongs[index]); suitableSongs.RemoveAt(index); } } Recommendations recommendations = new Recommendations(this); recommendations.setSongs(selectedSongs, thePlaylist); recommendations.createAlbums(); recommendations.ShowDialog(); }