Ejemplo n.º 1
0
 private void MakePlaylist(DirectoryInfo folderDirectory)
 {
     if (currentPlaylist == null)
     {
         listOfPlaylists = new ListPlaylists();
         isPlaylist      = true;
         listOfPlaylists.AddPlaylist(new Playlist(folderDirectory));
         currentPlaylist = listOfPlaylists.GetCurrentPlaylist();
         playlistTreeView.Items.Add(CreateDirectoryNode(folderDirectory));
     }
     else
     {
         Playlist newPlaylist = new Playlist(folderDirectory);
         if (!listOfPlaylists.Contains(folderDirectory.Name))
         {
             isPlaylist = true;
             listOfPlaylists.AddPlaylist(newPlaylist);
             playlistTreeView.Items.Add(CreateDirectoryNode(folderDirectory));
         }
     }
 }
Ejemplo n.º 2
0
        private void DeletePlaylist(object sender, RoutedEventArgs e)
        {
            if (selectedPlaylist != null && isSelectedPlaylist && !isSelectedPlaylistAudio)
            {
                if (listOfPlaylists.IsAnyPlaylist())
                {
                    if (currentPlaylist.GetPlaylistName() == selectedPlaylist)
                    {
                        foreach (var file in listOfPlaylists.GetPlaylist(selectedPlaylist).GetPlaylistDirectory().GetFiles("*.mp3"))
                        {
                            if (currentAudioFile != null)
                            {
                                if (file.Name == currentAudioFile.GetTitle() + ".mp3")
                                {
                                    StopFile(sender, e);
                                    currentAudioFile.RemoveAudio();
                                    currentAudioFile = null;
                                    if (outputDevice != null)
                                    {
                                        outputDevice.Dispose();
                                    }
                                    GC.Collect();
                                    GC.WaitForPendingFinalizers();
                                    outputDevice = new WaveOut();
                                    isAudio      = false;
                                }
                            }
                            listOfPlaylists.GetPlaylist(selectedPlaylist).DeleteFile(file.Name);
                        }

                        listOfPlaylists.DeletePlaylist(selectedPlaylist);
                        if (listOfPlaylists.GetSize() > 1)
                        {
                            currentPlaylist = listOfPlaylists.Last();
                        }
                        else
                        {
                            if (listOfPlaylists.GetSize() == 0)
                            {
                                currentPlaylist = null;
                                SetBeginning(sender, e);
                            }
                        }
                    }
                    else
                    {
                        listOfPlaylists.DeletePlaylist(selectedPlaylist);
                    }
                    if (listOfPlaylists.GetSize() == 0)
                    {
                        listOfPlaylists = null;
                    }

                    foreach (var item in playlistTreeView.Items)
                    {
                        TreeViewItem dirNode = (TreeViewItem)item;
                        if ((string)dirNode.Header == selectedPlaylist)
                        {
                            playlistTreeView.Items.Remove(dirNode);
                            break;
                        }
                    }
                    isSelectedPlaylist = false;
                }
            }
        }