Esempio n. 1
0
        public FolderPage(BaseItemDto parent, DisplayPreferences displayPreferences, IApiClient apiClient, IImageManager imageManager, IPresentationManager presentation, INavigationService navigationManager, IPlaybackManager playbackManager, ILogger logger, ListPageConfig options)
        {
            _logger = logger;
            _presentationManager = presentation;
            _imageManager = imageManager;
            _apiClient = apiClient;
            _options = options;

            _parentItem = parent;

            InitializeComponent();

            Loaded += FolderPage_Loaded;

            SetDefaults(displayPreferences);

            var playAllFromHere = parent.IsType("playlist") || parent.IsType("musicalbum");

            _viewModel = new ItemListViewModel(vm => options.CustomItemQuery(vm, displayPreferences), _presentationManager, _imageManager, _apiClient, navigationManager, playbackManager, _logger)
            {
                ImageDisplayHeightGenerator = GetImageDisplayHeight,
                DisplayNameGenerator = options.DisplayNameGenerator ?? GetDisplayName,
                PreferredImageTypesGenerator = GetPreferredImageTypes,

                ShowSidebarGenerator = GetShowSidebar,
                ScrollDirectionGenerator = GetScrollDirection,

                AutoSelectFirstItem = true,

                ShowLoadingAnimation = true,

                PlayAllFromHereOnPlayCommand = playAllFromHere,
                PlayAllFromHereOnNavigateCommand = playAllFromHere
            };

            if (options.ShowTitle)
            {
                _viewModel.OnItemCreated = v =>
                {
                    v.DisplayNameVisibility = Visibility.Visible;
                };
            }

            _viewModel.AddIndexOptions(options.IndexOptions);

            _viewModel.PropertyChanged += _viewModel_PropertyChanged;

            _viewModel.DisplayPreferences = displayPreferences;

            if (!string.IsNullOrEmpty(options.IndexValue))
            {
                var index = options.IndexOptions.First(i => string.Equals(i.Name, options.IndexValue));
                _viewModel.IndexOptionsCollectionView.MoveCurrentTo(index);
            }

            DataContext = _viewModel;
        }
        public FolderPage(BaseItemDto parent, DisplayPreferences displayPreferences, IApiClient apiClient, IImageManager imageManager, ISessionManager sessionManager, IPresentationManager presentation, INavigationService navigationManager, IPlaybackManager playbackManager, ILogger logger, IServerEvents serverEvents, ListPageConfig options)
        {
            _navigationManager = navigationManager;
            _playbackManager = playbackManager;
            _logger = logger;
            _serverEvents = serverEvents;
            _presentationManager = presentation;
            _sessionManager = sessionManager;
            _imageManager = imageManager;
            _apiClient = apiClient;
            _options = options;
            _displayPreferences = displayPreferences;

            _parentItem = parent;

            InitializeComponent();

            Loaded += FolderPage_Loaded;
            Unloaded += FolderPage_Unloaded;

            SetDefaults(displayPreferences);

            _viewModel = new ItemListViewModel(GetItemsAsync, _presentationManager, _imageManager, _apiClient, _navigationManager, _playbackManager, _logger, _serverEvents)
            {
                ImageDisplayHeightGenerator = GetImageDisplayHeight,
                DisplayNameGenerator = GetDisplayName,
                PreferredImageTypesGenerator = GetPreferredImageTypes,

                ShowSidebarGenerator = GetShowSidebar,
                ScrollDirectionGenerator = GetScrollDirection,

                AutoSelectFirstItem = true,

                ShowLoadingAnimation = true
            };

            _viewModel.AddIndexOptions(options.IndexOptions);

            _viewModel.PropertyChanged += _viewModel_PropertyChanged;

            _viewModel.DisplayPreferences = displayPreferences;

            DataContext = _viewModel;

            UpdateSortTitle();
            UpdateSortOrder();

            BtnSort.Visibility = _options.SortOptions.Count > 0
                                     ? Visibility.Visible
                                     : Visibility.Collapsed;

            BtnSort.Click += BtnSort_Click;
        }
        public FolderPage(BaseItemDto parent, DisplayPreferences displayPreferences, IApiClient apiClient, IImageManager imageManager, IPresentationManager presentation, INavigationService navigationManager, IPlaybackManager playbackManager, ILogger logger, IServerEvents serverEvents, ListPageConfig options)
        {
            _logger = logger;
            _presentationManager = presentation;
            _imageManager = imageManager;
            _apiClient = apiClient;
            _options = options;

            _parentItem = parent;

            InitializeComponent();

            Loaded += FolderPage_Loaded;

            SetDefaults(displayPreferences);

            _viewModel = new ItemListViewModel(vm => options.CustomItemQuery(vm, displayPreferences), _presentationManager, _imageManager, _apiClient, navigationManager, playbackManager, _logger, serverEvents)
            {
                ImageDisplayHeightGenerator = GetImageDisplayHeight,
                DisplayNameGenerator = options.DisplayNameGenerator ?? GetDisplayName,
                PreferredImageTypesGenerator = GetPreferredImageTypes,

                ShowSidebarGenerator = GetShowSidebar,
                ScrollDirectionGenerator = GetScrollDirection,

                AutoSelectFirstItem = true,

                ShowLoadingAnimation = true
            };

            _viewModel.AddIndexOptions(options.IndexOptions);

            _viewModel.PropertyChanged += _viewModel_PropertyChanged;

            _viewModel.DisplayPreferences = displayPreferences;

            if (!string.IsNullOrEmpty(options.IndexValue))
            {
                var index = options.IndexOptions.First(i => string.Equals(i.Name, options.IndexValue));
                _viewModel.IndexOptionsCollectionView.MoveCurrentTo(index);
            }

            DataContext = _viewModel;
        }
        private void LoadMatchedItemsViewModel()
        {
            MatchedItemsViewModel = new ItemListViewModel(s => Task.FromResult(_searchedItemsResult), _presentationManager, _imageManager, _apiClient, _navService, _playbackManager, _logger, _serverEvents)
            {
               ImageDisplayWidth = TileWidth,
               ImageDisplayHeightGenerator = vm => TileHeight,
               DisplayNameGenerator = GetDisplayName,
               PreferredImageTypesGenerator = vm => new[] { ImageType.Thumb, ImageType.Primary }, //   vm => _preferredImageTypes,
               ScrollDirection = ScrollDirection.Horizontal,
               EnableBackdropsForCurrentItem = false,
               ShowSidebar = false,
               AutoSelectFirstItem = false,
               ShowLoadingAnimation = true,
               IsVirtualizationRequired= false,
            };

            MatchedItemsViewModel.ItemContainerWidth = TileWidth + 5;
            MatchedItemsViewModel.ItemContainerHeight = TileHeight + 5;
            OnPropertyChanged("MatchedItemsViewModel");
        }
