Exemple #1
0
        private void renameCurrentPlaylistToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ManagePlayListForm managePlayListForm = new ManagePlayListForm(this);

            if (managePlayListForm.ShowDialog() == DialogResult.OK)
            {
                string newPlName = managePlayListForm.newPlaylistName;
                if (playlistsModel.renameOldPlaylist(currentPlaylist, newPlName))
                {
                    /*
                     * foreach (ToolStripMenuItem item in playlistsToolStripMenuItem.DropDownItems)    //уборка текущего плейлиста
                     * {
                     *    if (item.Name == currentPlaylist)
                     *    {
                     *        playlistsToolStripMenuItem.DropDownItems.Remove(item);
                     *        break;
                     *    }
                     * }   //*/
                    ToolStripMenuItem buffer = new ToolStripMenuItem();
                    buffer.Checked = true;
                    buffer.Text    = newPlName;

                    playlistsToolStripMenuItem.DropDownItems.Find(newPlName, true)[0] = buffer;
                }
            }
        }
Exemple #2
0
        private void newPlaylistToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ManagePlayListForm managePlayListForm = new ManagePlayListForm();

            if (managePlayListForm.ShowDialog() == DialogResult.OK)
            {
                string newPlName = managePlayListForm.newPlaylistName;
                if (playlistsModel.addNewPlaylist(newPlName))
                {
                    foreach (ToolStripMenuItem item in playlistsToolStripMenuItem.DropDownItems)    //уборка текущего плейлиста
                    {
                        if (item.Checked == true)
                        {
                            item.Checked = false;
                        }
                    }

                    ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem();
                    toolStripMenuItem.Text = newPlName;
                    playlistsToolStripMenuItem.DropDownItems.Add(toolStripMenuItem); //добавить плейлист в менюайтем
                    toolStripMenuItem.Checked = true;                                //сделать его текущим
                    currentPlaylist           = newPlName;                           //смена текущего плейлиста
                    toolStripMenuItem.Click  += ToolStripMenuItem_Click;
                    playListBox.Items.Clear();                                       //очистить список дорожек
                }
                else
                {
                    throw new SQLiteException("Не смог создать плейлист, прости хозяин");
                }
            }
        }