コード例 #1
0
        public PandoraMainViewModel(INavigationServiceEx navigationService, IPandoraService pandoraService, IDialogService dialogService)
        {
            _navigationService = navigationService;
            _pandoraService    = pandoraService;
            _dialogService     = dialogService;

            SearchCommand = new RelayCommand <string>((searchText) => Search(searchText));

            Messenger.Default.Register <AwaitableOperationMessage>(this, (args) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() => { IsBusy = args.IsRunning; BusyMessage = args.Message; });
            });

            Messenger.Default.Register <FaultMessage>(this, (args) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    if (args.FaultDetails != null)
                    {
                        _dialogService.ShowError(args.FaultDetails, "Connection error", "OK", () => { _navigationService.NavigateTo(PageKeys.HOME); });
                    }
                    else
                    {
                        _dialogService.ShowError(args.DisplayedMessage, "Connection error", "OK", () => { _navigationService.NavigateTo(PageKeys.HOME); });
                    }
                });
            });

            Connect();
        }
コード例 #2
0
        public PandoraPlaybackViewModel(INavigationServiceEx navigationServise, IPandoraService pandoraService, IPlaybackService playbackService)
        {
            _navigationServise = navigationServise;
            _pandoraService    = pandoraService;
            _playbackService   = playbackService;

            TogglePlayPauseCommand = new RelayCommand(TogglePlayPause);
            SkipNextCommand        = new RelayCommand(SkipNext, CanSkipNext);
            ThumbUpCommand         = new RelayCommand(() => { });
            ThumbDownCommand       = new RelayCommand(() => { });
            IncreaseVolumeCommand  = new RelayCommand(IncreaseVolume, CanIncreaseVolume);
            DecreaseVolumeCommand  = new RelayCommand(DecreaseVolume, CanDecreaseVolume);
            ToggleMuteCommand      = new RelayCommand <bool>(ToggleMute);

            Messenger.Default.Register <MediaEndedMessage>(this, (message) => { SkipNext(); });
            Messenger.Default.Register <MediaPlaybackSession>(this, (session) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Position           = session.Position.ToString(@"hh\:mm\:ss");
                    Duration           = session.NaturalDuration.ToString(@"hh\:mm\:ss");
                    PercentagePosition = (session.Position.TotalSeconds / session.NaturalDuration.TotalSeconds) * 100;
                });
            });
        }
コード例 #3
0
        public PandoraStationDetailsViewModel(INavigationServiceEx navigationService, IPandoraService pandoraService)
        {
            _navigationService = navigationService;
            _pandoraService    = pandoraService;

            FilterThumbsUpCommand   = new RelayCommand(FilterThumbsUp, () => { return(_canFilterThumbsUp); });
            FilterThumbsDownCommand = new RelayCommand(FilterThumbsDown, () => { return(_canFilterThumbsDown); });

            PlayStationCommand = new RelayCommand <string>((token) => { _navigationService.NavigateTo(PageKeys.PANDORA_PLAYBACK, token); });
        }