예제 #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);
 }