private void LoadSpotlightViewModel(GamesView view) { const ImageType imageType = ImageType.Backdrop; var tileWidth = TileWidth * 2 + TileMargin; var tileHeight = tileWidth * 9 / 16; BackdropItems = view.BackdropItems.ToArray(); var images = view.SpotlightItems.Select(i => new ImageViewerImage { Url = ApiClient.GetImageUrl(i, new ImageOptions { Height = Convert.ToInt32(tileHeight), Width = Convert.ToInt32(tileWidth), ImageType = imageType }), Caption = i.Name, Item = i }).ToList(); SpotlightViewModel.Images.AddRange(images); SpotlightViewModel.StartRotating(10000); }
private async void LoadViewModels() { PresentationManager.ShowLoadingAnimation(); var cancellationSource = _mainViewCancellationTokenSource = new CancellationTokenSource(); try { var view = await ApiClient.GetGamesView(_sessionManager.CurrentUser.Id, ParentId, cancellationSource.Token); _gamesView = view; LoadSpotlightViewModel(view); LoadGameSystemsViewModel(view); LoadMultiPlayerViewModel(view); LoadRecentlyPlayedViewModel(view); } catch (Exception ex) { _logger.ErrorException("Error getting games view", ex); PresentationManager.ShowDefaultErrorMessage(); } finally { PresentationManager.HideLoadingAnimation(); DisposeMainViewCancellationTokenSource(false); } }
private void LoadMiniSpotlightsViewModel2(GamesView view) { Func <ItemListViewModel, Task <ItemsResult> > getItems = vm => { var items = view.MiniSpotlights.Skip(2).Take(3).ToArray(); return(Task.FromResult(new ItemsResult { TotalRecordCount = items.Length, Items = items })); }; MiniSpotlightsViewModel2 = new ItemListViewModel(getItems, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger, _serverEvents) { ImageDisplayWidth = TileWidth, ImageDisplayHeightGenerator = v => TileHeight, DisplayNameGenerator = HomePageViewModel.GetDisplayName, EnableBackdropsForCurrentItem = false, ImageStretch = Stretch.UniformToFill, PreferredImageTypesGenerator = vm => new[] { ImageType.Backdrop }, DownloadImageAtExactSize = true }; OnPropertyChanged("MiniSpotlightsViewModel2"); }
private void LoadMultiPlayerViewModel(GamesView view) { MultiPlayerVisibility = view.MultiPlayerItems.Count > 0 ? Visibility.Visible : Visibility.Collapsed; var images = view.MultiPlayerItems.Take(1).Select(i => ApiClient.GetImageUrl(i.Id, new ImageOptions { ImageType = i.ImageType, Tag = i.ImageTag, Width = Convert.ToInt32(TileWidth * 2), EnableImageEnhancers = false })); MultiPlayerViewModel.AddImages(images); }
private void LoadGameSystemsViewModel(GamesView view) { GameSystemsViewModel = new ItemListViewModel(GetGameSystems, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger, _serverEvents) { ImageDisplayWidth = TileWidth, ImageDisplayHeightGenerator = v => TileHeight, DisplayNameGenerator = HomePageViewModel.GetDisplayName, EnableBackdropsForCurrentItem = false, Context = ViewType.Games, EnableServerImageEnhancers = false, OnItemCreated = vm => { vm.DisplayNameVisibility = Visibility.Visible; } }; OnPropertyChanged("GameSystemsViewModel"); }
private void LoadRecentlyPlayedViewModel(GamesView view) { RecentlyPlayedViewModel = new ItemListViewModel(GetRecentlyPlayedAsync, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger, _serverEvents) { ImageDisplayWidth = TileWidth * 13 / 16, ImageDisplayHeightGenerator = v => TileHeight, DisplayNameGenerator = HomePageViewModel.GetDisplayName, EnableBackdropsForCurrentItem = false, ImageStretch = Stretch.UniformToFill, Context = ViewType.Games, EnableServerImageEnhancers = false, OnItemCreated = vm => { vm.DisplayNameVisibility = Visibility.Visible; } }; OnPropertyChanged("RecentlyPlayedViewModel"); }
private void LoadMultiPlayerViewModel(GamesView view) { ShowMultiPlayer = view.MultiPlayerItems.Count > 0; var images = view.MultiPlayerItems.Take(1).Select(i => ApiClient.GetImageUrl(i.Id, new ImageOptions { ImageType = i.ImageType, Tag = i.ImageTag, Width = Convert.ToInt32(TileWidth * 2), EnableImageEnhancers = false })); MultiPlayerViewModel.AddImages(images); }
private void LoadYearsViewModel(GamesView view) { }
private void LoadGenresViewModel(GamesView view) { }
private void LoadSpotlightViewModel(GamesView view) { const ImageType imageType = ImageType.Backdrop; var tileWidth = TileWidth * 2 + TilePadding; var tileHeight = tileWidth * 9 / 16; BackdropItems = view.BackdropItems.ToArray(); var images = view.SpotlightItems.Select(i => new ImageViewerImage { Url = ApiClient.GetImageUrl(i, new ImageOptions { Height = Convert.ToInt32(tileHeight), Width = Convert.ToInt32(tileWidth), ImageType = imageType }), Caption = i.Name, Item = i }).ToList(); SpotlightViewModel.Images.AddRange(images); SpotlightViewModel.StartRotating(10000); }
private void LoadMiniSpotlightsViewModel2(GamesView view) { Func<ItemListViewModel, Task<ItemsResult>> getItems = vm => { var items = view.MiniSpotlights.Skip(2).Take(3).ToArray(); return Task.FromResult(new ItemsResult { TotalRecordCount = items.Length, Items = items }); }; MiniSpotlightsViewModel2 = new ItemListViewModel(getItems, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger, _serverEvents) { ImageDisplayWidth = TileWidth, ImageDisplayHeightGenerator = v => TileHeight, DisplayNameGenerator = HomePageViewModel.GetDisplayName, EnableBackdropsForCurrentItem = false, ImageStretch = Stretch.UniformToFill, PreferredImageTypesGenerator = vm => new[] { ImageType.Backdrop }, DownloadImageAtExactSize = true }; OnPropertyChanged("MiniSpotlightsViewModel2"); }