示例#1
0
        public async Task Load(List <string> files, LoadListener listener, CancellationToken cancelToken)
        {
            this.listener    = listener;
            this.cancelToken = cancelToken;
            lock (songs)
            {
                songs.Clear();
            }

            try
            {
                await Task.Run(() =>
                {
                    splits = 0;
                    listener.NotifyLoadInitiated(files.Count);
                    SplitAndLoad(files);
                }, cancelToken);
            }
            catch (Exception e)
            {
                Messenger.Log("Canceled!");
            }

            lock (songs)
            {
                Messenger.Log("Collected songs: " + songs.Count);
                listener.NotifyCompleted(songs);
            }
        }
 public Task Load(List <string> files, LoadListener listener1, CancellationToken cancelToken)
 {
     return(Task.Run(() =>
     {
         listener1.NotifyProgress(1);
         listener1.NotifyCompleted(Songs);
     }, cancelToken));
 }
示例#3
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();
        }
示例#4
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();
        }
示例#5
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();
        }
示例#6
0
        private IList <Song> LoadFromXml(LoadListener listener)
        {
            if (!File.Exists(filename))
            {
                throw new Exception(filename + " not found!");
            }

            listener.NotifyNewLoad();

            List <PersistedSong> songs = null;

            using (var reader = XmlReader.Create(filename))
            {
                songs = new List <PersistedSong>((PersistedSong[])serializerInstance.Deserialize(reader));
            }

            Messenger.Post("Library reloaded from " + filename);
            var convertedSongs = new SongConverter().ConvertPersistedSongs(songs);

            Messenger.Log("Persisted songs converted");
            listener.NotifyLoadInitiated(convertedSongs.Count);
            listener.NotifyCompleted(convertedSongs);
            return(convertedSongs);
        }
示例#7
0
 public void NotifyCompleted(IList <Song> loadedSongs)
 {
     attachedListener?.NotifyCompleted(loadedSongs);
     UpdateLibrary(loadedSongs, true);
     LoadCompleted?.Invoke(this, EventArgs.Empty);
 }
 public void SignalComplete()
 {
     listener?.NotifyCompleted(list);
 }