コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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");
        }
コード例 #6
0
        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");
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 private void LoadYearsViewModel(GamesView view)
 {
 }
コード例 #9
0
 private void LoadGenresViewModel(GamesView view)
 {
 }
コード例 #10
0
        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);
        }
コード例 #11
0
        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");
        }
コード例 #12
0
        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");
        }
コード例 #13
0
        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");
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
 private void LoadYearsViewModel(GamesView view)
 {
 }
コード例 #16
0
 private void LoadGenresViewModel(GamesView view)
 {
 }