internal CurrentPlaylistPageViewPresenter(
            IApplicationResources resources,
            IPlayQueueService playQueueService,
            ISongsService metadataEditService,
            ISongsCachingService cachingService,
            IApplicationStateService stateService,
            INavigationService navigationService,
            IRadioStationsService radioStationsService,
            ISettingsService settingsService,
            SongsBindingModel songsBindingModel)
        {
            this.resources            = resources;
            this.playQueueService     = playQueueService;
            this.metadataEditService  = metadataEditService;
            this.cachingService       = cachingService;
            this.stateService         = stateService;
            this.navigationService    = navigationService;
            this.radioStationsService = radioStationsService;
            this.settingsService      = settingsService;
            this.BindingModel         = songsBindingModel;

            this.playQueueService.QueueChanged += async(sender, args) => await this.Dispatcher.RunAsync(this.UpdateSongs);

            //this.SaveAsPlaylistCommand = new DelegateCommand(this.SaveAsPlaylist, () => this.BindingModel.Songs.Count > 0);
            this.RemoveSelectedSongCommand = new DelegateCommand(this.RemoveSelectedSong, () => this.BindingModel.SelectedItems.Count > 0);
            this.AddToPlaylistCommand      = new DelegateCommand(this.AddToPlaylist, () => this.BindingModel.SelectedItems.Count > 0);
            this.RateSongCommand           = new DelegateCommand(this.RateSong);
            this.DownloadCommand           = new DelegateCommand(this.Download, () => this.BindingModel.SelectedItems.Count(x => !x.Metadata.UnknownSong) > 0);
            this.UnPinCommand      = new DelegateCommand(this.UnPin, () => this.BindingModel.SelectedItems.Count(x => !x.Metadata.UnknownSong) > 0);
            this.StartRadioCommand = new DelegateCommand(this.StartRadio, () => this.BindingModel != null && this.BindingModel.SelectedItems.Count == 1);

            this.playQueueService.StateChanged += async(sender, args) => await this.Dispatcher.RunAsync(async() =>
            {
                if (this.BindingModel.SelectedItems.Count == 0)
                {
                    if (this.BindingModel.Songs != null && args.CurrentSong != null)
                    {
                        var currentSong = this.BindingModel.Songs.FirstOrDefault(x => string.Equals(x.Metadata.SongId, args.CurrentSong.SongId, StringComparison.Ordinal));
                        if (currentSong != null)
                        {
                            await this.View.ScrollIntoCurrentSongAsync(currentSong);
                        }
                    }
                }
            });
        }
示例#2
0
 public async Task ScrollIntoCurrentSongAsync(SongBindingModel songBindingModel)
 {
     await Task.Run(
         async() =>
     {
         if (this.presenter != null && songBindingModel != null)
         {
             SongsBindingModel songsBindingModel = this.presenter.BindingModel;
             if (songsBindingModel != null &&
                 songsBindingModel.Songs != null)
             {
                 await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, this.UpdateLayout);
                 await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => this.ListView.ScrollIntoView(songBindingModel));
             }
         }
     });
 }