コード例 #1
0
ファイル: PLForm.cs プロジェクト: henanMayueyue/MediaPlayer
        private void Savebtn_Click(object sender, EventArgs e)
        {
            if (PLNTextBox.Text.Equals("") && NewPLlistBox.Items.Count == 0)
            {
                MessageBox.Show("Please suggest any name to playlist and Please add track to playlist");
                return;
            }

            if (PLNTextBox.Text.Equals(""))
            {
                MessageBox.Show("Please suggest any name to playlist");
                return;
            }
            if (ANTextBox.Text.Equals(""))
            {
                MessageBox.Show("Please suggest any author name to playlist");
                return;
            }

            if (NewPLlistBox.Items.Count == 0)
            {
                MessageBox.Show("Please add track to playlist");
                return;
            }

            switch (action)
            {
            case "ADD":
            {
                SaveNewPlaylist();
                break;
            }

            case "SAVE":
            {
                SaveNewPlaylist();
                break;
            }

            case "EDIT":
            {
                if (!playlistName.Equals(PLNTextBox.Text))
                {
                    MyPlaylistData.delete(playlistName);
                    MyPlaylists.delete(playlistName);
                    MyPlaylists.setPlaylistNames(new String[] { PLNTextBox.Text });
                }

                MyPlaylistData.setPlaylist(PLNTextBox.Text, ANTextBox.Text, playlist);

                MessageBox.Show("Playlist Named: \"" + PLNTextBox.Text + "\" successfully edited");
                NewPLlistBox.Items.Clear();
                PLNTextBox.Clear();
                ANTextBox.Clear();
                this.Close();
                break;
            }
            }
            playlist = null;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: henanMayueyue/MediaPlayer
        private void DelBtnPL_Click(object sender, EventArgs e)
        {
            int selIndex = PLlistBox.SelectedIndex;

            // Prepare a message, a caption and buttons for the user prompt
            string            message = "Remove \"" + PLlistBox.Items[selIndex] + "\" Playlist?";
            string            caption = "Confirm Deletion";
            MessageBoxButtons buttons = MessageBoxButtons.OKCancel;

            // Prompt the user for permission to delete the object
            DialogResult result = MessageBox.Show(message, caption, buttons);

            // Check the user response
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    String name = PLlistBox.SelectedItem.ToString();
                    PLlistBox.Items.Remove(PLlistBox.SelectedItem);
                    MyPlaylistData.delete(name);
                    MyPlaylists.delete(name);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to Delete PlayList!\n\n" + ex.Message);
                }

                // Report that the item was deleted
                MessageBox.Show("Item Deleted\t\t\t");

                if (selIndex == 0 && PLlistBox.Items.Count > 0)
                {
                    PLlistBox.SelectedIndex = 0;
                }
                else
                {
                    PLlistBox.SelectedIndex = selIndex - 1;
                }
            }

            if (PLlistBox.Items.Count == 0)
            {
                PlayBtnPL.Enabled = false;
                DelBtnPL.Enabled  = false;
                EditBtn.Enabled   = false;
            }
        }