Exemplo 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;
        }
Exemplo n.º 2
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 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 Task <ItemsResult> GetItemsAsync(ItemListViewModel viewModel)
        {
            if (_options.CustomItemQuery != null)
            {
                return(_options.CustomItemQuery(viewModel, _displayPreferences));
            }

            var query = new ItemQuery
            {
                ParentId = _parentItem.Id,

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

                SortOrder = _displayPreferences.SortOrder,
                UserId    = _sessionManager.CurrentUser.Id,
                Fields    = QueryFields
            };

            return(_apiClient.GetItemsAsync(query));
        }