Esempio n. 5
0
        private Task<ItemsResult> GetSeriesByGenre(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var query = new ItemQuery
            {
                Fields = FolderPage.QueryFields,

                UserId = _sessionManager.LocalUserId,

                IncludeItemTypes = new[] { "Series" },

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                Recursive = true,
                ParentId = ParentId

            };

            var indexOption = viewModel.CurrentIndexOption;

            if (indexOption != null)
            {
                query.Genres = new[] { indexOption.Name };
            }

            return ApiClient.GetItemsAsync(query, CancellationToken.None);
        }
Esempio n. 6
0
        private void LoadNextUpViewModel(TvView view)
        {
            NextUpViewModel = new ItemListViewModel(GetNextUpAsync, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger)
            {
                ImageDisplayWidth = TileWidth,
                ImageDisplayHeightGenerator = v => TileHeight,
                DisplayNameGenerator = i => i.SeriesName,
                EnableBackdropsForCurrentItem = false,
                EnableServerImageEnhancers = false,

                OnItemCreated = vm =>
                {
                    vm.DisplayNameVisibility = Visibility.Visible;
                }
            };

            OnPropertyChanged("NextUpViewModel");
        }
        private void LoadLatestEpisodesViewModel(TvView view)
        {
            LatestEpisodesViewModel = new ItemListViewModel(GetLatestEpisodes, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger, _serverEvents)
            {
                ImageDisplayWidth = TileWidth,
                ImageDisplayHeightGenerator = v => TileHeight,
                DisplayNameGenerator = HomePageViewModel.GetDisplayName,
                EnableBackdropsForCurrentItem = false,
                EnableServerImageEnhancers = false,

                OnItemCreated = vm =>
                {
                    vm.DisplayNameVisibility = Visibility.Visible;
                }
            };

            OnPropertyChanged("LatestEpisodesViewModel");
        }
        private Task<ItemsResult> GetAlbumSongs(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var query = new ItemQuery
            {
                UserId = _sessionManager.LocalUserId,
                Fields = new[]
                        {
                                 ItemFields.PrimaryImageAspectRatio,
                                 ItemFields.DateCreated,
                                 ItemFields.Overview
                        },
                ParentId = item.Id,
                SortBy = new[] { ItemSortBy.SortName },

                Recursive = true,

                IncludeItemTypes = new[] { "Audio" }
            };

            return _apiClient.GetItemsAsync(query, CancellationToken.None);
        }
        private Task<ItemsResult> GetSeasons(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var query = new SeasonQuery
            {
                UserId = _sessionManager.LocalUserId,
                Fields = new[]
                        {
                                 ItemFields.PrimaryImageAspectRatio,
                                 ItemFields.DateCreated,
                                 ItemFields.Overview
                        },
                SeriesId = item.Id
            };

            return _apiClient.GetSeasonsAsync(query, CancellationToken.None);
        }
