Esempio n. 1
0
        //Method to show artist and their songs based on selection within SearchResults
        public void artistSelected(String name, List<Song> songs)
        {
            hideForms();

            artistView = new ArtistView(this.currentUser, this.musicPlayer);

            PlaylistModel pm = new PlaylistModel();
            List<Playlist> lp = pm.getPlaylistsForUser(currentUser.getUsername());
            artistView.setUsersPlaylists(lp);
            artistView.setupVariables(name, songs);
            artistView.createAlbums();

            artistView.TopLevel = false;
            artistView.Parent = this;
            artistView.FormBorderStyle = FormBorderStyle.None;

            picBoxBackground.Hide();

            artistView.Show();
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
0
        private void cmdCreatePlaylist_Click(object sender, EventArgs e)
        {
            String playlist = Microsoft.VisualBasic.Interaction.InputBox("Playlist Name: ", "Playlist Name");
            String owner = Microsoft.VisualBasic.Interaction.InputBox("Owner: ", "Owner");
            Guid id = Guid.NewGuid();
            List<Song> songs = new List<Song>();

            Playlist newPlaylist = new Playlist(playlist, id, owner, songs);

            PlaylistModel playlistModel = new PlaylistModel();
            playlistModel.createPlaylist(newPlaylist);
        }
        private void goToPlaylist(object sender, EventArgs e)
        {
            Label theLabel = (Label)sender;
            int index = int.Parse(theLabel.Tag.ToString());
            String playlistName = playlistLabelName[index].Text;
            String owner = playlistLabelOwner[index].Text;

            PlaylistModel playlistModel = new PlaylistModel();
            Playlist thePlaylist = playlistModel.getPlaylist(playlistName, owner);

            parent.showViewPlaylist(thePlaylist);

            this.Close();
        }
        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);
        }
        private void lblAddToPlaylist_Click(object sender, EventArgs e)
        {
            PlaylistModel playlistModel = new PlaylistModel();
            playlistModel.addSongToPlaylist(thePlaylist, songList[selectedSong]);

            parent.songAdded(songList[selectedSong]);

            removeAlbum(selectedSong);
        }
Esempio n. 7
0
        //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;
        }
Esempio n. 8
0
        //Method to show playlist window
        private void picBoxPlaylist_Click(object sender, EventArgs e)
        {
            hideForms();

            PlaylistModel playlistModel = new PlaylistModel();
            List<Playlist> playlistList = playlistModel.getPlaylistsForUser(currentUser.getUsername());

            playlists.currentUser = currentUser.getUsername();
            playlists.TopLevel = false;
            playlists.Parent = this;
            playlists.resetLabels();
            playlists.createLabels(playlistList);
            playlists.FormBorderStyle = FormBorderStyle.None;

            picBoxBackground.Hide();

            playlists.Show();
        }
Esempio n. 9
0
        //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);
        }
Esempio n. 10
0
        //Method to load search results window in child form
        private void loadSearchResults(List<Song> songs, List<String> artists, List<Playlist> playlists, String searchText)
        {
            //Clear previous search
            searchResults.resetSearch();

            //Set artist and song and playlists results from parameters
            searchResults.setSongList(songs);
            searchResults.setArtistList(artists);
            searchResults.setPlaylistList(playlists);

            //Set user's playlists
            searchResults.setCurrentUser(currentUser);

            PlaylistModel pm = new PlaylistModel();
            List<Playlist> lp = pm.getPlaylistsForUser(currentUser.getUsername());

            searchResults.setUsersPlaylists(lp);
            searchResults.createSongList(searchText);
            searchResults.createArtistList();
            searchResults.createPlaylistList();
            searchResults.addPlaylistLabels();

            picBoxBackground.Hide();

            searchResults.TopLevel = false;
            searchResults.Parent = this;
            searchResults.FormBorderStyle = FormBorderStyle.None;
            searchResults.Show();
        }
Esempio n. 11
0
        //When leaving mouse hover of edit box, save
        private void txtPlaylistNameEdit_MouseLeave(object sender, EventArgs e)
        {
            //Get new name
            String curr = (txtPlaylistNameEdit.Text).Trim();
            if (!curr.Equals(""))
            {
                //Update text for user
                lblPlaylistName.Text = curr;

                String first6 = thePlaylist.getPlaylistName().Substring(0, 6);

                if (this.currentUser.Equals(thePlaylist.getOwner()))
                {
                    if (!first6.Equals("$temp$"))
                    {
                        lblPlaylistName.Text = thePlaylist.getPlaylistName().Substring(6);
                        thePlaylist.setName(thePlaylist.getPlaylistName().Substring(6));
                        picSave.Visible = false;
                    }
                    picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10;
                }
                else
                {
                    picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 15 + picSave.Width;
                }

                //Convert to string for use in method
                String newPlaylistName = curr;

                //Update playlistname in database
                PlaylistModel playlistModel = new PlaylistModel();

                playlistModel.renamePlaylist(thePlaylist, newPlaylistName);

                //Hide textbox
                txtPlaylistNameEdit.Hide();

                //Show label again
                lblPlaylistName.Show();

                picSave.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10;
            }
            else
            {
                //Do nothing
            }
        }
