protected async Task AsyncAddToPlaylist(IPlayerContext pc, GetMediaItemsDlgt getMediaItemsFunction, bool play) { IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>(); Guid? dialogInstanceId = screenManager.ShowDialog(Consts.DIALOG_ADD_TO_PLAYLIST_PROGRESS, (dialogName, instanceId) => StopAddToPlaylist()); try { int numItems = 0; _stopAddToPlaylist = false; SetNumItemsAddedToPlaylist(0); ICollection <MediaItem> items = new List <MediaItem>(); foreach (MediaItem item in getMediaItemsFunction()) { SetNumItemsAddedToPlaylist(++numItems); if (_stopAddToPlaylist) { break; } items.Add(item); } pc.Playlist.AddAll(items); } finally { if (dialogInstanceId.HasValue) { screenManager.CloseDialog(dialogInstanceId.Value); } IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS, true); } // Must be done after the dialog is closed await CompletePlayOrEnqueue(pc, play); }
protected void BuildWorkflowActions() { _dynamicWorkflowActions = new List <WorkflowAction>(_availableScreens.Count); int ct = 0; foreach (AbstractScreenData screen in _availableScreens) { AbstractScreenData newScreen = screen; // Necessary to be used in closure WorkflowAction action = new MethodDelegateAction(Guid.NewGuid(), _navigationContextName + "->" + newScreen.MenuItemLabel, new Guid[] { _currentWorkflowStateId }, LocalizationHelper.CreateResourceString(newScreen.MenuItemLabel), () => { _currentScreenData.ReleaseScreenData(); _currentScreenData = newScreen; IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); // The last screen could have stepped into a deeper media navigation context when it had produced // sub views. So we first have to revert our workflow to the base workflow id before moving to the new screen. if (workflowManager.CurrentNavigationContext.WorkflowState.StateId == _baseWorkflowStateId) { // If we're already in the correct the state, update the screen manually _currentScreenData.CreateScreenData(this); SwitchToCurrentScreen(); } else { // WF-Manager updates the screen for us workflowManager.NavigatePopToState(_baseWorkflowStateId, false); } }) { DisplayCategory = Consts.FILTERS_WORKFLOW_CATEGORY, SortOrder = ct++.ToString(), // Sort in the order we have built up the filters }; _dynamicWorkflowActions.Add(action); } }
public void NavigateBackToOverview() { ShareProxy = null; IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_SHARES_OVERVIEW, false); }
private void ShowSingleChannelGuide(IChannel channel) { if (channel == null || CurrentChannelGroup == null) { return; } int channelId = channel.ChannelId; int groupId = CurrentChannelGroup.ChannelGroupId; IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); NavigationContextConfig navigationContextConfig = new NavigationContextConfig(); navigationContextConfig.AdditionalContextVariables = new Dictionary <string, object>(); navigationContextConfig.AdditionalContextVariables[SlimTvClientModel.KEY_CHANNEL_ID] = channelId; navigationContextConfig.AdditionalContextVariables[SlimTvClientModel.KEY_GROUP_ID] = groupId; Guid stateId = new Guid("A40F05BB-022E-4247-8BEE-16EB3E0B39C5"); if (workflowManager.IsAnyStateContainedInNavigationStack(new Guid[] { stateId })) { workflowManager.NavigatePopToState(stateId, false); } else { workflowManager.NavigatePush(stateId, navigationContextConfig); } }
/// <summary> /// Gets a list of available screens ("filters") of the current <see cref="NavigationData"/>. This method can return either filtering screens that are showing /// results of predefined query (<paramref name="onlySearchScreens"/>=<c>false</c>), or custom search screens that allow user input for searching (<paramref name="onlySearchScreens"/>=<c>true</c>). /// </summary> /// <param name="onlySearchScreens"><c>true</c> to return only search screens.</param> /// <returns>List of workflow actions</returns> public IList <WorkflowAction> GetWorkflowActions(bool onlySearchScreens = false) { // Inherit the actions of the parent if necessary. This is particularly the case if this is a sub-view // as we need to ensure that the base/parent view is updated when switching screens as any sub-views // will be popped from the navigation stack. if (_inheritActions) { return(Parent != null?Parent.GetWorkflowActions(onlySearchScreens) : new List <WorkflowAction>()); } IList <WorkflowAction> actions = new List <WorkflowAction>(_availableScreens.Count); int ct = 0; foreach (AbstractScreenData screen in _availableScreens) { if (onlySearchScreens && !(screen is AbstractSearchScreenData)) { continue; } if (!onlySearchScreens && (screen is AbstractSearchScreenData)) { continue; } AbstractScreenData newScreen = screen; // Necessary to be used in closure WorkflowAction action = new MethodDelegateAction(Guid.NewGuid(), _navigationContextName + "->" + newScreen.MenuItemLabel, new Guid[] { _currentWorkflowStateId }, LocalizationHelper.CreateResourceString(newScreen.MenuItemLabel), () => { _currentScreenData.ReleaseScreenData(); _currentScreenData = newScreen; string parent = Parent == null ? _navigationContextName : Parent.CurrentScreenData.GetType().ToString(); // Do not save search screens as selection, they are only a "transient" state. if (!(newScreen is AbstractSearchScreenData)) { SaveScreenHierarchy(parent, newScreen.GetType().ToString()); } IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); // The last screen could have stepped into a deeper media navigation context when it had produced // sub views. So we first have to revert our workflow to the base workflow id before moving to the new screen. if (workflowManager.CurrentNavigationContext.WorkflowState.StateId == _baseWorkflowStateId) { // If we're already in the correct the state, update the screen manually _currentScreenData.CreateScreenData(this); SwitchToCurrentScreen(); } else { // WF-Manager updates the screen for us workflowManager.NavigatePopToState(_baseWorkflowStateId, false); } }) { DisplayCategory = Consts.FILTERS_WORKFLOW_CATEGORY, SortOrder = ct++.ToString(), // Sort in the order we have built up the filters }; actions.Add(action); } return(actions); }
public override void NavigateBackToOverview() { _emulatorProxy = null; IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(_enteredState, _enteredState != STATE_OVERVIEW); }
public void Select(ListItem item) { if (item == null) { return; } ICommand command = item.Command; if (command != null) { command.Execute(); } object obj; NavigationMode mode = NavigationMode.ExitPCWorkflow; if (item.AdditionalProperties.TryGetValue(Consts.KEY_NAVIGATION_MODE, out obj)) { mode = (NavigationMode)obj; } if (mode == NavigationMode.ExitPCWorkflow) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_PLAYER_CONFIGURATION_DIALOG, true); } }
public override void Execute() { bool isBrowseMode; string screenName; Guid currentWorkflowState; if (!GetRootState(out screenName, out isBrowseMode, out currentWorkflowState)) { return; } string oldScreen = null; if (isBrowseMode) { NavigationData.LoadScreenHierarchy(screenName + "_OLD", out oldScreen); } NavigationData.SaveScreenHierarchy(screenName, isBrowseMode ? oldScreen : Consts.USE_BROWSE_MODE, !isBrowseMode /* backup when switching to browse mode */); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.StartBatchUpdate(); workflowManager.NavigatePopToState(currentWorkflowState, true); workflowManager.NavigatePush(currentWorkflowState); workflowManager.EndBatchUpdate(); }
private void ShowHomeScreen(bool force) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); if (force || workflowManager.CurrentNavigationContext.WorkflowState.StateId != Consts.WF_STATE_ID_HOME_SCREEN) { workflowManager.NavigatePopToState(Consts.WF_STATE_ID_HOME_SCREEN, force); } }
public bool NavigateBackToOverview() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); if (!workflowManager.IsStateContainedInNavigationStack(Consts.WF_STATE_ID_PLAYLISTS_OVERVIEW) || workflowManager.CurrentNavigationContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYLISTS_OVERVIEW) { return(false); } workflowManager.NavigatePopToState(Consts.WF_STATE_ID_PLAYLISTS_OVERVIEW, false); return(true); }
private void NavigateToHome() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); if (workflowManager == null) { return; } if (workflowManager.CurrentNavigationContext.WorkflowState.StateId != HOME_STATE_ID) { workflowManager.NavigatePopToState(HOME_STATE_ID, false); } }
private static void Show(NavigationContextConfig context) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); Guid stateId = new Guid("3C6081CB-88DC-44A7-9E17-8D7BFE006EE5"); if (workflowManager.IsAnyStateContainedInNavigationStack(new Guid[] { stateId })) { workflowManager.NavigatePopToState(stateId, false); } else { workflowManager.NavigatePush(stateId, context); } }
private void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message) { if (message.ChannelName == PlaylistMessaging.CHANNEL) { PlaylistMessaging.MessageType messageType = (PlaylistMessaging.MessageType)message.MessageType; switch (messageType) { case PlaylistMessaging.MessageType.PlaylistUpdate: UpdatePlaylist(); break; case PlaylistMessaging.MessageType.CurrentItemChange: UpdateCurrentItem(); break; case PlaylistMessaging.MessageType.PropertiesChange: UpdateProperties(); break; } } else if (message.ChannelName == PlayerManagerMessaging.CHANNEL) { PlayerManagerMessaging.MessageType messageType = (PlayerManagerMessaging.MessageType)message.MessageType; switch (messageType) { case PlayerManagerMessaging.MessageType.PlayerSlotClosed: IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); ISystemStateService sss = ServiceRegistration.Get <ISystemStateService>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); if (pc == null && sss.CurrentState == SystemState.Running) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_SHOW_PLAYLIST, true); } break; // We don't need to track the PlayerSlotActivated or PlayerSlotsChanged messages, because all information // we need is contained in the CurrentPlayer information } } else if (message.ChannelName == PlayerContextManagerMessaging.CHANNEL) { PlayerContextManagerMessaging.MessageType messageType = (PlayerContextManagerMessaging.MessageType)message.MessageType; switch (messageType) { case PlayerContextManagerMessaging.MessageType.CurrentPlayerChanged: UpdatePlaylist(); break; } } }
private void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message) { if (message.ChannelName == PlaylistMessaging.CHANNEL) { PlaylistMessaging.MessageType messageType = (PlaylistMessaging.MessageType)message.MessageType; switch (messageType) { case PlaylistMessaging.MessageType.PlaylistUpdate: UpdatePlaylist(); break; case PlaylistMessaging.MessageType.PropertiesChange: UpdateProperties(); break; } } else if (message.ChannelName == PlayerManagerMessaging.CHANNEL) { PlayerManagerMessaging.MessageType messageType = (PlayerManagerMessaging.MessageType)message.MessageType; switch (messageType) { case PlayerManagerMessaging.MessageType.PlayerSlotClosed: IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); ISystemStateService sss = ServiceRegistration.Get <ISystemStateService>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); if (pc == null && sss.CurrentState == SystemState.Running) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_EDIT_PLAYLIST, true); } break; } } else if (message.ChannelName == PlayerContextManagerMessaging.CHANNEL) { PlayerContextManagerMessaging.MessageType messageType = (PlayerContextManagerMessaging.MessageType)message.MessageType; switch (messageType) { case PlayerContextManagerMessaging.MessageType.CurrentPlayerChanged: UpdatePlaylist(); break; } } }
/// <summary> /// Creates a schedule using the configured properties. /// </summary> public void CreateSchedule() { IChannel channel = Channel; DateTime startTime = StartTime; DateTime endTime = EndTime; ScheduleRecordingType recordingType = RecordingType; if (!CheckScheduleValid(channel, startTime, endTime)) { return; } ITvHandler tvHandler = ServiceRegistration.Get <ITvHandler>(); ISchedule schedule; bool result = tvHandler.ScheduleControl.CreateScheduleByTime(channel, startTime, endTime, recordingType, out schedule); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(STATE_MANUAL_SCHEDULE, true); }
private bool NavigateToHome() { try { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); if (workflowManager == null) { return(false); } if (workflowManager.CurrentNavigationContext.WorkflowState.StateId != HOME_STATE_ID) { workflowManager.NavigatePopToState(HOME_STATE_ID, false); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Warn("HomeMenuModel: Failed to navigate.", ex); return(false); } return(true); }
/// <summary> /// Creates a schedule using the configured properties. /// </summary> public async Task CreateSchedule() { IChannel channel = Channel; DateTime startTime = StartTime; DateTime endTime = EndTime; ScheduleRecordingType recordingType = RecordingType; if (!CheckScheduleValid(channel, startTime, endTime)) { return; } ITvHandler tvHandler = ServiceRegistration.Get <ITvHandler>(); var result = await tvHandler.ScheduleControl.CreateScheduleByTimeAsync(channel, startTime, endTime, recordingType); if (!result.Success) { ServiceRegistration.Get <ILogger>().Warn("SlimTvManualScheduleModel: Could not create schedule."); } IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(STATE_MANUAL_SCHEDULE, true); }
protected void LeaveCheckQueryPlayActionSingleItemState() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_CHECK_QUERY_PLAYACTION_SINGLE_ITEM, true); }
protected void LeaveCheckEditionsState() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_CHECK_EDITION, true); }
protected void LeaveCheckResumePlaybackSingleItemState() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_CHECK_RESUME_SINGLE_ITEM, true); }
protected void LeaveQueryAVTypeState() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_QUERY_AV_TYPE_CHECK_QUERY_PLAYACTION_MULTIPLE_ITEMS, true); }
protected static void WorkflowPopToState(Guid workflowStateId) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(workflowStateId, false); }