Beispiel #1
0
        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 lblAddToPlaylist_Click(object sender, EventArgs e)
        {
            PlaylistModel playlistModel = new PlaylistModel();
            playlistModel.addSongToPlaylist(thePlaylist, songList[selectedSong]);

            parent.songAdded(songList[selectedSong]);

            removeAlbum(selectedSong);
        }
        private void addSongToPlaylist(object sender, EventArgs e)
        {
            int playListIndex;

            Label theLabel = (Label)sender;
            playListIndex = int.Parse(theLabel.Tag.ToString());

            Playlist thePlaylist = usersPlaylists[playListIndex];
            Song toAdd = songList[selectedSong];

            PlaylistModel playlistModel = new PlaylistModel();

            playlistModel.addSongToPlaylist(thePlaylist, toAdd);
        }
        //Adding song to playlist
        private void addSongToPlaylist(object sender, EventArgs e)
        {
            //Get the playlist
            int playListIndex;

            Label theLabel = (Label)sender;
            playListIndex = int.Parse(theLabel.Tag.ToString());

            Playlist thePlaylist = usersPlaylists[playListIndex];

            String[] tmp = selectedSong.Split(',');
            int x = int.Parse(tmp[0]);
            int y = int.Parse(tmp[1]);

            String songName = songLabelsName[x][y].Text;

            Song toAdd = new Song();

            for (int i = 0; i < songs.Count; i++)
            {
                if (songs[i].getTrackName().Equals(songName))
                {
                    toAdd = songs[i];
                    break;
                }
            }

            //This part does the actual adding
            if (toAdd.getTrackName() != null && toAdd.getTrackName() != "")
            {
                PlaylistModel playlistModel = new PlaylistModel();

                playlistModel.addSongToPlaylist(thePlaylist, toAdd);
            }

            pnlOptions.Visible = false;
            pnlPlaylists.Visible = false;
        }