/// <summary>
        /// Navigates to the given media navigation state and shows the given screen.
        /// </summary>
        /// <param name="mediaNavigationRootState">The root media navigation state.</param>
        /// <param name="filterScreenType">The type of screen data to show.</param>
        public void NavigateToFilterScreen(Guid mediaNavigationRootState, Type filterScreenType)
        {
            MediaNavigationConfig config = new MediaNavigationConfig
            {
                DefaultScreenType      = filterScreenType,
                AlwaysUseDefaultScreen = true
            };

            MediaNavigationModel.NavigateToRootState(mediaNavigationRootState, config);
        }
        /// <summary>
        /// Navigates to the specified media navigation root state.
        /// </summary>
        /// <param name="mediaNavigationRootState">The root workflow state.</param>
        /// <param name="config">Configuration for the media navigation or <c>null</c> to use the default configuration.</param>
        public static void NavigateToRootState(Guid mediaNavigationRootState, MediaNavigationConfig config)
        {
            Dictionary <string, object> contextVariables = new Dictionary <string, object>();

            contextVariables.Add(Consts.KEY_NAVIGATION_CONFIG, config);
            var wf = ServiceRegistration.Get <IWorkflowManager>();

            wf.NavigatePushAsync(mediaNavigationRootState, new NavigationContextConfig()
            {
                AdditionalContextVariables = contextVariables
            });
        }
        /// <summary>
        /// Prepares the given workflow navigation <paramref name="context"/>, i.e. prepares the view data and the
        /// available filter criteria to be used in the menu.
        /// </summary>
        protected void PrepareState(NavigationContext context)
        {
            _currentNavigationContext = context;
            NavigationData navigationData = GetNavigationData(context, false);

            if (navigationData != null)
            {
                return;
            }

            MediaNavigationConfig config = context.GetContextVariable(Consts.KEY_NAVIGATION_CONFIG, false) as MediaNavigationConfig;
            // Initialize root media navigation state. We will set up all sub processes for each media model "part", i.e.
            // audio, videos, images, browse local media and browse media library.
            IDictionary <string, object> contextVariables = PrepareRootState(context.WorkflowState.StateId, config);

            foreach (KeyValuePair <string, object> variable in contextVariables)
            {
                context.SetContextVariable(variable.Key, variable.Value);
            }
        }
        /// <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>
        /// <param name="config">Configuration for the media navigation</param>
        /// <returns>Mapping of context variable keys to values.</returns>
        protected static IDictionary <string, object> PrepareRootState(Guid workflowStateId, MediaNavigationConfig config)
        {
            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.
            if (!_initializers.ContainsKey(workflowStateId))
            {
                return(result);
            }

            // Use the IMediaNavigationInitializer that is associated with our root workflow state.
            IMediaNavigationInitializer initializer = _initializers[workflowStateId];
            string         mode;
            NavigationData navigationData;

            initializer.InitMediaNavigation(config, out mode, out navigationData);
            result.Add(Consts.KEY_NAVIGATION_MODE, mode);
            result.Add(Consts.KEY_NAVIGATION_DATA, navigationData);
            return(result);
        }