Esempio n. 10
0
        private Task<ItemsResult> GetSoundtracks(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var query = new ItemQuery
            {
                UserId = _sessionManager.LocalUserId,
                Fields = new[]
                        {
                                 ItemFields.PrimaryImageAspectRatio,
                                 ItemFields.DateCreated
                        },
                Ids = item.SoundtrackIds,
                SortBy = new[] { ItemSortBy.SortName }
            };

            return _apiClient.GetItemsAsync(query, CancellationToken.None);
        }
        private Task<ItemsResult> GetMovies(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var query = new ItemQuery
            {
                Fields = FolderPage.QueryFields,

                UserId = _sessionManager.CurrentUser.Id,

                IncludeItemTypes = new[] { "Movie" },

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                Recursive = true
            };

            var indexOption = viewModel.CurrentIndexOption == null ? string.Empty : viewModel.CurrentIndexOption.Name;

            if (string.Equals(indexOption, "TopRated"))
            {
                query.MinCommunityRating = ApiClientExtensions.TopMovieCommunityRating;

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (string.Equals(indexOption, "Unwatched"))
            {
                query.Filters = new[] { ItemFilter.IsUnplayed };
            }
            else if (string.Equals(indexOption, "NewReleases"))
            {
                query.SortBy = new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate };
                query.SortOrder = SortOrder.Descending;
                query.Limit = 100;
            }
            else if (string.Equals(indexOption, "HDMovies"))
            {
                query.IsHD = true;

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (string.Equals(indexOption, "3DMovies"))
            {
                query.Is3D = true;

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (string.Equals(indexOption, "Trailers"))
            {
                query.IncludeItemTypes = new[] { "Trailer" };

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (string.Equals(indexOption, "BoxSets"))
            {
                query.IncludeItemTypes = new[] { "BoxSet" };

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (string.Equals(indexOption, "FavoriteMovies"))
            {
                query.Filters = new[] { ItemFilter.IsFavorite };

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (string.Equals(indexOption, "TopCriticRated"))
            {
                query.MinCriticRating = 95;

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (string.Equals(indexOption, "Family"))
            {
                query.Genres = new[] { "Family" };

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (indexOption.StartsWith("Genre:"))
            {
                query.Genres = new[] { indexOption.Split(':').Last() };

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }
            else if (indexOption.StartsWith("Studio:"))
            {
                query.Studios = new[] { indexOption.Split(':').Last() };

                query.SortBy = new[] { ItemSortBy.SortName };
                query.SortOrder = SortOrder.Ascending;
            }

            return ApiClient.GetItemsAsync(query);
        }
        private Task<ItemsResult> GetLatestMoviesAsync(ItemListViewModel viewModel)
        {
            var result = new ItemsResult
            {
                Items = _moviesView.LatestMovies.ToArray(),
                TotalRecordCount = _moviesView.LatestMovies.Count
            };

            return Task.FromResult(result);
        }
        private void LoadLatestTrailersViewModel(MoviesView view)
        {
            LatestTrailersViewModel = new ItemListViewModel(GetLatestTrailersAsync, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger, _serverEvents)
            {
                ImageDisplayWidth = _posterTileWidth,
                ImageDisplayHeightGenerator = v => _posterTileHeight,
                DisplayNameGenerator = HomePageViewModel.GetDisplayName,
                PreferredImageTypesGenerator = vm => new[] { ImageType.Primary },
                EnableBackdropsForCurrentItem = false
            };

            OnPropertyChanged("LatestTrailersViewModel");

            LatestTrailersVisibility = view.TrailerItems.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
        }
        private Task<ItemsResult> GetChildren(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var query = new ItemQuery
            {
                UserId = _sessionManager.CurrentUser.Id,
                Fields = new[]
                        {
                                 ItemFields.PrimaryImageAspectRatio,
                                 ItemFields.DateCreated,
                                 ItemFields.Overview
                        },
                ParentId = item.Id,
                SortBy = new[] { ItemSortBy.SortName }
            };

            return _apiClient.GetItemsAsync(query, CancellationToken.None);
        }
        private Task<ItemsResult> GetSeasons(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var query = new SeasonQuery
            {
                UserId = _sessionManager.CurrentUser.Id,
                Fields = new[]
                        {
                                 ItemFields.PrimaryImageAspectRatio,
                                 ItemFields.DateCreated,
                                 ItemFields.Overview
                        },
                SeriesId = item.Id,
                IsSpecialSeason = false
            };

            return _apiClient.GetSeasonsAsync(query);
        }
Esempio n. 16
0
        private async Task<ItemsResult> GetConvertedThemeMediaResult(ItemListViewModel viewModel)
        {
            var allThemeMedia = await GetThemeMedia(ItemViewModel.Item);

            return new ItemsResult
            {
                TotalRecordCount = allThemeMedia.ThemeSongsResult.TotalRecordCount + allThemeMedia.ThemeVideosResult.TotalRecordCount,
                Items = allThemeMedia.ThemeVideosResult.Items.Concat(allThemeMedia.ThemeSongsResult.Items).ToArray()
            };
        }
Esempio n. 17
0
        private Task<ItemsResult> GetSimilarItemsAsync(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var query = new SimilarItemsQuery
            {
                UserId = _sessionManager.LocalUserId,
                Limit = item.IsGame || item.IsType("musicalbum") ? 6 : 12,
                Fields = new[]
                        {
                                 ItemFields.PrimaryImageAspectRatio,
                                 ItemFields.DateCreated,
                                 ItemFields.Overview,
                                 ItemFields.MediaStreams
                        },
                Id = item.Id
            };

            if (item.IsType("trailer"))
            {
                return _apiClient.GetSimilarTrailersAsync(query, CancellationToken.None);
            }
            if (item.IsGame)
            {
                return _apiClient.GetSimilarGamesAsync(query, CancellationToken.None);
            }
            if (item.IsType("musicalbum"))
            {
                return _apiClient.GetSimilarAlbumsAsync(query, CancellationToken.None);
            }
            if (item.IsType("series"))
            {
                return _apiClient.GetSimilarSeriesAsync(query, CancellationToken.None);
            }

            return _apiClient.GetSimilarMoviesAsync(query, CancellationToken.None);
        }
        private Task<ItemsResult> GetMoviesByYear(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var query = new ItemQuery
            {
                Fields = FolderPage.QueryFields,

                UserId = _sessionManager.CurrentUser.Id,

                IncludeItemTypes = new[] { "Movie" },

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                Recursive = true
            };

            var indexOption = viewModel.CurrentIndexOption;

            if (indexOption != null)
            {
                query.Years = new[] { int.Parse(indexOption.Name) };
            }

            return ApiClient.GetItemsAsync(query);
        }
Esempio n. 19
0
        private async Task<ItemsResult> GetTrailers(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var items = await _apiClient.GetLocalTrailersAsync(_sessionManager.LocalUserId, item.Id);

            return new ItemsResult
            {
                Items = items,
                TotalRecordCount = items.Length
            };
        }
        private Task<ItemsResult> GetAllActors(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var fields = FolderPage.QueryFields.ToList();
            fields.Remove(ItemFields.Overview);
            fields.Remove(ItemFields.DisplayPreferencesId);
            fields.Remove(ItemFields.DateCreated);

            var query = new PersonsQuery
            {
                Fields = fields.ToArray(),

                IncludeItemTypes = new[] { "Movie", "Trailer" },

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                UserId = _sessionManager.CurrentUser.Id,

                Recursive = true
            };

            var indexOption = viewModel.CurrentIndexOption;

            if (indexOption != null)
            {
                if (string.Equals(indexOption.Name, "#", StringComparison.OrdinalIgnoreCase))
                {
                    query.NameLessThan = "A";
                }
                else
                {
                    query.NameStartsWithOrGreater = indexOption.Name;
                    query.NameLessThan = indexOption.Name + "zz";
                }
            }

            return ApiClient.GetPeopleAsync(query);
        }
Esempio n. 21
0
 private Task<ItemsResult> GetSeriesEpisodes(ItemListViewModel viewModel)
 {
     return _apiClient.GetEpisodesAsync(new EpisodeQuery
     {
         UserId = _sessionManager.LocalUserId,
         Fields = new[]
                 {
                          ItemFields.PrimaryImageAspectRatio,
                          ItemFields.DateCreated,
                          ItemFields.Overview,
                          ItemFields.MediaStreams
                 },
         SeasonNumber = 1,
         SeriesId = ItemViewModel.Item.Id
     }, CancellationToken.None);
 }
        public MoviesViewModel(IPresentationManager presentation, IImageManager imageManager, IApiClient apiClient, ISessionManager session, INavigationService nav, IPlaybackManager playback, ILogger logger, double tileWidth, double tileHeight, IServerEvents serverEvents)
            : base(presentation, apiClient)
        {
            _sessionManager = session;
            _imageManager = imageManager;
            _navService = nav;
            _playbackManager = playback;
            _logger = logger;
            _serverEvents = serverEvents;

            TileWidth = tileWidth;
            TileHeight = tileHeight;

            var trailerTileHeight = (TileHeight * 1.46) + TilePadding / 2;
            var trailerTileWidth = trailerTileHeight * 2 / 3;

            LatestTrailersViewModel = new ItemListViewModel(GetLatestTrailersAsync, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth = trailerTileWidth,
                ImageDisplayHeightGenerator = v => trailerTileHeight,
                DisplayNameGenerator = HomePageViewModel.GetDisplayName,
                PreferredImageTypesGenerator = vm => new[] { ImageType.Primary },
                EnableBackdropsForCurrentItem = false
            };
            LatestTrailersViewModel.PropertyChanged += TrailersViewModel_PropertyChanged;

            const double tileScaleFactor = 13;

            LatestMoviesViewModel = new ItemListViewModel(GetLatestMoviesAsync, presentation, imageManager, apiClient, nav, playback, logger, _serverEvents)
            {
                ImageDisplayWidth = trailerTileWidth,
                ImageDisplayHeightGenerator = v => trailerTileHeight,
                DisplayNameGenerator = HomePageViewModel.GetDisplayName,
                PreferredImageTypesGenerator = vm => new[] { ImageType.Primary, ImageType.Backdrop, ImageType.Thumb, },
                EnableBackdropsForCurrentItem = false,
                ListType = "LatestMovies"
            };
            LatestMoviesViewModel.PropertyChanged += LatestMoviesViewModel_PropertyChanged;

            ActorsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToActorsInternal)
            };

            GenresViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToGenresInternal)
            };

            YearsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToYearsInternal)
            };

            AllMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToAllMoviesInternal)
            };

            BoxsetsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToBoxsetsInternal)
            };

            TrailersViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToTrailersInternal)
            };

            HDMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToHDMoviesInternal)
            };

            FamilyMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToFamilyMoviesInternal)
            };

            ThreeDMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateTo3DMoviesInternal)
            };

            RomanticMoviesViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToRomanticMoviesInternal)
            };

            ComedyItemsViewModel = new GalleryViewModel(ApiClient, _imageManager, _navService)
            {
                GalleryHeight = TileHeight,
                GalleryWidth = TileWidth * tileScaleFactor / 16,
                CustomCommandAction = () => NavigateWithLoading(NavigateToComedyMoviesInternal)
            };

            var spotlightTileWidth = TileWidth * 2 + TilePadding;
            var spotlightTileHeight = spotlightTileWidth * 9 / 16;

            SpotlightViewModel = new ImageViewerViewModel(_imageManager, new List<ImageViewerImage>())
            {
                Height = spotlightTileHeight,
                Width = spotlightTileWidth,
                CustomCommandAction = i => _navService.NavigateToItem(i.Item, ViewType.Movies),
                ImageStretch = Stretch.UniformToFill
            };

            LoadViewModels();
        }
