/// <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> /// 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); }
public void ShowSiteOptions(OnlineSiteViewModel item) { ServiceRegistration.Get <IWorkflowManager>().NavigatePushTransient( WorkflowState.CreateTransientState("OnlineSiteOptions", item.Site.Name, true, "ovsDialogGenericItems", false, WorkflowType.Dialog), new NavigationContextConfig() { AdditionalContextVariables = new Dictionary <string, object> { { Constants.CONTEXT_VAR_ITEMS, GetSiteOptions(item) }, { Constants.CONTEXT_VAR_COMMAND, new CommandContainer <ListItem>(ExecuteSiteOption) } } }); }
/// <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); }
void ShowCategories(IList <Category> categories, string navigationLabel) { CategoriesList = new ItemsList(); foreach (Category c in categories) { CategoriesList.Add(new CategoryViewModel(c)); } ImageDownloader.GetImages <Category>(categories); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePushTransientAsync( WorkflowState.CreateTransientState(Guids.WorkflowStateCategoriesName, navigationLabel, false, "categories", false, WorkflowType.Workflow), new NavigationContextConfig()); }
void HandleCustomContextMenuEntry(Sites.ContextMenuEntry entry) { ServiceRegistration.Get <IScreenManager>().CloseTopmostDialog(); switch (entry.Action) { case Sites.ContextMenuEntry.UIAction.Execute: ExecuteCustomContextMenuEntry(entry); break; case Sites.ContextMenuEntry.UIAction.GetText: //todo: show input dialog and execute when confirmed //entry.UserInputText = text; //ExecuteCustomContextMenuEntry(entry); break; case Sites.ContextMenuEntry.UIAction.PromptYesNo: var dialogHandleId = ServiceRegistration.Get <IDialogManager>().ShowDialog(entry.DisplayText, entry.PromptText, DialogType.YesNoDialog, false, DialogButtonType.No); var dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, (dialogResult) => { if (dialogResult == DialogResult.Yes) { ExecuteCustomContextMenuEntry(entry); } }); break; case Sites.ContextMenuEntry.UIAction.ShowList: var menuItems = new ItemsList(); foreach (var item in entry.SubEntries) { var listItem = new ListItem(Consts.KEY_NAME, item.DisplayText); listItem.AdditionalProperties.Add(Consts.KEY_MEDIA_ITEM, item); menuItems.Add(listItem); } ServiceRegistration.Get <IWorkflowManager>().NavigatePushTransient( WorkflowState.CreateTransientState("CustomContextItems", entry.DisplayText, true, "ovsDialogGenericItems", false, WorkflowType.Dialog), new NavigationContextConfig() { AdditionalContextVariables = new Dictionary <string, object> { { Constants.CONTEXT_VAR_ITEMS, menuItems }, { Constants.CONTEXT_VAR_COMMAND, new CommandContainer <ListItem>((li) => HandleCustomContextMenuEntry(li.AdditionalProperties[Consts.KEY_MEDIA_ITEM] as Sites.ContextMenuEntry)) } } }); break; } }
/// <summary> /// Creates a <see cref="WorkflowAction"/> that pushes a dialog as transient state on the navigation stack. /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="displayLabel"></param> /// <param name="dialogItems"></param> /// <param name="sourceState"></param> /// <param name="action"></param> /// <returns></returns> public static WorkflowAction CreateDialogMenuAction(Guid id, string name, string displayLabel, ItemsList dialogItems, WorkflowState sourceState, Action <ListItem> action) { return(new PushTransientStateNavigationTransition( id, sourceState.Name + "->" + name, displayLabel, new Guid[] { sourceState.StateId }, WorkflowState.CreateTransientState(name, displayLabel, true, "ovsDialogGenericItems", false, WorkflowType.Dialog), LocalizationHelper.CreateResourceString(displayLabel)) { SortOrder = name, WorkflowNavigationContextVariables = new Dictionary <string, object> { { Constants.CONTEXT_VAR_ITEMS, dialogItems }, { Constants.CONTEXT_VAR_COMMAND, new CommandContainer <ListItem>(action) } } }); }
public void UpdateMenuActions(NavigationContext context, IDictionary <Guid, WorkflowAction> actions) { IConfigurationManager configurationManager = ServiceRegistration.Get <IConfigurationManager>(); string configLocation = GetConfigLocation(context); WorkflowState mainState; ServiceRegistration.Get <IWorkflowManager>().States.TryGetValue(new Guid(CONFIGURATION_MAIN_STATE_ID_STR), out mainState); IConfigurationNode currentNode = configurationManager.GetNode(configLocation); foreach (IConfigurationNode childNode in currentNode.ChildNodes) { if (childNode.ConfigObj is ConfigSection) { bool supportedSettings = NumSettingsSupported(childNode) > 0; // Hint (Albert): Instead of skipping, we could disable the transition in case there are no supported // settings contained in it if (!supportedSettings) { continue; } ConfigSection section = (ConfigSection)childNode.ConfigObj; // Create transient state for new config section WorkflowState newState = WorkflowState.CreateTransientState( string.Format("Config: '{0}'", childNode.Location), section.SectionMetadata.Text, false, CONFIGURATION_SECTION_SCREEN, false, WorkflowType.Workflow, context.WorkflowState.HideGroups); // Add action for menu IResourceString res = LocalizationHelper.CreateResourceString(section.Metadata.Text); WorkflowAction wa = new PushTransientStateNavigationTransition( Guid.NewGuid(), context.WorkflowState.Name + "->" + childNode.Location, null, new Guid[] { context.WorkflowState.StateId }, newState, res) { DisplayCategory = ACTIONS_WORKFLOW_CATEGORY, SortOrder = childNode.Sort ?? res.Evaluate(), WorkflowNavigationContextVariables = new Dictionary <string, object> { { CONFIG_LOCATION_KEY, childNode.Location } } }; actions.Add(wa.ActionId, wa); } } }
/// <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); }
public void ChoosePlaybackOptions(string defaultUrl, Action <string> resultHandler, bool skipDialog = false) { // with no options set, return the VideoUrl field if (VideoInfo.PlaybackOptions == null || VideoInfo.PlaybackOptions.Count == 0) { resultHandler(defaultUrl); } // with just one option set, resolve it and call handler else if (VideoInfo.PlaybackOptions.Count == 1) { BackgroundTask.Instance.Start <string>( () => { return(VideoInfo.GetPlaybackOptionUrl(VideoInfo.PlaybackOptions.First().Key)); }, (success, url) => { if (success) { resultHandler(url); } }, Translation.Instance.GettingPlaybackUrlsForVideo); } else { if (skipDialog) { var defaultOption = VideoInfo.PlaybackOptions.FirstOrDefault(p => p.Value == defaultUrl).Key; if (string.IsNullOrEmpty(defaultOption)) { defaultOption = VideoInfo.PlaybackOptions.First().Key; } BackgroundTask.Instance.Start <string>( () => { return(VideoInfo.GetPlaybackOptionUrl(defaultOption)); }, (success, url) => { if (success) { resultHandler(url); } }, Translation.Instance.GettingPlaybackUrlsForVideo); } else { var playbackOptionsItems = new ItemsList(); foreach (var item in VideoInfo.PlaybackOptions) { var listItem = new ListItem(Consts.KEY_NAME, item.Key); listItem.AdditionalProperties.Add(Constants.KEY_HANDLER, resultHandler); listItem.Selected = item.Value == defaultUrl; playbackOptionsItems.Add(listItem); } ServiceRegistration.Get <IWorkflowManager>().NavigatePushTransient( WorkflowState.CreateTransientState("PlaybackOptions", VideoInfo.Title, true, "ovsDialogGenericItems", false, WorkflowType.Dialog), new NavigationContextConfig() { AdditionalContextVariables = new Dictionary <string, object> { { Constants.CONTEXT_VAR_ITEMS, playbackOptionsItems }, { Constants.CONTEXT_VAR_COMMAND, new CommandContainer <ListItem>(SelectPlaybackOption) } } }); } } }