Ejemplo n.º 1
0
 public ShellMenuViewModel(
     LibraryViewModel libraryViewModel,
     //AllTracksFilterViewModel allTracksViewModel,
     //AllTracksViewModel allTracksViewModel,
     PlaybackControlsViewModel playbackControlsViewModel)
 {
     this.LibraryViewModel = libraryViewModel ?? throw new ArgumentNullException(nameof(libraryViewModel));
     //this.AllTracksViewModel = allTracksViewModel ?? throw new ArgumentNullException(nameof(allTracksViewModel));
     this.PlaybackControlsViewModel = playbackControlsViewModel ?? throw new ArgumentNullException(nameof(playbackControlsViewModel));
 }
Ejemplo n.º 2
0
        //private readonly LibraryViewModel _libraryViewModel;

        #endregion

        #region ctors

        public LibrarySidebarViewModel(LibraryViewModel libraryViewModel)
        {
        }
Ejemplo n.º 3
0
        public ShellViewModel(
            IAudioPlaybackEngine audioPlaybackEngine,
            //IWriteLibraryService writeLibraryService,
            IReadLibraryService readLibraryService,
            IDialogService dialogService,
            LibraryViewModel libraryViewModel,
            PlaybackControlsViewModel playbackControlsViewModel,
            //PlaybackHistoryViewModel playbackHistoryViewModel,
            ShellMenuViewModel shellMenuViewModel,
            Func <MiniPlayerViewModel> _miniplayerViewModelFactoryMethod)
        {
            this._audioPlaybackEngine = audioPlaybackEngine ?? throw new ArgumentNullException(nameof(audioPlaybackEngine));
            //this._writeLibraryService = writeLibraryService ?? throw new ArgumentNullException(nameof(writeLibraryService));
            this._readLibraryService       = readLibraryService ?? throw new ArgumentNullException(nameof(readLibraryService));
            this._dialogService            = dialogService ?? throw new ArgumentNullException(nameof(dialogService));
            this.LibraryViewModel          = libraryViewModel ?? throw new ArgumentNullException(nameof(libraryViewModel));
            this.PlaybackControlsViewModel = playbackControlsViewModel ?? throw new ArgumentNullException(nameof(playbackControlsViewModel));
            //this.PlaybackHistoryViewModel = playbackHistoryViewModel ?? throw new ArgumentNullException(nameof(playbackHistoryViewModel));
            this.ShellMenuViewModel = shellMenuViewModel ?? throw new ArgumentNullException(nameof(shellMenuViewModel));
            this.miniplayerViewModelFactoryMethod = _miniplayerViewModelFactoryMethod ?? throw new ArgumentNullException(nameof(_miniplayerViewModelFactoryMethod));

            this._isEnabled_OAPH = Observable
                                   .Return(true)
                                   .ToProperty(this, nameof(this.IsEnabled))
                                   .DisposeWith(this._disposables);

            this._taskbarProgressState_OAPH = Observable.CombineLatest(
                this._audioPlaybackEngine.WhenStatusChanged,
                this._audioPlaybackEngine.WhenDurationChanged,
                this._audioPlaybackEngine.WhenPositionChanged,
                (status, duration, position) =>
            {
                switch (status)
                {
                case PlaybackStatus.Loaded:
                case PlaybackStatus.PlayedToEnd:
                case PlaybackStatus.ManuallyInterrupted:
                case PlaybackStatus.None:
                    return(TaskbarItemProgressState.None);

                case PlaybackStatus.Playing:
                    if (duration.HasValue && position.HasValue)
                    {
                        return(TaskbarItemProgressState.Normal);
                    }
                    return(TaskbarItemProgressState.Indeterminate);

                case PlaybackStatus.Paused:
                    return(TaskbarItemProgressState.Paused);

                case PlaybackStatus.Loading:
                    return(TaskbarItemProgressState.Indeterminate);

                case PlaybackStatus.Exploded:
                    return(TaskbarItemProgressState.Error);

                default:
                    return(TaskbarItemProgressState.None);
                }
            })
                                              .DistinctUntilChanged()
                                              .ToProperty(this, nameof(this.TaskbarProgressState))
                                              .DisposeWith(this._disposables);

            this._taskbarProgressValue_OAPH = Observable.CombineLatest(
                this._audioPlaybackEngine.WhenDurationChanged,
                this._audioPlaybackEngine.WhenPositionChanged,
                (duration, position) =>
            {
                if (duration.HasValue && position.HasValue)
                {
                    return(position.Value.TotalMilliseconds / duration.Value.TotalMilliseconds);
                }

                return(Double.NaN);
            })
                                              .DistinctUntilChanged()
                                              .ToProperty(this, nameof(this.TaskbarProgressValue))
                                              .DisposeWith(this._disposables);

            this._audioPlaybackEngine.WhenTrackChanged
            //.ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(track => this.UpdateDisplayName(track))
            .DisposeWith(this._disposables);

            this.HideShellAndShowMiniPlayer = ReactiveCommand.CreateFromTask(
                async() =>
            {
                var miniPlayerVM = this.miniplayerViewModelFactoryMethod.Invoke();

                this.IsVisible = false;

                await this._dialogService.ShowWindowAsync(miniPlayerVM);

                //this.IsVisible = true;
            })
                                              .DisposeWith(this._disposables);

            this.Items.Add(this.LibraryViewModel);
            this.Items.Add(this.PlaybackHistoryViewModel);
            this.Items.Add(this.PlaybackControlsViewModel);
            this.Items.Add(this.ShellMenuViewModel);
        }