Пример #1
0
        private void HandlePlaybackQueueCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (!PlaybackQueue.IsRootChanging)
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    oldIndex = e.OldStartingIndex;
                }
                else if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    int newIndex = e.NewStartingIndex;

                    PlaybackQueue.IsEndChanging = true;

                    rootModel.MoveSong(oldIndex, newIndex);

                    PlaybackQueue.IsEndChanging = false;
                }
            }
            else
            {
                if (e.Action == NotifyCollectionChangedAction.Remove ||
                    e.Action == NotifyCollectionChangedAction.Replace)
                {
                    foreach (PlayQueueEntryViewModel model in e.OldItems)
                    {
                        LookupDictionary.Remove(model.RowId);
                    }
                }
                if (e.Action == NotifyCollectionChangedAction.Add ||
                    e.Action == NotifyCollectionChangedAction.Replace)
                {
                    foreach (PlayQueueEntryViewModel model in e.NewItems)
                    {
                        LookupDictionary.Add(model.RowId, model);
                    }
                }
                if (e.Action == NotifyCollectionChangedAction.Reset)
                {
                    LookupDictionary.Clear();
                }

                PlayPausePlayer.RaiseExecuteChanged();
                ShuffleRemaining.RaiseExecuteChanged();
                NotifyPropertyChanged(Properties.IsEmpty);
            }

            int currentPosition = 1;

            foreach (PlayQueueEntryViewModel model in PlaybackQueue)
            {
                model.TotalPosition = currentPosition;
                currentPosition++;
            }
            NotifyPropertyChanged(Properties.NextTrack);
            NotifyPropertyChanged(Properties.PrevTrack);
            NotifyPropertyChanged(Properties.TracksLeft);
            ClearPlayed.RaiseExecuteChanged();
            ClearAll.RaiseExecuteChanged();
        }
Пример #2
0
        void HandleRootModelPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case PlayQueueModel.Properties.IsActive:
                NotifyPropertyChanged(Properties.IsActive);
                break;

            case PlayQueueModel.Properties.NowPlaying:
                CurrentTrack = LibraryViewModel.Current.LookupSongById(rootModel.NowPlaying);
                break;

            case PlayQueueModel.Properties.NextTrack:
                NotifyPropertyChanged(Properties.NextTrack);
                SkipPlayer.RaiseExecuteChanged();
                break;

            case PlayQueueModel.Properties.PrevTrack:
                NotifyPropertyChanged(Properties.PrevTrack);
                PrevPlayer.RaiseExecuteChanged();
                break;

            case PlayQueueModel.Properties.IsPlaying:
                NotifyPropertyChanged(Properties.IsPlaying);
                break;

            case PlayQueueModel.Properties.CurrentTime:
                NotifyPropertyChanged(Properties.TimeLeft);
                NotifyPropertyChanged(Properties.ElapsedTime);
                NotifyPropertyChanged(Properties.PercentTime);
                NotifyPropertyChanged(Properties.ProgressTime);
                break;

            case PlayQueueModel.Properties.FullTime:
                NotifyPropertyChanged(Properties.TimeLeft);
                NotifyPropertyChanged(Properties.TotalTicks);
                NotifyPropertyChanged(Properties.TotalTime);
                NotifyPropertyChanged(Properties.PercentTime);
                NotifyPropertyChanged(Properties.ProgressTime);
                break;

            case PlayQueueModel.Properties.CurrentPlaybackQueueEntryId:
                NotifyPropertyChanged(Properties.CurrentTrackRowId);
                NotifyPropertyChanged(Properties.CurrentTrackPosition);
                NotifyPropertyChanged(Properties.TracksLeft);
                NotifyPropertyChanged(Properties.NextTrack);
                NotifyPropertyChanged(Properties.PrevTrack);
                ClearPlayed.RaiseExecuteChanged();
                break;
            }
        }