Esempio n. 23
0
        private async Task<ItemsResult> GetSpecialFeatures(ItemListViewModel viewModel)
        {
            var item = ItemViewModel.Item;

            var items = await _apiClient.GetSpecialFeaturesAsync(_sessionManager.LocalUserId, item.Id);

            return new ItemsResult
            {
                TotalRecordCount = items.Length,
                Items = items
            };
        }
        private Task<ItemsResult> GetLatestMoviesAsync(ItemListViewModel viewModel)
        {
            var query = new ItemQuery
            {
                Fields = new[]
                        {
                            ItemFields.PrimaryImageAspectRatio,
                            ItemFields.DateCreated,
                            ItemFields.DisplayPreferencesId
                        },

                UserId = _sessionManager.CurrentUser.Id,

                SortBy = new[] { ItemSortBy.DateCreated },

                SortOrder = SortOrder.Descending,

                IncludeItemTypes = new[] { "Movie" },

                Filters = new[] { ItemFilter.IsUnplayed },

                Limit = 8,

                Recursive = true
            };

            return ApiClient.GetItemsAsync(query);
        }
        private Task<ItemsResult> GetAllShows(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var query = new ItemQuery
            {
                Fields = FolderPage.QueryFields,

                UserId = _sessionManager.CurrentUser.Id,

                IncludeItemTypes = new[] { "Series" },

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                Recursive = true
            };

            return ApiClient.GetItemsAsync(query, CancellationToken.None);
        }
        private Task<ItemsResult> GetComedyMovies(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var query = new ItemQuery
            {
                Fields = FolderPage.QueryFields,

                UserId = _sessionManager.CurrentUser.Id,

                IncludeItemTypes = new[] { "Movie" },

                Genres = new[] { ApiClientExtensions.ComedyGenre },

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                Recursive = true
            };

            return ApiClient.GetItemsAsync(query);
        }
