public UserProfileWindow(DefaultThemePageMasterCommandsViewModel masterCommands, ISessionManager session, IPresentationManager presentationManager, IImageManager imageManager, IApiClient apiClient, DisplayPreferences displayPreferences, ListPageConfig options)
        {
            _session = session;
            _options = options;
            _displayPreferencesViewModel = new DisplayPreferencesViewModel(displayPreferences, presentationManager);
            _previousFocus = "";

            InitializeComponent();

            Loaded += UserProfileWindow_Loaded;
            Unloaded += UserProfileWindow_Unloaded;
            masterCommands.PageNavigated += masterCommands_PageNavigated;
            BtnClose.Click += BtnClose_Click;

            //Display preferences
            RadioList.Click += radioList_Click;
            RadioPoster.Click += radioPoster_Click;
            RadioThumbstrip.Click += radioThumbstrip_Click;
            RadioPosterStrip.Click += radioPosterStrip_Click;

            //Sort preferences
            RadioSortAscending.Click += RadioSortAscending_Click;
            RadioSortDescending.Click += RadioSortDescending_Click;

            //Focus tracking
            BtnClose.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            HomeButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            DisplayPreferencesButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            SortButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            SettingsButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            LogoutButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            ShutdownAppButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            SleepButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            RestartButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            ShutdownButton.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;

            RadioList.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            RadioPosterStrip.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            RadioPoster.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            RadioThumbstrip.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;

            RadioSortAscending.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            RadioSortDescending.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;
            CheckBoxSortRemember.IsKeyboardFocusedChanged += Button_IsKeyboardFocusedChanged;

            ContentGrid.DataContext = new DefaultThemeUserDtoViewModel(masterCommands, apiClient, imageManager, session)
            {
                User = session.CurrentUser,
                ImageHeight = 54
            };

            MainGrid.DataContext = this;
            CheckBoxSortRemember.DataContext = _displayPreferencesViewModel;

            if (displayPreferences != null)
            {
                //Always set to false to begin with in case the user is just doing a quick sort and doesn't want it saved.
                _displayPreferencesViewModel.RememberSorting = false;
            }
        }
        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, 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;
        }
Beispiel #5
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
            };

            _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 ViewWindow(DisplayPreferencesViewModel displayPreferencesViewModel, ListPageConfig options)
        {
            _displayPreferencesViewModel = displayPreferencesViewModel;
            _options = options;
            InitializeComponent();

            DataContext = this;

            btnClose.Click += btnClose_Click;
            radioList.Click += radioList_Click;
            radioPoster.Click += radioPoster_Click;
            radioThumbstrip.Click += radioThumbstrip_Click;
            radioPosterStrip.Click += radioPosterStrip_Click;
            Loaded += SortMenuPage_Loaded;
        }
        public ViewWindow(DisplayPreferencesViewModel displayPreferencesViewModel, ListPageConfig options)
        {
            _displayPreferencesViewModel = displayPreferencesViewModel;
            _options = options;
            InitializeComponent();

            DataContext = this;

            btnClose.Click         += btnClose_Click;
            radioList.Click        += radioList_Click;
            radioPoster.Click      += radioPoster_Click;
            radioThumbstrip.Click  += radioThumbstrip_Click;
            radioPosterStrip.Click += radioPosterStrip_Click;
            Loaded += SortMenuPage_Loaded;
        }
        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;
        }
