Esempio n. 1
0
 internal void AlertSongChanged(SongViewModel songViewModel, string propertyName)
 {
     foreach (MixViewModel mix in MixCollection)
     {
         mix.OnSongPropertyChanged(songViewModel, propertyName);
     }
 }
Esempio n. 2
0
        public void ReevaulateSong(SongViewModel song)
        {
            bool belongsInList = !IsCircular && RootEvaluator.Eval(song);

            bool updated = false;

            if (belongsInList && !CurrentSongs.ActuallyContains(song))
            {
                CurrentSongs.Add(song);

                updated = true;
            }
            else if (!belongsInList && CurrentSongs.ActuallyContains(song))
            {
                CurrentSongs.Remove(song);

                updated = true;
            }

            if (updated && !IsCircular)
            {
                foreach (MixViewModel mixViewModel in DependentMixes)
                {
                    mixViewModel.ReevaulateSong(song);
                }
            }
        }
Esempio n. 3
0
        private SongViewModel LookupSong(SongModel song)
        {
            if (song == null)
            {
                return(null);
            }

            if (SongLookupMap.ContainsKey(song.SongId))
            {
                return(SongLookupMap[song.SongId]);
            }
            else
            {
                ArtistViewModel artist = LookupArtistById(song.ArtistId);

                AlbumViewModel album = LookupAlbumById(song.AlbumId);

                SongViewModel newSongViewModel = new SongViewModel(song, artist, album);

                SongLookupMap.Add(newSongViewModel.SongId, newSongViewModel);
                SongCollection.Add(newSongViewModel, newSongViewModel.SortName);
                FlatSongCollection.Add(newSongViewModel);

                if (LibraryLoaded)
                {
                    NotifyPropertyChanged(Properties.IsEmpty);
                }

                return(newSongViewModel);
            }
        }
Esempio n. 4
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            SongViewModel otherSong = obj as SongViewModel;

            if (otherSong != null)
            {
                if (otherSong.SortName == this.SortName)
                {
                    return(this.Album.CompareTo(otherSong.Album));
                }
                else
                {
                    return(this.SortName.CompareTo(otherSong.SortName));
                }
            }
            else
            {
                throw new ArgumentException("Object is not a SongViewModel");
            }
        }
Esempio n. 5
0
        internal void RemoveAllInstancesOfSong(SongViewModel song)
        {
            rootModel.RemoveSong(song.SongId);

            foreach (MixViewModel mixViewModel in DependentMixes)
            {
                mixViewModel.ReevaulateSong(song);
            }
        }
Esempio n. 6
0
        public void AddSong(SongViewModel songToAdd)
        {
            rootModel.AddSong(songToAdd.SongId);

            foreach (MixViewModel mixViewModel in DependentMixes)
            {
                mixViewModel.ReevaulateSong(songToAdd);
            }
        }
Esempio n. 7
0
        public void ReevaulateSong(SongViewModel song)
        {
            bool belongsInList = !IsCircular && RootEvaluator.Eval(song);

            if (belongsInList && !CurrentSongs.ActuallyContains(song))
            {
                CurrentSongs.Add(song);
            }
            else if (!belongsInList && CurrentSongs.ActuallyContains(song))
            {
                CurrentSongs.Remove(song);
            }
        }
Esempio n. 8
0
        internal bool AddSong(StorageProviderSong song, bool resetSongData)
        {
            SongModel songFromSource = LibraryModel.Current.GetSongFromSource(StorageProviderSourceToSongOriginSource(song.Origin), song.Source);

            if (songFromSource != null)
            {
                if (resetSongData)
                {
                    SongViewModel songViewModel = LookupSong(songFromSource);

                    songViewModel.Name = song.Name;

                    songViewModel.ArtistName = song.Artist;

                    string newAlbumName      = song.Album;
                    string newAlbumAristName = song.AlbumArtist;

                    if (newAlbumName != songViewModel.Album.Name || newAlbumAristName != songViewModel.Album.ArtistName)
                    {
                        ArtistViewModel albumArtistViewModel = LibraryViewModel.Current.LookupArtistByName(newAlbumAristName);
                        AlbumViewModel  newAlbumViewModel    = LibraryViewModel.Current.LookupAlbumByName(newAlbumName, albumArtistViewModel.ArtistId);

                        songViewModel.UpdateAlbum(newAlbumViewModel);
                    }

                    songViewModel.TrackNumber = song.TrackNumber;
                }
                return(false);
            }

            SongModel newSongModel = LibraryModel.Current.AddNewSong(
                song.Artist,
                song.Album,
                song.AlbumArtist,
                song.Name,
                song.Source,
                StorageProviderSourceToSongOriginSource(song.Origin),
                song.Duration.Ticks,
                song.Rating,
                song.TrackNumber
                );

            if (LookupSong(newSongModel) == null)
            {
                DebugHelper.Alert(new CallerInfo(), "Failed to add song");
                return(false);
            }

            return(true);
        }
