示例#1
0
 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);
   }
 }
示例#2
0
    /// <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)
    {
      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;
    }