Beispiel #9
0
        private ListPageConfig GetListPageConfig(BaseItemDto item, ViewType context)
        {
            var apiClient = _connectionManager.GetApiClient(item);

            var config = new ListPageConfig();

            if (item.IsType("playlist"))
            {
                config.DefaultViewType = ListViewTypes.List;
            }
            if (context == ViewType.Tv || item.IsType("season"))
            {
                TvViewModel.SetDefaults(config);

                if (item.IsType("season"))
                {
                    config.DefaultViewType = ListViewTypes.List;

                    config.PosterImageWidth = 480;
                    config.PosterStripImageWidth = 592;
                    config.ThumbImageWidth = 592;
                }
            }
            else if (context == ViewType.Movies)
            {
                MoviesViewModel.SetDefaults(config);
            }
            else if (context == ViewType.Games)
            {
                GamesViewModel.SetDefaults(config, item.GameSystem);
            }

            if (item.IsFolder)
            {
                config.CustomItemQuery = (vm, displayPreferences) =>
                {

                    if (item.IsType("series"))
                    {
                        return apiClient.GetSeasonsAsync(new SeasonQuery
                        {
                            UserId = _sessionManager.LocalUserId,
                            SeriesId = item.Id,
                            Fields = FolderPage.QueryFields
                        }, CancellationToken.None);
                    }


                    if (item.IsType("season"))
                    {
                        return apiClient.GetEpisodesAsync(new EpisodeQuery
                        {
                            UserId = _sessionManager.LocalUserId,
                            SeriesId = item.SeriesId,
                            SeasonId = item.Id,
                            Fields = FolderPage.QueryFields
                        }, CancellationToken.None);
                    }

                    var query = new ItemQuery
                    {
                        UserId = _sessionManager.LocalUserId,

                        ParentId = item.Id,

                        Fields = FolderPage.QueryFields
                    };

                    // Server will sort boxset titles based on server settings
                    if (!item.IsType("boxset"))
                    {
                        query.SortBy = new[] { ItemSortBy.SortName };
                        query.SortOrder = displayPreferences.SortOrder;
                    }

                    return apiClient.GetItemsAsync(query, CancellationToken.None);
                };

                if (item.IsType("season") && item.IndexNumber.HasValue && item.IndexNumber.Value > 0)
                {
                    config.DisplayNameGenerator = FolderPage.GetDisplayNameWithAiredSpecial;
                }
            }

            return config;
        }
