Ejemplo n.º 1
0
        private void _saveToPlaylist_Click(object sender, EventArgs e)
        {
            var  selecteditem = _playlistListView.SelectedItems;
            bool exists       = false;

            if (!isSessionPL)
            {
                if (selecteditem[0] != null)
                {
                    exists = datafuncs.checkExists(selecteditem[0].Text);
                }
                else
                {
                    exists = datafuncs.checkExists(_playlistName.Text);
                }
            }

            if (exists)
            {
                selectedPL = datafuncs.loadPlaylist(playlists + _playlistListView.SelectedItems[0].Text + ".json");
                if (selectedPL.whizzyfilelist != null)
                {
                    foreach (Whizzyfile item in selectedPL.whizzyfilelist)
                    {
                        if (listinscope.Count != 0)
                        {
                            int count = 0;
                            if (item.Filepath == listinscope[count].Filepath)
                            {
                                listinscope.RemoveAt(count);
                            }
                            count++;
                        }
                    }
                    funcs.addListToExistingPlaylist(selectedPL, listinscope);
                }
                else
                {
                    funcs.addListToExistingPlaylist(selectedPL, listinscope);
                }

                datafuncs.savePlaylist(selectedPL, _playlistListView.SelectedItems[0].Text);
                allplaylists.Add(selectedPL);
            }
            else
            {
                using (DialogBox dialogbox = new DialogBox())
                {
                    dialogbox.textboxdata = "";
                    if (dialogbox.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        spl.playlistname = dialogbox.textboxdata;
                        datafuncs.createPlaylist(spl, dialogbox.textboxdata);
                        _playlistName.Text = spl.playlistname;
                    }
                }
                selectedPL = spl;
                if (spl.whizzyfilelist.Count != 0)
                {
                    spl.whizzyfilelist.Clear();
                }
                ;
            }
            isSessionPL = false;
            funcs.loadPlaylists(_playlistListView, allplaylists);
        }