Esempio n. 1
0
        public ViewPlaylist(Playlist playlist, frmMusicPlayer music, User currentUser, HomePage parent)
        {
            InitializeComponent();

            picSave.Visible = true;

            //Set player, playlist, user
            this.musicPlayer = music;
            this.currentUser = currentUser;
            this.thePlaylist = playlist;
            lblPlaylistName.Text = thePlaylist.getPlaylistName();
            lblOwner.Text = thePlaylist.getOwner();
            this.parent = parent;

            //Initially hide edit box
            txtPlaylistNameEdit.Hide();

            List<Song> songs = thePlaylist.getSongs();
            int numSongs = thePlaylist.getSongs().Count;

            lblNumSongs.Text = numSongs.ToString();

            if (numSongs == 1) { lblNumSongs.Text += " song"; } else { lblNumSongs.Text += " songs"; }

            //Get total playlist length
            int totalLength = 0;
            for (int i = 0; i < songs.Count; i++)
            {
                totalLength += songs[i].getLength();
            }

            int hours = totalLength / 3600;
            int minutes = (totalLength - hours * 3600) / 60;
            int seconds = totalLength - (hours * 3600) - (minutes * 60);

            //Set up string saying how long the playlist is
            String output = "";
            if(hours > 0)
            {
                output += hours.ToString() + " hours, \n";
            }
            if (minutes > 0)
            {
                output += minutes.ToString() + " minutes, \n";
            }
            if (seconds > 0)
            {
                output += seconds.ToString() + " seconds, \n";
            }

            if (output.Equals(""))
            {
                output = "O seconds";
            }
            else {
                output = output.Substring(0, output.Length - 3);
            }

            //Set length to label
            lblTime.Text = output;

            String currUser = this.currentUser.getUsername();
            String owner = thePlaylist.getOwner();

            String first6 = "";

            if (!(thePlaylist.getPlaylistName().Length < 6))
            {
                first6 = thePlaylist.getPlaylistName().Substring(0, 6);
            }

            if (currUser.Equals(owner) && first6 != "" )
            {
                if (first6.Equals("$temp$"))
                {
                    lblPlaylistName.Text = thePlaylist.getPlaylistName().Substring(6);
                    thePlaylist.setName(thePlaylist.getPlaylistName().Substring(6));
                }
                else {
                    picSave.Visible = false;
                }
                picRecommend.Visible = true;
                picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10;
            }
            else
            {
                picSave.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10;
                picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 15 + picSave.Width;
                picRecommend.Visible = false;
            }
        }
Esempio n. 2
0
        public void createTempPlaylist(Playlist p)
        {
            try
            {
                //init();
                ISession session = cluster.Connect("maltmusic");

                String plName = p.getPlaylistName();
                Guid pid = p.getID();
                String owner = p.getOwner();

                String todo = ("insert into list_playlist (\n" +
                      "playlist_id, owner,playlist_name)\n" +
                     "values (:pid,:own,:plnm) if not exists using TTL 3600");

                PreparedStatement ps = session.Prepare(todo);

                BoundStatement bs = ps.Bind(pid, owner, plName);

                session.Execute(bs);

                addToTempPlaylist(p, session);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception during playlist create" + e);
            }
        }
        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
        }