Beispiel #10
0
        private ListPageConfig GetChannelPageConfig(BaseItemDto item, ViewType context)
        {
            var apiClient = _connectionManager.GetApiClient(item);

            var config = new ListPageConfig();

            config.CustomItemQuery = (vm, displayPreferences) =>
            {
                return GetChannelItems(apiClient, new ChannelItemQuery
                {
                    UserId = _sessionManager.LocalUserId,
                    ChannelId = item.IsType("channel") ? item.Id : item.ChannelId,
                    FolderId = item.IsType("channel") ? null : item.Id,
                    Fields = FolderPage.QueryFields

                }, CancellationToken.None);
            };

            return config;
        }
        private async Task NavigateToComedyMoviesInternal()
        {
            var item = await ApiClient.GetRootFolderAsync(_sessionManager.CurrentUser.Id);

            var displayPreferences = await PresentationManager.GetDisplayPreferences("ComedyMovies", CancellationToken.None);

            var options = new ListPageConfig
            {
                PageTitle = "Comedy Night",
                CustomItemQuery = GetComedyMovies,
                SortOptions = GetMovieSortOptions()
            };

            SetDefaults(options);

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, _sessionManager,
                                      PresentationManager, _navService, _playbackManager, _logger, _serverEvents, options)
            {
                ViewType = ViewType.Movies
            };

            await _navService.Navigate(page);
        }
        private async Task NavigateToYearsInternal()
        {
            var item = await ApiClient.GetRootFolderAsync(_sessionManager.CurrentUser.Id);

            var displayPreferences = await PresentationManager.GetDisplayPreferences("MovieYears", CancellationToken.None);

            var yearIndex = await ApiClient.GetYearIndex(_sessionManager.CurrentUser.Id, new[] { "Movie" }, CancellationToken.None);

            var indexOptions = yearIndex.Where(i => !string.IsNullOrEmpty(i.Name)).Select(i => new TabItem
            {
                Name = i.Name,
                DisplayName = i.Name + " (" + i.ItemCount + ")"
            });

            var options = new ListPageConfig
            {
                IndexOptions = indexOptions.ToList(),
                PageTitle = "Movies | Timeline",
                CustomItemQuery = GetMoviesByYear
            };

            SetDefaults(options);

            options.DefaultViewType = ListViewTypes.PosterStrip;

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, _sessionManager,
                                      PresentationManager, _navService, _playbackManager, _logger, _serverEvents, options)
            {
                ViewType = ViewType.Movies
            };

            await _navService.Navigate(page);
        }
        private async Task NavigateToActorsInternal()
        {
            var item = await ApiClient.GetRootFolderAsync(_sessionManager.CurrentUser.Id);

            var displayPreferences = await PresentationManager.GetDisplayPreferences("People", CancellationToken.None);

            var options = new ListPageConfig
            {
                IndexOptions = AlphabetIndex,
                PageTitle = "Movies | People",
                CustomItemQuery = GetAllActors
            };

            SetDefaults(options);

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, _sessionManager,
                                      PresentationManager, _navService, _playbackManager, _logger, _serverEvents, options)
            {
                ViewType = ViewType.Movies
            };

            await _navService.Navigate(page);
        }
        private async Task NavigateToMoviesInternal(string indexValue)
        {
            var item = await GetRootFolder();

            var displayPreferences = await PresentationManager.GetDisplayPreferences("Movies", CancellationToken.None);

            var view = _moviesView ?? await ApiClient.GetMovieView(_sessionManager.CurrentUser.Id, CancellationToken.None);

            var tabs = new List<TabItem>();

            tabs.Add(new TabItem
            {
                DisplayName = "All Movies",
                Name = "AllMovies"
            });

            tabs.Add(new TabItem
            {
                DisplayName = "Unwatched",
                Name = "Unwatched",
            });

            tabs.Add(new TabItem
            {
                DisplayName = "New Releases",
                Name = "NewReleases",
            });

            tabs.Add(new TabItem
            {
                DisplayName = "Trailers",
                Name = "Trailers",
            });

            tabs.Add(new TabItem
            {
                DisplayName = "Favorites",
                Name = "FavoriteMovies"
            });

            if (view.BoxSetItems.Count > 0)
            {
                tabs.Add(new TabItem
                {
                    DisplayName = "Box Sets",
                    Name = "BoxSets",
                });
            }

            if (view.FamilyMovies.Count > 0)
            {
                tabs.Add(new TabItem
                {
                    DisplayName = "Family",
                    Name = "Family",
                });
            }

            tabs.Add(new TabItem
            {
                DisplayName = "Popular",
                Name = "TopRated",
            });

            tabs.Add(new TabItem
            {
                DisplayName = "Critically Acclaimed",
                Name = "TopCriticRated",
            });

            if (view.ThreeDItems.Count > 0)
            {
                tabs.Add(new TabItem
                {
                    DisplayName = "3D Movies",
                    Name = "3DMovies",
                });
            }

            var options = new ListPageConfig
            {
                PageTitle = " ",
                CustomItemQuery = GetMovies,
                IndexOptions = tabs,
                IndexValue = indexValue,
                SortOptions = GetMovieSortOptions()
            };

            SetDefaults(options);

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, PresentationManager, _navService, _playbackManager, _logger, _serverEvents, options)
            {
                ViewType = ViewType.Movies
            };

            await _navService.Navigate(page);
        }
        private async void NavigateToFavorites(string type)
        {
            try
            {
                var itemCounts = await ApiClient.GetItemCountsAsync(new ItemCountsQuery
                {
                    UserId = _sessionManager.CurrentUser.Id,
                    IsFavorite = true
                });

                var item = await ApiClient.GetRootFolderAsync(_sessionManager.CurrentUser.Id);

                var displayPreferences = await PresentationManager.GetDisplayPreferences("Favorites", CancellationToken.None);

                displayPreferences.PrimaryImageWidth = GetImageWidth(type);

                var options = new ListPageConfig
                {
                    IndexOptions = GetFavoriteTabs(itemCounts).ToList(),
                    PageTitle = "Favorites",
                    CustomItemQuery = GetFavoriteItems
                };

                var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, _sessionManager,
                                          PresentationManager, _navService, _playbackManager, _logger, _serverEvents, options)
                {
                    ViewType = ViewType.Folders
                };

                await _navService.Navigate(page);
            }
            catch (Exception ex)
            {
                _logger.Error("Error navigating to favorites", ex);

                PresentationManager.ShowDefaultErrorMessage();
            }
        }
        private async Task NavigateToGenresInternal()
        {
            var item = await ApiClient.GetRootFolderAsync(_sessionManager.CurrentUser.Id);

            var displayPreferences = await PresentationManager.GetDisplayPreferences("GameGenres", CancellationToken.None);

            var genres = await ApiClient.GetGameGenresAsync(new ItemsByNameQuery
            {
                IncludeItemTypes = new[] { "Game" },
                SortBy = new[] { ItemSortBy.SortName },
                Recursive = true,
                UserId = _sessionManager.CurrentUser.Id
            });

            var indexOptions = genres.Items.Select(i => new TabItem
            {
                Name = i.Name,
                DisplayName = i.Name + " (" + i.GameCount + ")"
            });

            var options = new ListPageConfig
            {
                IndexOptions = indexOptions.ToList(),
                PageTitle = "Games | Genres",
                CustomItemQuery = GetGamesByGenre
            };

            SetDefaults(options, null);

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, _sessionManager,
                                      PresentationManager, _navService, _playbackManager, _logger, _serverEvents, options)
            {
                ViewType = ViewType.Games
            };

            await _navService.Navigate(page);
        }
        private async Task NavigateToAllShowsInternal()
        {
            var item = await _apiClient.GetRootFolderAsync(_sessionManager.CurrentUser.Id);

            var displayPreferences = await _presentationManager.GetDisplayPreferences("Shows", CancellationToken.None);

            var options = new ListPageConfig
            {
                PageTitle = "TV Shows",
                CustomItemQuery = GetAllShows,
                SortOptions = TvViewModel.GetSeriesSortOptions()
            };

            TvViewModel.SetDefaults(options);

            var page = new FolderPage(item, displayPreferences, _apiClient, _imageManager, _sessionManager,
                                      _presentationManager, _nav, _playbackManager, _logger, _serverEvents, options)
            {
                ViewType = ViewType.Tv
            };

            await _nav.Navigate(page);
        }
