예제 #1
0
        void HandleSongsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            NotifyPropertyChanged(Properties.LengthInfo);

            if (!Songs.IsRootChanging)
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    oldIndex = e.OldStartingIndex;
                }
                else if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    int newIndex = e.NewStartingIndex;

                    Songs.IsEndChanging = true;

                    rootModel.MoveSong(oldIndex, newIndex);

                    Songs.IsEndChanging = false;
                }
            }

            QueueAllSongs.RaiseExecuteChanged();
            PlayAllSongs.RaiseExecuteChanged();
            ShuffleAllSongs.RaiseExecuteChanged();
        }
예제 #2
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();
            }
        }