Esempio n. 27
0
        private void LoadMiniSpotlightsViewModel(TvView view)
        {
            Func<ItemListViewModel, Task<ItemsResult>> getItems = vm =>
            {
                var items = view.MiniSpotlights.Take(3).ToArray();

                return Task.FromResult(new ItemsResult
                {
                    TotalRecordCount = items.Length,
                    Items = items
                });
            };

            MiniSpotlightsViewModel = new ItemListViewModel(getItems, PresentationManager, _imageManager, ApiClient, _navService, _playbackManager, _logger)
            {
                ImageDisplayWidth = TileWidth + (TileMargin / 4) - 1,
                ImageDisplayHeightGenerator = v => TileHeight,
                DisplayNameGenerator = HomePageViewModel.GetDisplayName,
                EnableBackdropsForCurrentItem = false,
                ImageStretch = Stretch.UniformToFill,
                PreferredImageTypesGenerator = vm => new[] { ImageType.Backdrop },
                DownloadImageAtExactSize = true,

                OnItemCreated = vm =>
                {
                    vm.DisplayNameVisibility = Visibility.Visible;
                }
            };

            OnPropertyChanged("MiniSpotlightsViewModel");
        }
Esempio n. 28
0
        private ItemListViewModel GetItemByNameItemListViewModel(string type, int width, double height, ViewType context)
        {
            Func<ItemListViewModel, Task<ItemsResult>> itemGenerator = (vm) => GetItemByNameItemsAsync(type);

            var viewModel = new ItemListViewModel(itemGenerator, _presentationManager, _imageManager, _apiClient, _navigation, _playback, _logger)
            {
                ViewType = ListViewTypes.Poster,
                ImageDisplayWidth = width,
                ImageDisplayHeightGenerator = GetImageDisplayHeight,

                ItemContainerWidth = width + 20,
                ItemContainerHeight = height + 20,

                ItemContainerHeightGenerator = vm => GetImageDisplayHeight(vm) + 20,

                DisplayNameGenerator = HomePageViewModel.GetDisplayName,
                PreferredImageTypesGenerator = vm => new[] { ImageType.Primary },

                ShowSidebarGenerator = vm => false,
                ScrollDirectionGenerator = vm => ScrollDirection.Horizontal,

                AutoSelectFirstItem = false,

                ShowLoadingAnimation = true,
                EnableBackdropsForCurrentItem = false,

                Context = context
            };

            return viewModel;
        }
Esempio n. 29
0
        private Task<ItemsResult> GetResumeablesAsync(ItemListViewModel viewModel)
        {
            var result = new ItemsResult
            {
                Items = _tvView.ResumableEpisodes.ToArray(),
                TotalRecordCount = _tvView.ResumableEpisodes.Count
            };

            ResumeVisibility = result.TotalRecordCount > 0 ? Visibility.Visible : Visibility.Collapsed;

            return Task.FromResult(result);
        }
Esempio n. 30
0
        private double GetImageDisplayHeight(ItemListViewModel viewModel)
        {
            var imageDisplayWidth = viewModel.ImageDisplayWidth;
            var medianPrimaryImageAspectRatio = viewModel.MedianPrimaryImageAspectRatio ?? 0;

            if (!medianPrimaryImageAspectRatio.Equals(0))
            {
                double height = imageDisplayWidth;
                height /= medianPrimaryImageAspectRatio;

                return height;
            }

            return viewModel.DefaultImageDisplayHeight;
        }