Beispiel #18
0
        private async Task NavigateToGenresInternal()
        {
            var item = await GetRootFolder();

            var displayPreferences = await PresentationManager.GetDisplayPreferences(ApiClient, "TVGenres", CancellationToken.None);

            var genres = await ApiClient.GetGenresAsync(new ItemsByNameQuery
            {
                IncludeItemTypes = new[] { "Series" },
                SortBy = new[] { ItemSortBy.SortName },
                Recursive = true,
                UserId = _sessionManager.LocalUserId,
                ParentId = ParentId

            });

            var indexOptions = genres.Items.Select(i => new TabItem
            {
                Name = i.Name,
                DisplayName = i.Name
            });

            var options = new ListPageConfig
            {
                IndexOptions = indexOptions.ToList(),
                PageTitle = "TV",
                CustomItemQuery = GetSeriesByGenre
            };

            SetDefaults(options);

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, PresentationManager, _navService, _playbackManager, _logger, options)
            {
                ViewType = ViewType.Tv
            };

            await _navService.Navigate(page);
        }
        private ListPageConfig GetListPageConfig(BaseItemDto item, ViewType context)
        {
            var config = new ListPageConfig();

            if (context == ViewType.Tv)
            {
                TvViewModel.SetDefaults(config);

                if (item.IsType("season"))
                {
                    config.DefaultViewType = ListViewTypes.List;
                }
            }
            else if (context == ViewType.Movies)
            {
                MoviesViewModel.SetDefaults(config);
            }
            else if (context == ViewType.Games)
            {
                GamesViewModel.SetDefaults(config, item.GameSystem);
            }

            return config;
        }
        private async Task NavigateToYearsInternal()
        {
            var item = await GetRootFolder();

            var displayPreferences = await PresentationManager.GetDisplayPreferences("GameYears", CancellationToken.None);

            var yearIndex = await ApiClient.GetYearIndex(_sessionManager.LocalUserId, new[] { "Game" }, CancellationToken.None);

            var indexOptions = yearIndex.Where(i => !string.IsNullOrEmpty(i.Name)).OrderByDescending(i => i.Name).Select(i => new TabItem
            {
                Name = i.Name,
                DisplayName = i.Name
            });

            var options = new ListPageConfig
            {
                IndexOptions = indexOptions.ToList(),
                PageTitle = "Games",
                CustomItemQuery = GetGamesByYear
            };

            SetDefaults(options, null);

            options.DefaultViewType = ListViewTypes.PosterStrip;

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, PresentationManager, _navService, _playbackManager, _logger, options)
            {
                ViewType = ViewType.Games
            };

            await _navService.Navigate(page);
        }
        private async Task NavigateToGenreInternal(string itemType, string includeItemType, string pageTitle, Func<ItemListViewModel, DisplayPreferences, Task<ItemsResult>> query, string selectedGenre)
        {
            var apiClient = _sessionFactory().ActiveApiClient;

            var root = await apiClient.GetRootFolderAsync(apiClient.CurrentUserId);

            var displayPreferences = await _presentationManager.GetDisplayPreferences(apiClient, itemType + "Genres", CancellationToken.None);

            var genres = await apiClient.GetGenresAsync(new ItemsByNameQuery
            {
                IncludeItemTypes = new[] { includeItemType },
                SortBy = new[] { ItemSortBy.SortName },
                Recursive = true,
                UserId = _sessionFactory().LocalUserId
            });

            var indexOptions = genres.Items.Select(i => new TabItem
            {
                Name = i.Name,
                DisplayName = i.Name
            });

            var options = new ListPageConfig
            {
                IndexOptions = indexOptions.ToList(),
                IndexValue = selectedGenre,
                PageTitle = pageTitle,
                CustomItemQuery = query
            };

            options.DefaultViewType = ListViewTypes.PosterStrip;

            var page = new FolderPage(root, displayPreferences, apiClient, _imageManager, _presentationManager, this, _playbackManagerFactory(), _logger, options)
            {
                ViewType = ViewType.Movies
            };

            await Navigate(page);
        }
