/// <summary> /// Creates a new navigation data structure for a new media navigation step. /// </summary> /// <param name="parent">Parent navigation data, this navigation data is derived from.</param> /// <param name="navigationContextName">Name, which is used for the corresponding workflow navigation context.</param> /// <param name="currentWorkflowStateId">Id of the workflow state which corresponds to the new media navigation step.</param> /// <param name="parentWorkflowStateId">Id of the workflow state to which the workflow navigation should be reverted when /// another filter is choosen.</param> /// <param name="baseViewSpecification">View specification for the media items of the new media navigation step.</param> /// <param name="defaultScreen">Screen which should present the new navigation step by default.</param> /// <param name="availableScreens">Available set of screen descriptions which can present the new media navigation step.</param> /// <param name="currentSorting">Denotes the current sorting for the items to be shown. If this is set to <c>null</c>, /// default sorting will be applied.</param> /// <param name="currentGrouping">Denotes the current grouping for the items to be shown.</param> public NavigationData(NavigationData parent, string navigationContextName, Guid parentWorkflowStateId, Guid currentWorkflowStateId, ViewSpecification baseViewSpecification, AbstractScreenData defaultScreen, ICollection <AbstractScreenData> availableScreens, Sorting.Sorting currentSorting, Sorting.Sorting currentGrouping) : this(parent, navigationContextName, parentWorkflowStateId, currentWorkflowStateId, baseViewSpecification, defaultScreen, availableScreens, currentSorting, currentGrouping, false) { }
/// <summary> /// Enters a new media navigation context by inheriting all currently available screens. This is used for /// presenting the contents of a media items or filter group, where the current menu should remain available. /// Only the currently visible screen can be exchanged to configure another presentation mode for the group to /// be stepped-in. /// </summary> /// <remarks> /// Actually, we mix two different concerns in this method: /// <list type="number"> /// <item>The setting that the new navigation context will be subordinated, i.e. it will be removed/exchanged by a filter action</item> /// <item>The setting that all menu actions will be adopted from the parent navigation context</item> /// </list> /// But in fact, filter actions are only used together with the concept that there exist two different kind of navigation contexts; /// autonomous contexts and subordinated contexts. /// If there are no filter actions present (like in the browse media navigation modes), the only difference between the methods /// <see cref="StackSubordinateNavigationContext"/> and <see cref="StackAutonomousNavigationContext"/> is the inheritance of the menu. /// </remarks> /// <param name="subViewSpecification">Specification for the sub view to be shown in the new navigation context.</param> /// <param name="visibleScreen">Screen which should be visible in the new navigation context.</param> /// <param name="navbarDisplayLabel">Display label to be shown in the navigation bar for the new navigation context.</param> /// <returns>Newly created navigation data.</returns> public NavigationData StackSubordinateNavigationContext(ViewSpecification subViewSpecification, AbstractScreenData visibleScreen, string navbarDisplayLabel) { WorkflowState newState = WorkflowState.CreateTransientState( "View: " + subViewSpecification.ViewDisplayName, subViewSpecification.ViewDisplayName, false, null, true, WorkflowType.Workflow, null); ScreenConfig nextScreenConfig; LoadLayoutSettings(visibleScreen.ToString(), out nextScreenConfig); Sorting.Sorting nextSortingMode = AvailableSortings.FirstOrDefault( sorting => sorting.GetType().ToString() == nextScreenConfig.Sorting && sorting.IsAvailable(visibleScreen)) ?? _currentSorting; Sorting.Sorting nextGroupingMode = string.IsNullOrEmpty(nextScreenConfig.Grouping) ? null : AvailableGroupings.FirstOrDefault( grouping => grouping.GetType().ToString() == nextScreenConfig.Grouping && grouping.IsAvailable(visibleScreen)) ?? _currentGrouping; NavigationData newNavigationData = new NavigationData(this, subViewSpecification.ViewDisplayName, _baseWorkflowStateId, newState.StateId, subViewSpecification, visibleScreen, _availableScreens, nextSortingMode, nextGroupingMode, true) { LayoutType = nextScreenConfig.LayoutType, LayoutSize = nextScreenConfig.LayoutSize }; PushNewNavigationWorkflowState(newState, navbarDisplayLabel, newNavigationData); return(newNavigationData); }
/// <summary> /// Prepares custom views or initializes specific data, which are not available at construction time (i.e. <see cref="MediaNavigationModel.GetMediaSkinOptionalMIATypes(string)"/>). /// </summary> protected virtual void Prepare() { // Read filters from plugin.xml and apply the matching ones BuildFilters(); _customRootViewSpecification = null; }
/// <summary> /// There are two modes for browsing media in its directory structure; ML browsing and local browsing. /// This method switches between those modes. It takes the current media navigation state and tries to navigate to the most sensible sibling state, i.e. /// tries to navigate as close as possible to the current directory navigation in the other mode. /// </summary> public static void NavigateToSiblingState() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); NavigationContext workflowNavigationContext = workflowManager.CurrentNavigationContext; NavigationData nd = MediaNavigationModel.GetNavigationData(workflowNavigationContext, false); if (nd == null) { ServiceRegistration.Get <ILogger>().Warn("AbstractBrowseMediaNavigationScreenData: Cannot navigate to sibling browse media state - there is no active media screen"); return; } AbstractBrowseMediaNavigationScreenData screenData = nd.CurrentScreenData as AbstractBrowseMediaNavigationScreenData; if (screenData == null) { ServiceRegistration.Get <ILogger>().Warn("AbstractBrowseMediaNavigationScreenData: Cannot navigate to sibling browse media state - there is no active media items screen"); return; } ViewSpecification vs = Unwrap(nd.BaseViewSpecification); ResourcePath path; if (BrowseMediaRootProxyViewSpecification.TryGetLocalBrowseViewPath(vs, out path)) { NavigateToLocalBrowsing(path); } else if (LocalMediaRootProxyViewSpecification.TryGetLocalBrowseViewPath(vs, out path)) { NavigateToMLBrowsing(path); } }
protected static ViewSpecification Unwrap(ViewSpecification vs) { // Unwrap potentially available removable media VS to get access to the inner ML VS or Local Browsing VS AddedRemovableMediaViewSpecificationFacade armvs = vs as AddedRemovableMediaViewSpecificationFacade; return(armvs == null ? vs : armvs.DelegateViewSpecification); }
protected void NavigateToGroup(ViewSpecification subViewSpecification, IFilter clusterFilter) { AbstractFiltersScreenData <T> childScreenData = Derive(); childScreenData.ClusterFilter = clusterFilter; // We already showed the clusters in the current screen - avoid clusters again else we would present the same grouped screen contents again _navigationData.StackSubordinateNavigationContext(subViewSpecification, childScreenData, GetNavbarDisplayLabel(subViewSpecification)); }
/// <summary> /// Prepares custom views or initializes specific data, which are not available at construction time (i.e. <see cref="MediaNavigationModel.GetMediaSkinOptionalMIATypes(string)"/>). /// </summary> protected virtual Task PrepareAsync() { // Read filters from plugin.xml and apply the matching ones BuildFilters(); _customRootViewSpecification = null; return(Task.CompletedTask); }
public virtual void InitMediaNavigation(out string mediaNavigationMode, out NavigationData navigationData) { Prepare(); string nextScreenName; AbstractScreenData nextScreen = null; // Try to load the prefered next screen from settings. if (NavigationData.LoadScreenHierarchy(_viewName, out nextScreenName)) { // Support for browsing mode. if (nextScreenName == Consts.USE_BROWSE_MODE) { SetBrowseMode(); } if (_availableScreens != null) { nextScreen = _availableScreens.FirstOrDefault(s => s.GetType().ToString() == nextScreenName); } } IEnumerable <Guid> optionalMIATypeIDs = MediaNavigationModel.GetMediaSkinOptionalMIATypes(MediaNavigationMode); if (_optionalMias != null) { optionalMIATypeIDs = optionalMIATypeIDs.Union(_optionalMias); optionalMIATypeIDs = optionalMIATypeIDs.Except(_necessaryMias); } // Prefer custom view specification. ViewSpecification rootViewSpecification = _customRootViewSpecification ?? new MediaLibraryQueryViewSpecification(_viewName, _filter, _necessaryMias, optionalMIATypeIDs, true, _necessaryMias) { 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; }
/// <summary> /// Enters a new media navigation context by inheriting all currently available screens. This is used for /// presenting the contents of a media items or filter group, where the current menu should remain available. /// Only the currently visible screen can be exchanged to configure another presentation mode for the group to /// be stepped-in. /// </summary> /// <remarks> /// Actually, we mix two different concerns in this method: /// <list type="number"> /// <item>The setting that the new navigation context will be subordinated, i.e. it will be removed/exchanged by a filter action</item> /// <item>The setting that all menu actions will be adopted from the parent navigation context</item> /// </list> /// But in fact, filter actions are only used together with the concept that there exist two different kind of navigation contexts; /// autonomous contexts and subordinated contexts. /// If there are no filter actions present (like in the browse media navigation modes), the only difference between the methods /// <see cref="StackSubordinateNavigationContext"/> and <see cref="StackAutonomousNavigationContext"/> is the inheritance of the menu. /// </remarks> /// <param name="subViewSpecification">Specification for the sub view to be shown in the new navigation context.</param> /// <param name="visibleScreen">Screen which should be visible in the new navigation context.</param> /// <param name="navbarDisplayLabel">Display label to be shown in the navigation bar for the new navigation context.</param> /// <returns>Newly created navigation data.</returns> public NavigationData StackSubordinateNavigationContext(ViewSpecification subViewSpecification, AbstractScreenData visibleScreen, string navbarDisplayLabel) { WorkflowState newState = WorkflowState.CreateTransientState( "View: " + subViewSpecification.ViewDisplayName, subViewSpecification.ViewDisplayName, false, null, true, WorkflowType.Workflow); NavigationData newNavigationData = new NavigationData(this, subViewSpecification.ViewDisplayName, _baseWorkflowStateId, newState.StateId, subViewSpecification, visibleScreen, _availableScreens, _currentSorting, true); PushNewNavigationWorkflowState(newState, navbarDisplayLabel, newNavigationData); return(newNavigationData); }
protected MultimediaDriveHandler(DriveInfo driveInfo, IEnumerable <Guid> necessaryMIATypeIds, IEnumerable <Guid> optionalMIATypeIds, MultiMediaType mediaType) : base(driveInfo) { _mediaType = mediaType; string drive = driveInfo.Name; drive = drive.Substring(0, 2); // Clip potential '\\' at the end string directory = "/" + drive + "/"; _mediaItemsSubViewSpecification = new LocalDirectoryViewSpecification(driveInfo.VolumeLabel + " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")", ResourcePath.BuildBaseProviderPath(LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID, directory), necessaryMIATypeIds, optionalMIATypeIds); }
/// <summary> /// Enters a new media navigation context by modifying the list of available screens. This is used for /// presenting the result of a filter, where the menu must be changed. /// </summary> /// <param name="subViewSpecification">Specification for the sub view to be shown in the new navigation context.</param> /// <param name="remainingScreens">New collection of remaining available screens.</param> /// <param name="navbarDisplayLabel">Display label to be shown in the navigation bar for the new navigation context.</param> /// <returns>Newly created navigation data.</returns> public NavigationData StackAutonomousNavigationContext(ViewSpecification subViewSpecification, ICollection <AbstractScreenData> remainingScreens, string navbarDisplayLabel) { WorkflowState newState = WorkflowState.CreateTransientState( "View: " + subViewSpecification.ViewDisplayName, subViewSpecification.ViewDisplayName, false, null, false, WorkflowType.Workflow); NavigationData newNavigationData = new NavigationData(this, subViewSpecification.ViewDisplayName, newState.StateId, newState.StateId, subViewSpecification, remainingScreens.FirstOrDefault(), remainingScreens, _currentSorting); PushNewNavigationWorkflowState(newState, navbarDisplayLabel, newNavigationData); return(newNavigationData); }
public ViewDefinitionImpl(SQLVendorImpl vendor, TableNameDirect name, QueryExpression query, ViewSpecification spec, ViewCheckOption?check, Boolean isRecursive) : base(vendor) { ArgumentValidator.ValidateNotNull(nameof(name), name); ArgumentValidator.ValidateNotNull(nameof(query), query); ArgumentValidator.ValidateNotNull(nameof(spec), spec); this._name = name; this._query = query; this._spec = spec; this._viewCheck = check; this._isRecursive = isRecursive; }
/// <summary> /// Enters a new media navigation context by modifying the list of available screens. This is used for /// presenting the result of a filter, where the menu must be changed. /// </summary> /// <param name="subViewSpecification">Specification for the sub view to be shown in the new navigation context.</param> /// <param name="currentMenuItemLabel">Current menu item label needed for distinction of available screens.</param> /// <param name="navbarDisplayLabel">Display label to be shown in the navigation bar for the new navigation context.</param> /// <returns>Newly created navigation data.</returns> public NavigationData StackAutonomousNavigationContext(ViewSpecification subViewSpecification, string currentMenuItemLabel, string navbarDisplayLabel) { AbstractScreenData currentScreen = AvailableScreens.FirstOrDefault(screen => screen.MenuItemLabel == currentMenuItemLabel); ICollection <AbstractScreenData> remainingScreens = new List <AbstractScreenData>(AvailableScreens.Where(screen => screen != currentScreen)); WorkflowState newState = WorkflowState.CreateTransientState( "View: " + subViewSpecification.ViewDisplayName, subViewSpecification.ViewDisplayName, false, null, false, WorkflowType.Workflow, null); string nextScreenName; AbstractScreenData nextScreen = null; // Try to load the prefered next screen from settings. if (LoadScreenHierarchy(CurrentScreenData.GetType().ToString(), out nextScreenName)) { nextScreen = remainingScreens.FirstOrDefault(s => s.GetType().ToString() == nextScreenName); } // Default way: always take the first of the available screens. if (nextScreen == null) { nextScreen = remainingScreens.First(s => s != currentScreen); } ScreenConfig nextScreenConfig; LoadLayoutSettings(nextScreen.GetType().ToString(), out nextScreenConfig); Sorting.Sorting nextSortingMode = AvailableSortings.FirstOrDefault( sorting => sorting.GetType().ToString() == nextScreenConfig.Sorting && sorting.IsAvailable(nextScreen)) ?? _currentSorting; Sorting.Sorting nextGroupingMode = String.IsNullOrEmpty(nextScreenConfig.Grouping) ? null : AvailableGroupings.FirstOrDefault( grouping => grouping.GetType().ToString() == nextScreenConfig.Grouping && grouping.IsAvailable(nextScreen)) ?? _currentGrouping; NavigationData newNavigationData = new NavigationData(this, subViewSpecification.ViewDisplayName, newState.StateId, newState.StateId, subViewSpecification, nextScreen, remainingScreens, nextSortingMode, nextGroupingMode) { LayoutType = nextScreenConfig.LayoutType, LayoutSize = nextScreenConfig.LayoutSize }; PushNewNavigationWorkflowState(newState, navbarDisplayLabel, newNavigationData); return(newNavigationData); }
// If the suppressActions parameter is set to <c>true</c>, no actions will be built. Instead, they will be inherited from // the parent navigation step. That is used for subview navigation where the navigation step doesn't produce own // workflow actions. protected NavigationData(NavigationData parent, string navigationContextName, Guid parentWorkflowStateId, Guid currentWorkflowStateId, ViewSpecification baseViewSpecification, AbstractScreenData defaultScreen, ICollection <AbstractScreenData> availableScreens, Sorting.Sorting currentSorting, bool suppressActions) { _parent = parent; _navigationContextName = navigationContextName; _currentWorkflowStateId = currentWorkflowStateId; _baseWorkflowStateId = parentWorkflowStateId; _baseViewSpecification = baseViewSpecification; _currentScreenData = defaultScreen; _availableScreens = availableScreens ?? new List <AbstractScreenData>(); _currentSorting = currentSorting; if (suppressActions) { _dynamicWorkflowActions = null; } else { BuildWorkflowActions(); } }
protected void InitializeSearch(ViewSpecification baseViewSpecification) { _baseViewSpecification = baseViewSpecification as MediaLibraryQueryViewSpecification; if (_baseViewSpecification == null) { return; } if (_simpleSearchTextProperty == null) { _simpleSearchTextProperty = new WProperty(typeof(string), string.Empty); _simpleSearchTextProperty.Attach(OnSimpleSearchTextChanged); } SimpleSearchText = string.Empty; // Initialize data manually which would have been initialized by AbstractItemsScreenData.UpdateMediaItems else IsItemsValid = true; IsItemsEmpty = false; TooManyItems = false; NumItemsStr = "-"; NumItems = 0; lock (_syncObj) _view = null; _items = new ItemsList(); }
/// <summary> /// Constructs the display label for navigation bar. Derived classes can override the way how to construct it. /// </summary> /// <param name="subViewSpecification">ViewSpecification.</param> /// <returns>Display label.</returns> protected virtual string GetNavbarDisplayLabel(ViewSpecification subViewSpecification) { return(LocalizationHelper.Translate(_navbarSubViewNavigationDisplayLabel, LocalizationHelper.Translate(subViewSpecification.ViewDisplayName))); }
/// <summary> /// Returns context variables to be set for the given workflow state id. /// </summary> /// <param name="workflowStateId">Workflow state which determines the root media navigation state.</param> /// <returns>Mapping of context variable keys to values.</returns> protected static IDictionary <string, object> PrepareRootState(Guid workflowStateId) { IDictionary <string, object> result = new Dictionary <string, object>(); // The initial state ID determines the media model "part" to initialize: Browse local media, browse media library, audio, videos or images. // The media model part determines the media navigation mode and the view contents to be set. NavigationData navigationData; string mode; if (_initializers.ContainsKey(workflowStateId)) { // Use the IMediaNavigationInitializer that is associated with our root workflow state. IMediaNavigationInitializer initializer = _initializers[workflowStateId]; initializer.InitMediaNavigation(out mode, out navigationData); } else { // If we were called with a supported root state, we should be either in state WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT // or WF_STATE_ID_MEDIA_BROWSE_NAVIGATION_ROOT here if (workflowStateId != Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT && workflowStateId != Consts.WF_STATE_ID_BROWSE_MEDIA_NAVIGATION_ROOT) { // Error case: We cannot handle the given state ServiceRegistration.Get <ILogger>().Warn("MediaNavigationModel: Unknown root workflow state with ID '{0}', initializing local media navigation", workflowStateId); // We simply use the local media mode as fallback for this case, so we go on workflowStateId = Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT; } mode = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? MediaNavigationMode.BrowseLocalMedia : MediaNavigationMode.BrowseMediaLibrary; IEnumerable <Guid> skinDependentOptionalMIATypeIDs = GetMediaSkinOptionalMIATypes(mode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => { if (mi.Aspects.ContainsKey(AudioAspect.ASPECT_ID)) { return new AudioItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) } } ; if (mi.Aspects.ContainsKey(VideoAspect.ASPECT_ID)) { return new VideoItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) } } ; if (mi.Aspects.ContainsKey(ImageAspect.ASPECT_ID)) { return new ImageItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) } } ; return(null); }; IEnumerable <Guid> necessaryMIATypeIDs = new Guid[] { ProviderResourceAspect.ASPECT_ID, MediaAspect.ASPECT_ID, }; IEnumerable <Guid> optionalMIATypeIDs = new Guid[] { AudioAspect.ASPECT_ID, VideoAspect.ASPECT_ID, ImageAspect.ASPECT_ID, }.Union(skinDependentOptionalMIATypeIDs); string viewName = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? Consts.RES_LOCAL_MEDIA_ROOT_VIEW_NAME : Consts.RES_BROWSE_MEDIA_ROOT_VIEW_NAME; ViewSpecification rootViewSpecification = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? new AddedRemovableMediaViewSpecificationFacade(new LocalMediaRootProxyViewSpecification(viewName, necessaryMIATypeIDs, optionalMIATypeIDs)) : new AddedRemovableMediaViewSpecificationFacade(new BrowseMediaRootProxyViewSpecification(viewName, necessaryMIATypeIDs, optionalMIATypeIDs)); // Dynamic screens remain null - browse media states don't provide dynamic filters AbstractScreenData screenData = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? (AbstractScreenData) new LocalMediaNavigationScreenData(picd) : new BrowseMediaNavigationScreenData(picd); Sorting.Sorting browseDefaultSorting = new BrowseDefaultSorting(); ICollection <Sorting.Sorting> availableSortings = new List <Sorting.Sorting> { browseDefaultSorting, new SortByTitle(), new SortByDate(), // We could offer sortings here which are specific for one media item type but which will cope with all three item types (and sort items of the three types in a defined order) }; navigationData = new NavigationData(null, viewName, workflowStateId, workflowStateId, rootViewSpecification, screenData, null, browseDefaultSorting) { AvailableSortings = availableSortings }; } result.Add(Consts.KEY_NAVIGATION_MODE, mode); result.Add(Consts.KEY_NAVIGATION_DATA, navigationData); return(result); }
/// <summary> /// Prepares custom views or initializes specific data, which are not available at construction time (i.e. <see cref="MediaNavigationModel.GetMediaSkinOptionalMIATypes(string)"/>). /// </summary> protected virtual void Prepare() { _customRootViewSpecification = null; }
public virtual ViewDefinition NewViewDefinition(TableNameDirect viewName, QueryExpression query, ViewSpecification viewSpec, ViewCheckOption?viewCheck = null, bool isRecursive = false) { return(new ViewDefinitionImpl(this.vendor, viewName, query, viewSpec, viewCheck, isRecursive)); }
/// <summary> /// Does the actual work of navigating to the specifield sub view. This will create a new <see cref="NavigationData"/> /// instance for the new screen and push a new transient workflow state onto the workflow navigation stack. /// </summary> /// <param name="subViewSpecification">Specification of the sub view to navigate to.</param> protected internal NavigationData NavigateToView(ViewSpecification subViewSpecification) { return(_navigationData.StackSubordinateNavigationContext(subViewSpecification, Derive(), LocalizationHelper.Translate(_navbarSubViewNavigationDisplayLabel, LocalizationHelper.Translate(subViewSpecification.ViewDisplayName)))); }
protected void NavigateToSubView(ViewSpecification subViewSpecification, ICollection <AbstractScreenData> remainingScreens) { _navigationData.StackAutonomousNavigationContext(subViewSpecification, remainingScreens, LocalizationHelper.Translate(_navbarSubViewNavigationDisplayLabel, LocalizationHelper.Translate(subViewSpecification.ViewDisplayName))); }
public ViewDefinitionBuilder SetViewSpecification(ViewSpecification specification) { this._viewSpec = specification; return(this); }
/// <summary> /// Loads the view. /// </summary> /// <param name="specification">The specification.</param> public void LoadView(ViewSpecification specification) { RegionManager.RequestNavigate(RegionNames.MainContentRegion, specification.GetAddress(), NavigationCompleted, specification.Parameters); }
protected void NavigateToSubView(ViewSpecification subViewSpecification) { _navigationData.StackAutonomousNavigationContext(subViewSpecification, MenuItemLabel, GetNavbarDisplayLabel(subViewSpecification)); }
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; }
/// <summary> /// Switches to browsing by MediaLibray shares, limited to restricted MediaCategories. /// </summary> /// <param name="optionalMIATypeIDs">Optional MIAs to use.</param> protected void SetBrowseMode(IEnumerable <Guid> optionalMIATypeIDs) { _availableScreens = null; _defaultScreen = new BrowseMediaNavigationScreenData(_genericPlayableItemCreatorDelegate); _customRootViewSpecification = new BrowseMediaRootProxyViewSpecification(_viewName, _necessaryMias, optionalMIATypeIDs, _restrictedMediaCategories); }
/// <summary> /// Returns context variables to be set for the given workflow state id. /// </summary> /// <param name="workflowStateId">Workflow state which determines the root media navigation state.</param> /// <returns>Mapping of context variable keys to values.</returns> protected static IDictionary <string, object> PrepareRootState(Guid workflowStateId) { IDictionary <string, object> result = new Dictionary <string, object>(); // The initial state ID determines the media model "part" to initialize: Browse local media, browse media library, audio, videos or images. // The media model part determines the media navigation mode and the view contents to be set. NavigationData navigationData; MediaNavigationMode mode; if (workflowStateId == Consts.WF_STATE_ID_AUDIO_NAVIGATION_ROOT) { mode = MediaNavigationMode.Audio; IEnumerable <Guid> skinDependentOptionalMIATypeIDs = GetMediaSkinOptionalMIATypes(mode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new AudioItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) }; ViewSpecification rootViewSpecification = new MediaLibraryQueryViewSpecification(Consts.RES_AUDIO_VIEW_NAME, null, Consts.NECESSARY_AUDIO_MIAS, skinDependentOptionalMIATypeIDs, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; AbstractScreenData filterByAlbum = new AudioFilterByAlbumScreenData(); ICollection <AbstractScreenData> availableScreens = new List <AbstractScreenData> { new AudioShowItemsScreenData(picd), new AudioFilterByArtistScreenData(), filterByAlbum, // C# doesn't like it to have an assignment inside a collection initializer new AudioFilterByGenreScreenData(), new AudioFilterByDecadeScreenData(), new AudioFilterBySystemScreenData(), new AudioSimpleSearchScreenData(picd), }; Sorting.Sorting sortByAlbumTrack = new AudioSortByAlbumTrack(); ICollection <Sorting.Sorting> availableSortings = new List <Sorting.Sorting> { sortByAlbumTrack, new SortByTitle(), new AudioSortByFirstGenre(), new AudioSortByFirstArtist(), new AudioSortByAlbum(), new AudioSortByTrack(), new SortByYear(), new SortBySystem(), }; navigationData = new NavigationData(null, Consts.RES_AUDIO_VIEW_NAME, workflowStateId, workflowStateId, rootViewSpecification, filterByAlbum, availableScreens, sortByAlbumTrack) { AvailableSortings = availableSortings }; } else if (workflowStateId == Consts.WF_STATE_ID_VIDEOS_NAVIGATION_ROOT) { mode = MediaNavigationMode.Videos; IEnumerable <Guid> skinDependentOptionalMIATypeIDs = GetMediaSkinOptionalMIATypes(mode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new VideoItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) }; ViewSpecification rootViewSpecification = new MediaLibraryQueryViewSpecification(Consts.RES_VIDEOS_VIEW_NAME, null, Consts.NECESSARY_VIDEO_MIAS, skinDependentOptionalMIATypeIDs, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; AbstractScreenData filterByGenre = new VideosFilterByGenreScreenData(); ICollection <AbstractScreenData> availableScreens = new List <AbstractScreenData> { new VideosShowItemsScreenData(picd), new VideosFilterByLanguageScreenData(), new VideosFilterByActorScreenData(), filterByGenre, // C# doesn't like it to have an assignment inside a collection initializer new VideosFilterByYearScreenData(), new VideosFilterBySystemScreenData(), new VideosSimpleSearchScreenData(picd), }; Sorting.Sorting sortByTitle = new SortByTitle(); ICollection <Sorting.Sorting> availableSortings = new List <Sorting.Sorting> { sortByTitle, new SortByYear(), new VideoSortByFirstGenre(), new VideoSortByDuration(), new VideoSortByDirector(), new VideoSortByFirstActor(), new VideoSortBySize(), new VideoSortByAspectRatio(), new SortBySystem(), }; navigationData = new NavigationData(null, Consts.RES_VIDEOS_VIEW_NAME, workflowStateId, workflowStateId, rootViewSpecification, filterByGenre, availableScreens, sortByTitle) { AvailableSortings = availableSortings }; } else if (workflowStateId == Consts.WF_STATE_ID_SERIES_NAVIGATION_ROOT) { mode = MediaNavigationMode.Videos; IEnumerable <Guid> skinDependentOptionalMIATypeIDs = GetMediaSkinOptionalMIATypes(mode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new SeriesItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) }; ViewSpecification rootViewSpecification = new MediaLibraryQueryViewSpecification(Consts.RES_SERIES_VIEW_NAME, null, Consts.NECESSARY_SERIES_MIAS, skinDependentOptionalMIATypeIDs, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; AbstractScreenData filterBySeries = new SeriesFilterByNameScreenData(); ICollection <AbstractScreenData> availableScreens = new List <AbstractScreenData> { new SeriesShowItemsScreenData(picd), filterBySeries, // C# doesn't like it to have an assignment inside a collection initializer new VideosFilterByLanguageScreenData(), new SeriesFilterBySeasonScreenData(), new VideosFilterByGenreScreenData(), new VideosSimpleSearchScreenData(picd), }; Sorting.Sorting sortByEpisode = new SeriesSortByEpisode(); ICollection <Sorting.Sorting> availableSortings = new List <Sorting.Sorting> { sortByEpisode, new SortByTitle(), new SortByDate(), new SortBySystem(), }; navigationData = new NavigationData(null, Consts.RES_SERIES_VIEW_NAME, workflowStateId, workflowStateId, rootViewSpecification, filterBySeries, availableScreens, sortByEpisode) { AvailableSortings = availableSortings }; } else if (workflowStateId == Consts.WF_STATE_ID_MOVIES_NAVIGATION_ROOT) { mode = MediaNavigationMode.Movies; IEnumerable <Guid> skinDependentOptionalMIATypeIDs = GetMediaSkinOptionalMIATypes(mode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new MovieItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) }; ViewSpecification rootViewSpecification = new MediaLibraryQueryViewSpecification(Consts.RES_MOVIES_VIEW_NAME, null, Consts.NECESSARY_MOVIES_MIAS, skinDependentOptionalMIATypeIDs, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; AbstractScreenData filterByGenre = new VideosFilterByGenreScreenData(); ICollection <AbstractScreenData> availableScreens = new List <AbstractScreenData> { new MoviesShowItemsScreenData(picd), new VideosFilterByActorScreenData(), filterByGenre, // C# doesn't like it to have an assignment inside a collection initializer new VideosFilterByYearScreenData(), new VideosFilterBySystemScreenData(), new VideosSimpleSearchScreenData(picd), }; Sorting.Sorting sortByTitle = new SortByTitle(); ICollection <Sorting.Sorting> availableSortings = new List <Sorting.Sorting> { sortByTitle, new SortByYear(), new VideoSortByFirstGenre(), new VideoSortByDuration(), new VideoSortByDirector(), new VideoSortByFirstActor(), new VideoSortBySize(), new VideoSortByAspectRatio(), new SortBySystem(), }; navigationData = new NavigationData(null, Consts.RES_MOVIES_VIEW_NAME, workflowStateId, workflowStateId, rootViewSpecification, filterByGenre, availableScreens, sortByTitle) { AvailableSortings = availableSortings }; } else if (workflowStateId == Consts.WF_STATE_ID_IMAGES_NAVIGATION_ROOT) { mode = MediaNavigationMode.Images; IEnumerable <Guid> skinDependentOptionalMIATypeIDs = GetMediaSkinOptionalMIATypes(mode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new ImageItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) }; ViewSpecification rootViewSpecification = new MediaLibraryQueryViewSpecification(Consts.RES_IMAGES_VIEW_NAME, null, Consts.NECESSARY_IMAGE_MIAS, skinDependentOptionalMIATypeIDs, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; AbstractScreenData filterByYear = new ImagesFilterByYearScreenData(); ICollection <AbstractScreenData> availableScreens = new List <AbstractScreenData> { new ImagesShowItemsScreenData(picd), filterByYear, // C# doesn't like it to have an assignment inside a collection initializer new ImagesFilterBySizeScreenData(), new ImagesFilterBySystemScreenData(), new ImagesSimpleSearchScreenData(picd), }; Sorting.Sorting sortByYear = new SortByYear(); ICollection <Sorting.Sorting> availableSortings = new List <Sorting.Sorting> { new SortByYear(), new SortByTitle(), new ImageSortBySize(), new SortBySystem(), }; navigationData = new NavigationData(null, Consts.RES_IMAGES_VIEW_NAME, workflowStateId, workflowStateId, rootViewSpecification, filterByYear, availableScreens, sortByYear) { AvailableSortings = availableSortings }; } else { // If we were called with a supported root state, we should be either in state WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT // or WF_STATE_ID_MEDIA_BROWSE_NAVIGATION_ROOT here if (workflowStateId != Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT && workflowStateId != Consts.WF_STATE_ID_BROWSE_MEDIA_NAVIGATION_ROOT) { // Error case: We cannot handle the given state ServiceRegistration.Get <ILogger>().Warn("MediaNavigationModel: Unknown root workflow state with ID '{0}', initializing local media navigation", workflowStateId); // We simply use the local media mode as fallback for this case, so we go on workflowStateId = Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT; } mode = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? MediaNavigationMode.BrowseLocalMedia : MediaNavigationMode.BrowseMediaLibrary; IEnumerable <Guid> skinDependentOptionalMIATypeIDs = GetMediaSkinOptionalMIATypes(mode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => { if (mi.Aspects.ContainsKey(AudioAspect.ASPECT_ID)) { return new AudioItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) } } ; if (mi.Aspects.ContainsKey(VideoAspect.ASPECT_ID)) { return new VideoItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) } } ; if (mi.Aspects.ContainsKey(ImageAspect.ASPECT_ID)) { return new ImageItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) } } ; return(null); }; IEnumerable <Guid> necessaryMIATypeIDs = new Guid[] { ProviderResourceAspect.ASPECT_ID, MediaAspect.ASPECT_ID, }; IEnumerable <Guid> optionalMIATypeIDs = new Guid[] { AudioAspect.ASPECT_ID, VideoAspect.ASPECT_ID, ImageAspect.ASPECT_ID, }.Union(skinDependentOptionalMIATypeIDs); string viewName = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? Consts.RES_LOCAL_MEDIA_ROOT_VIEW_NAME : Consts.RES_BROWSE_MEDIA_ROOT_VIEW_NAME; ViewSpecification rootViewSpecification = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? new AddedRemovableMediaViewSpecificationFacade(new LocalMediaRootProxyViewSpecification(viewName, necessaryMIATypeIDs, optionalMIATypeIDs)) : new AddedRemovableMediaViewSpecificationFacade(new BrowseMediaRootProxyViewSpecification(viewName, necessaryMIATypeIDs, optionalMIATypeIDs)); // Dynamic screens remain null - browse media states don't provide dynamic filters AbstractScreenData screenData = workflowStateId == Consts.WF_STATE_ID_LOCAL_MEDIA_NAVIGATION_ROOT ? (AbstractScreenData) new LocalMediaNavigationScreenData(picd) : new BrowseMediaNavigationScreenData(picd); Sorting.Sorting browseDefaultSorting = new BrowseDefaultSorting(); ICollection <Sorting.Sorting> availableSortings = new List <Sorting.Sorting> { browseDefaultSorting, new SortByTitle(), new SortByDate(), // We could offer sortings here which are specific for one media item type but which will cope with all three item types (and sort items of the three types in a defined order) }; navigationData = new NavigationData(null, viewName, workflowStateId, workflowStateId, rootViewSpecification, screenData, null, browseDefaultSorting) { AvailableSortings = availableSortings }; } result.Add(Consts.KEY_NAVIGATION_MODE, mode); result.Add(Consts.KEY_NAVIGATION_DATA, navigationData); return(result); }