public MediaLibraryQueryViewSpecification CreateSubViewSpecification(string viewDisplayName, FilterTreePath filterPath, IFilter filter, Guid?linkedId) { IFilterTree newFilterTree = _filterTree.DeepCopy(); if (linkedId.HasValue) { newFilterTree.AddLinkedId(linkedId.Value, filterPath); } else if (filter != null) { newFilterTree.AddFilter(filter, filterPath); } return(new MediaLibraryQueryViewSpecification(viewDisplayName, newFilterTree, _necessaryMIATypeIds, _optionalMIATypeIds, _onlyOnline) { MaxNumItems = _maxNumItems, FilterPath = filterPath }); }
public virtual void InitMediaNavigation(MediaNavigationConfig config, out string mediaNavigationMode, out NavigationData navigationData) { PrepareAsync().Wait(); IFilterTree filterTree = _customFilterTree ?? (_rootRole.HasValue ? new RelationshipFilterTree(_rootRole.Value) : (IFilterTree) new SimpleFilterTree()); if (_filter != null) { filterTree.AddFilter(_filter); } //Default configuration string viewName = _viewName; AbstractScreenData nextScreen = null; //Apply any custom configuration if (config != null) { if (_availableScreens != null) { //Use the configured root screen to load the next screen from the hierarchy //and remove it from the list of available screens AbstractScreenData configRoot = config.RootScreenType != null?_availableScreens.FirstOrDefault(s => s.GetType() == config.RootScreenType) : null; if (configRoot != null) { viewName = configRoot.GetType().ToString(); _availableScreens.Remove(configRoot); } //Use the configured default screen if there is no saved screen hierarchy AbstractScreenData configDefault = config.DefaultScreenType != null?_availableScreens.FirstOrDefault(s => s.GetType() == config.DefaultScreenType) : null; if (configDefault != null) { _defaultScreen = configDefault; // If we want to force the default screen to be shown, set the next screen // here to avoid loading it from the screen hierarchy below. if (config.AlwaysUseDefaultScreen) { nextScreen = configDefault; } } } //Apply any additional filters if (config.LinkedId.HasValue) { filterTree.AddLinkedId(config.LinkedId.Value, config.FilterPath); } if (config.Filter != null) { filterTree.AddFilter(config.Filter, config.FilterPath); } } IEnumerable <Guid> optionalMIATypeIDs = MediaNavigationModel.GetMediaSkinOptionalMIATypes(MediaNavigationMode); if (_optionalMias != null) { optionalMIATypeIDs = optionalMIATypeIDs.Union(_optionalMias).Except(_necessaryMias); } // Try to load the prefered next screen from settings if not already set. if (nextScreen == null && NavigationData.LoadScreenHierarchy(viewName, out string nextScreenName)) { // Support for browsing mode. if (nextScreenName == Consts.USE_BROWSE_MODE) { SetBrowseMode(optionalMIATypeIDs); } if (_availableScreens != null) { nextScreen = _availableScreens.FirstOrDefault(s => s.GetType().ToString() == nextScreenName); } } if (_applyUserFilter) { var userFilter = UserHelper.GetUserRestrictionFilter(_necessaryMias.ToList()); if (userFilter != null) { filterTree.AddFilter(userFilter); } } // Prefer custom view specification. ViewSpecification rootViewSpecification = _customRootViewSpecification ?? // Always use the default view name for the root view specification, not any custom name that may // have been specified in a navigation config, otherwise toggling browse mode won't work correctly. // To switch to browse mode we update the root screen hierarchy to point to the browse screen and // then navigate to the root wf state. The name of the root screen hierarchy is determined by the // name specified here so it should always point to the actual root view name. new MediaLibraryQueryViewSpecification(_viewName, filterTree, _necessaryMias, optionalMIATypeIDs, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE, }; if (nextScreen == null) { nextScreen = _defaultScreen; } ScreenConfig nextScreenConfig; NavigationData.LoadLayoutSettings(nextScreen.GetType().ToString(), out nextScreenConfig); Sorting.Sorting nextSortingMode = _availableSortings.FirstOrDefault(sorting => sorting.GetType().ToString() == nextScreenConfig.Sorting) ?? _defaultSorting; Sorting.Sorting nextGroupingMode = _availableGroupings == null || String.IsNullOrEmpty(nextScreenConfig.Grouping) ? null : _availableGroupings.FirstOrDefault(grouping => grouping.GetType().ToString() == nextScreenConfig.Grouping) ?? _defaultGrouping; navigationData = new NavigationData(null, viewName, MediaNavigationRootState, MediaNavigationRootState, rootViewSpecification, nextScreen, _availableScreens, nextSortingMode, nextGroupingMode) { AvailableSortings = _availableSortings, AvailableGroupings = _availableGroupings, LayoutType = nextScreenConfig.LayoutType, LayoutSize = nextScreenConfig.LayoutSize }; mediaNavigationMode = MediaNavigationMode; }