Esempio n. 12
0
        private void removeSong(object sender, EventArgs e)
        {
            // Convert the sender to a picture box
            PictureBox picBox = (PictureBox)sender;
            // Get the index from the tag
            int index = int.Parse(picBox.Tag.ToString());
            // Get the relevant song
            Song theSong = songs[index];

            // Remove the song from the playlist
            PlaylistModel playlistModel = new PlaylistModel();
            playlistModel.removeSongFromPlaylist(thePlaylist, theSong);

            this.Controls.Remove(removeLabels[index]);
            removeLabels.RemoveAt(index);

            this.Controls.Remove(artistLabels[index]);
            artistLabels.RemoveAt(index);

            this.Controls.Remove(songLabels[index]);
            songLabels.RemoveAt(index);

            this.Controls.Remove(positionLabels[index]);
            positionLabels.RemoveAt(index);

            songs.RemoveAt(index);

            for (int i = index; i < songs.Count; i++)
            {
                removeLabels[i].Top -= 33;
                artistLabels[i].Top -= 33;
                positionLabels[i].Top -= 33;
                songLabels[i].Top -= 33;
                positionLabels[i].Text = (i + 1).ToString();
                removeLabels[i].Tag = (i).ToString();
                artistLabels[i].Tag = (i).ToString();
                positionLabels[i].Tag = (i).ToString();
                songLabels[i].Tag = (i).ToString();

                if (i % 2 == 0)
                {
                    positionLabels[i].BackColor = Color.FromArgb(60, 60, 60);
                    songLabels[i].BackColor = Color.FromArgb(60, 60, 60);
                    artistLabels[i].BackColor = Color.FromArgb(60, 60, 60);
                }
                else
                {
                    positionLabels[i].BackColor = Color.FromArgb(40, 40, 40);
                    songLabels[i].BackColor = Color.FromArgb(40, 40, 40);
                    artistLabels[i].BackColor = Color.FromArgb(40, 40, 40);
                }

                setupAlbumCovers(songs);
            }
        }
Esempio n. 13
0
 private void picSave_Click(object sender, EventArgs e)
 {
     PlaylistModel playlistModel = new PlaylistModel();
     playlistModel.savePlaylist(this.thePlaylist, currentUser);
     MessageBox.Show("Playlist Saved");
     picSave.Visible = false;
 }
        private void cmdCreatePlaylist_Click(object sender, EventArgs e)
        {
            String playlist = Microsoft.VisualBasic.Interaction.InputBox("Playlist Name: ", "Playlist Name");
            Guid id = Guid.NewGuid();
            List<Song> songs = new List<Song>();

            Playlist newPlaylist = new Playlist(playlist, id, this.currentUser, songs);

            PlaylistModel playlistModel = new PlaylistModel();
            playlistModel.createPlaylist(newPlaylist);
            playlists.Add(newPlaylist);

            #region createLabel
            int count = playlists.Count - 1;
            Label newLabel = new Label();
            newLabel.Text = newPlaylist.getPlaylistName();
            newLabel.Size = new Size(400, 30);
            newLabel.ForeColor = Color.White;
            newLabel.Tag = count.ToString();
            newLabel.Click += playlistSelected;
            if (count % 2 == 0) { newLabel.BackColor = Color.FromArgb(20, 20, 20); } else { newLabel.BackColor = Color.FromArgb(60, 60, 60); }
            newLabel.Location = new Point(290, 120 + (count * 30));
            newLabel.Font = new System.Drawing.Font("Franklin Gothic Medium", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            labelList.Add(newLabel);

            this.Controls.Add(labelList[count]);

            #endregion

            #region createLabelRemove
            PictureBox deleteButton = new PictureBox();
            deleteButton.Size = new Size(20, 20);
            deleteButton.Tag = count.ToString();
            deleteButton.Click += deletePlaylist;
            deleteButton.BackgroundImage = Properties.Resources.removeFromPlaylist;
            deleteButton.BackgroundImageLayout = ImageLayout.Stretch;
            deleteButton.Location = new Point(700, 125 + (count * 30));

            deleteLabels.Add(deleteButton);

            this.Controls.Add(deleteLabels[count]);

            #endregion
        }
        private void deletePlaylist(object sender, EventArgs e)
        {
            PictureBox p = (PictureBox)sender;
            int index = int.Parse(p.Tag.ToString());

            DialogResult dialogResult = MessageBox.Show("Are you sure you wish to delete playlist: " + labelList[index].Text + "?", "Confirm Deletion", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                // do, do delete
                PlaylistModel playlistModel = new PlaylistModel();
                playlistModel.deletePlaylist(this.playlists[index]);

                this.Controls.Remove(labelList[index]);
                labelList.RemoveAt(index);
                this.Controls.Remove(deleteLabels[index]);
                deleteLabels.RemoveAt(index);
                this.playlists.RemoveAt(index);

                int count = this.playlists.Count - 1;
                resetLabels();
                createLabels(this.playlists);

            }
            // do repositioning/resetting stuff
        }