Пример #1
0
        public List <string> Load(string path, LoadListener listener)
        {
            listener.NotifyNewLoad();
            Messenger.PostMessage("Counting files, please be patient", Messenger.TargetType.Frontend);
            var list = fileCollector.CollectFileNamesSync(path);

            Messenger.PostMessage("Now adding " + list.Count + " files to library. Please be patient.",
                                  Messenger.TargetType.Frontend);
            return(list);
        }
Пример #2
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();
        }
Пример #3
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();
        }
Пример #4
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();
        }
Пример #5
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);
        }
Пример #6
0
 public void NotifyNewLoad()
 {
     attachedListener?.NotifyNewLoad();
     NewLoad?.Invoke(this, EventArgs.Empty);
 }