Beispiel #22
0
 public static void SetDefaults(ListPageConfig config)
 {
     config.DefaultViewType = ListViewTypes.PosterStrip;
     config.PosterImageWidth = PosterWidth;
     config.ThumbImageWidth = ThumbstripWidth;
     config.ListImageWidth = ListImageWidth;
     config.PosterStripImageWidth = PosterStripWidth;
 }
        public static void SetDefaults(ListPageConfig config, string gameSystem)
        {
            config.DefaultViewType = ListViewTypes.Poster;
            config.PosterImageWidth = PosterWidth;
            config.ThumbImageWidth = ThumbstripWidth;
            config.ListImageWidth = ListImageWidth;
            config.PosterStripImageWidth = 320;

            if (string.Equals(gameSystem, GameSystem.Nintendo64, StringComparison.OrdinalIgnoreCase))
            {
                config.PosterImageWidth = 400;
                config.PosterStripImageWidth = 480;
            }
            else if (string.Equals(gameSystem, GameSystem.SuperNintendo, StringComparison.OrdinalIgnoreCase))
            {
                config.PosterImageWidth = 400;
                config.PosterStripImageWidth = 480;
            }
            else if (string.Equals(gameSystem, GameSystem.SegaSaturn, StringComparison.OrdinalIgnoreCase))
            {
                config.PosterImageWidth = PosterWidth - 20;
                config.PosterStripImageWidth = 250;
            }
            else if (string.Equals(gameSystem, GameSystem.SegaCD, StringComparison.OrdinalIgnoreCase))
            {
                config.PosterImageWidth = PosterWidth - 20;
                config.PosterStripImageWidth = 250;
            }
            else if (string.Equals(gameSystem, GameSystem.SonyPlaystation, StringComparison.OrdinalIgnoreCase))
            {
                config.PosterImageWidth = 300;
                config.PosterStripImageWidth = 380;
            }
            else if (string.Equals(gameSystem, GameSystem.SegaDreamcast, StringComparison.OrdinalIgnoreCase))
            {
                config.PosterImageWidth = 300;
                config.PosterStripImageWidth = 380;
            }
        }
Beispiel #24
0
        public async Task NavigateToAllShows()
        {
            var item = await GetRootFolder();

            var displayPreferences = await PresentationManager.GetDisplayPreferences(ApiClient, "Shows", CancellationToken.None);

            var options = new ListPageConfig
            {
                PageTitle = "TV",
                CustomItemQuery = GetAllShows,
                SortOptions = GetSeriesSortOptions()
            };

            SetDefaults(options);

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, PresentationManager, _navService, _playbackManager, _logger, options)
            {
                ViewType = ViewType.Tv
            };

            await _navService.Navigate(page);
        }
        private async Task NavigateToMultiPlayerGamesInternal()
        {
            var item = await ApiClient.GetRootFolderAsync(_sessionManager.CurrentUser.Id);

            var displayPreferences = await PresentationManager.GetDisplayPreferences("MultiPlayerGames", CancellationToken.None);

            var playerIndex = await ApiClient.GetGamePlayerIndex(_sessionManager.CurrentUser.Id, CancellationToken.None);

            var indexOptions = playerIndex.Where(i => !string.IsNullOrEmpty(i.Name) && int.Parse(i.Name) > 1).Select(i => new TabItem
            {
                Name = i.Name,
                DisplayName = i.Name + " Player (" + i.ItemCount + ")"
            });

            var options = new ListPageConfig
            {
                IndexOptions = indexOptions.ToList(),
                PageTitle = "Games | Multi-Player",
                CustomItemQuery = GetMultiPlayerGames
            };

            SetDefaults(options, null);

            var page = new FolderPage(item, displayPreferences, ApiClient, _imageManager, _sessionManager,
                                      PresentationManager, _navService, _playbackManager, _logger, _serverEvents, options)
            {
                ViewType = ViewType.Games
            };

            await _navService.Navigate(page);
        }