Ejemplo n.º 1
0
        public async Task RemovePlaylist(UserPlaylist playlist)
        {
            Playlists.Remove(playlist);
            PlaylistRemoved?.Invoke(this, playlist);

            using (
                var command =
                    new SQLiteCommand(
                        "DELETE FROM `Playlists` WHERE Guid=@guid", _connection))
            {
                command.Parameters.AddGuid("@guid", playlist.Id);

                await command.ExecuteNonQueryAsync();
            }

            using (
                var command =
                    new SQLiteCommand(
                        "DELETE FROM `PlaylistTracks` WHERE PlaylistId=@guid", _connection))
            {
                command.Parameters.AddGuid("@guid", playlist.Id);

                await command.ExecuteNonQueryAsync();
            }
        }
Ejemplo n.º 2
0
        private void FileWatcherRenamed(object sender, RenamedEventArgs e)
        {
            Trace.WriteLine(Trace.kKinsky, "PlaylistWatcher.FileSystemWatcherRenamed: e.OldFullPath=" + e.OldFullPath + ", e.FullPath=" + e.FullPath);

            // a file has been renamed - rename the corresponding entry
            bool playlistRenamed = false;

            lock (iLock)
            {
                if (iPlaylists.ContainsKey(e.OldFullPath))
                {
                    iPlaylists.Remove(e.OldFullPath);
                    FileInfo i = new FileInfo(e.FullPath);
                    iPlaylists.Add(i.FullName, i.Name.Replace(i.Extension, ""));
                    playlistRenamed = true;
                }
            }

            if (playlistRenamed)
            {
                PlaylistRemoved evRem = EventPlaylistRemoved;
                if (evRem != null)
                {
                    evRem(e.OldFullPath);
                }
                PlaylistAdded evAdd = EventPlaylistAdded;
                if (evAdd != null)
                {
                    evAdd(e.FullPath);
                }
            }
        }
Ejemplo n.º 3
0
        private void FileWatcherChanged(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Deleted)
            {
                // the file has been removed - remove the corresponding entry
                bool playlistRemoved = false;
                lock (iLock)
                {
                    if (iPlaylists.ContainsKey(e.FullPath))
                    {
                        iPlaylists.Remove(e.FullPath);
                        playlistRemoved = true;
                    }
                }

                // if the file was removed from the list, send event
                PlaylistRemoved ev = EventPlaylistRemoved;
                if (playlistRemoved && ev != null)
                {
                    ev(e.FullPath);
                }
            }
            else
            {
                // some unknown change has happened - rescan the save directory
                lock (iLock)
                {
                    Rescan();
                }

                // send the event
                PlaylistsChanged ev = EventPlaylistsChanged;
                if (ev != null)
                {
                    ev();
                }
            }
        }
 internal virtual void OnPlaylistRemoved(PlaylistEventArgs e)
 {
     PlaylistRemoved.RaiseEvent(this, e);
 }