Пример #1
0
        public void DeleteArtist(string artist, LoadListener progressTracker)
        {
            var songs = library.GetSongsByArtist(artist);

            progressTracker.NotifyNewLoad();
            progressTracker.NotifyLoadInitiated(songs.Count + 1);
            foreach (var song in songs)
            {
                library.RemoveById(song.ID);
                progressTracker.NotifyProgress(1);
            }

            library.InitialiseParts();
            progressTracker.NotifyProgress(1);
            progressTracker.NotifyCompleted(new List <Song>());
            NotifyUpdated();
        }
Пример #2
0
 public Task Load(List <string> files, LoadListener listener1, CancellationToken cancelToken)
 {
     return(Task.Run(() =>
     {
         listener1.NotifyProgress(1);
         listener1.NotifyCompleted(Songs);
     }, cancelToken));
 }
Пример #3
0
        public Task <List <string> > LoadAsync(string path, LoadListener listener)
        {
            var task = Task.Run(() =>
            {
                Path          = path;
                this.listener = listener;
                Initiate();
                listener.NotifyProgress(1);
                var list1 = list.Select((e) => e.Name).ToList();
                return(list1);
            });

            task.Wait();
            return(task);
        }
Пример #4
0
        public void DeleteSongs(IList <Song> songs, LoadListener progressTracker)
        {
            progressTracker.NotifyNewLoad();
            progressTracker.NotifyLoadInitiated(songs.Count);

            foreach (var s in songs)
            {
                library.RemoveById(s.ID);
                Messenger.Post("Deleted song: " + s.Name);
                progressTracker.NotifyProgress(1);
            }

            progressTracker.NotifyCompleted(songs);
            library.InitialiseParts();
            NotifyUpdated();
        }
Пример #5
0
        public void DeleteAlbum(string album, LoadListener listener)
        {
            var songsToDelete = library.GetSongsByAlbum(album);

            listener.NotifyNewLoad();
            listener.NotifyLoadInitiated(songsToDelete.Count);
            foreach (var song in songsToDelete)
            {
                library.RemoveById(song.ID);
                listener.NotifyProgress(1);
            }

            library.InitialiseParts();
            listener.NotifyCompleted(new List <Song>());
            NotifyUpdated();
        }
Пример #6
0
        private Task LoadPartial(List <string> list)
        {
            return(Task.Run(() =>
            {
                if (list.Count > 2000)
                {
                    splits++;
                    Messenger.Log("Do split! " + splits + " Count " + list.Count);
                    SplitAndLoad(list);
                    splits--;
                    Messenger.Log("Post split. " + splits);
                    return;
                }

                foreach (var file in list)
                {
                    cancelToken.ThrowIfCancellationRequested();
                    LoadSong(file);
                    listener.NotifyProgress(1);
                }

                Messenger.Log("Done chunk! " + splits);
            }, cancelToken));
        }
Пример #7
0
 public void NotifyProgress(int progressed)
 {
     attachedListener?.NotifyProgress(progressed);
     LoadProgress?.Invoke(this, progressed);
 }
Пример #8
0
 public void SignalProgress()
 {
     listener?.NotifyProgress(1);
 }