Esempio n. 9
0
        private void HandleAllSongsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                foreach (SongViewModel oldSongViewModel in FlatSongCollection)
                {
                    oldSongViewModel.Album.Songs.Remove(oldSongViewModel);
                    oldSongViewModel.Artist.Songs.Remove(oldSongViewModel);

                    SongCollection.Remove(oldSongViewModel, oldSongViewModel.SortName);
                    FlatSongCollection.Remove(oldSongViewModel);
                    SongLookupMap.Remove(oldSongViewModel.SongId);
                }
            }
            else
            {
                if (e.OldItems != null)
                {
                    foreach (SongModel oldSong in e.OldItems)
                    {
                        SongViewModel oldSongViewModel = LookupSong(oldSong);

                        SongCollection.Remove(oldSongViewModel, oldSongViewModel.SortName);
                        FlatSongCollection.Remove(oldSongViewModel);
                        SongLookupMap.Remove(oldSongViewModel.SongId);

                        oldSongViewModel.Album.Songs.Remove(oldSongViewModel);
                        oldSongViewModel.Artist.Songs.Remove(oldSongViewModel);
                    }
                }

                if (e.NewItems != null)
                {
                    foreach (SongModel newSong in e.NewItems)
                    {
                        LookupSong(newSong);
                    }
                }
            }

            if (LibraryLoaded)
            {
                NotifyPropertyChanged(Properties.IsEmpty);
                ShuffleAllSongs.RaiseExecuteChanged();
            }
        }
Esempio n. 10
0
        internal void DeleteSong(SongViewModel song)
        {
            foreach (PlaylistViewModel playlist in PlaylistCollection)
            {
                playlist.RemoveAllInstancesOfSong(song);
            }

            PlayQueue.RemoveAllInstancesOfSong(song);

            AlbumViewModel  album  = song.Album;
            ArtistViewModel artist = song.Artist;

            LibraryModel.Current.DeleteSong(song.SongId);

            RemoveAlbumIfNeeded(album);
            RemoveArtistIfNeeded(artist);
        }
Esempio n. 11
0
        public void OnSongPropertyChanged(SongViewModel song, string propertyName)
        {
            if (RootEvaluator.IsPropertyAffected(propertyName))
            {
                ReevaulateSong(song);
            }

            if (propertyName == MixSortOrderToSongProperty(SortType))
            {
                // Remove and reinsert to update sort order
                if (CurrentSongs.ActuallyContains(song))
                {
                    CurrentSongs.Remove(song);
                    CurrentSongs.Add(song);
                }
            }
        }
Esempio n. 12
0
        private async void SearchSongs(string query)
        {
            Songs.Clear();

            List <int> foundSongs = await SearchManagerModel.SearchSongs(query);

            foreach (int songId in foundSongs)
            {
                SongViewModel foundSong = LibraryViewModel.Current.LookupSongById(songId);
                if (foundSong != null)
                {
                    Songs.Add(foundSong);
                }
            }

            songSearchInProgress = false;
            NotifyPropertyChanged(Properties.SearchInProgress);
            NotifyPropertyChanged(Properties.ContentInfoSongs);
        }
Esempio n. 13
0
 internal void RemoveAllInstancesOfSong(SongViewModel song)
 {
     rootModel.RemoveSong(song.SongId);
 }
Esempio n. 14
0
 public void QueueSong(SongViewModel s)
 {
     rootModel.QueueSong(s.SongId);
 }
Esempio n. 15
0
 public void PlaySong(SongViewModel s)
 {
     rootModel.PlaySong(s.SongId);
 }
Esempio n. 16
0
 internal bool ContainsSong(SongViewModel song)
 {
     return(CurrentSongs.Contains(song));
 }
Esempio n. 17
0
 internal bool ContainsSong(SongViewModel song)
 {
     return(rootModel.ContainsSong(song.SongId));
 }
Esempio n. 18
0
 internal void AlertSongNameChanged(SongViewModel songViewModel, string oldName)
 {
     SongCollection.Remove(songViewModel, oldName);
     SongCollection.Add(songViewModel, songViewModel.SortName);
 }