Пример #1
0
//----------------------------------------------------------------------------
//                                                                TakeNextStep
//----------------------------------------------------------------------------

/*
 *   TakeNextStep() controls progress through the several steps of deployment.
 *   This function can be called by manually clicking on a Next button, or
 *   directly from within a function to perform an automatic step forward.
 *
 *   stepDirection allows for more complex future forms which allow back
 *   stepping. However, at the moment it is not actively used.
 *
 *   Returns true if a change in the step counter was performed.
 */
        private Boolean TakeNextStep(EnumStep stepDirection)
        {
            WORD wStep;

// Move to next step
            wStep = mwStep;
// Distribute on direction
            switch (stepDirection)
            {
            case EnumStep.Next:
                // Attempt to move to next step
                wStep++;
                // Ignore if no forward steps remain
                if (wStep >= (WORD)EnumStep.NoMoreSteps)
                {
                    return(false);
                }
                break;

            case EnumStep.Back:
                // Attempt to move to next step
                wStep--;
                // Ignore if no backward steps remain
                if (wStep == 0)
                {
                    return(false);
                }
                break;
            }
// Prepare form for the next step
            mwStep   = wStep;
            meAction = EnumFormAction.DoStep;
            return(true);
        }
 /// <summary>
 /// The on step async.
 /// </summary>
 /// <param name="stepName">
 /// The step name.
 /// </param>
 /// <returns>
 /// The <see cref="Task"/>.
 /// </returns>
 public override async Task OnStepAsync(object stepName)
 {
     this._CurrentEnumStep = (EnumStep)Enum.Parse(typeof(EnumStep), stepName.ToString());
     switch (this._CurrentEnumStep)
     {
         case EnumStep.Start:
             this.SetBusyAction(LoadingText);
             this.ActiveViewModel = this;
             this.TrancheSummary = await FundingFunctions.GetAllTranchesAsync();
             
             if (this.NewTrancheViewModel == null)
             { 
                 this.NewTrancheViewModel = new NewTrancheViewModel(this); 
             }
             if (this.ExistingTrancheViewModel == null)
             {
                 this.ExistingTrancheViewModel = new ExistingTrancheViewModel(this);
             }
             this.ResetBusyAction();
             break;
         case EnumStep.SelectTranche:
             this.SetBusyAction(LoadingText);
             await this.ExistingTrancheViewModel.SetTrancheIdAsync(this.SelectedTranche.TrancheId);
             this.FundingDetails = this.ExistingTrancheViewModel;
             this.FundingDetails.ListErrorHyperlink.Clear();
             this.FundingDetails.IsConfirmError = false;
             this.ActiveViewModel = this.FundingDetails;
             await this.FundingDetails.OnStepAsync(ExistingTrancheViewModel.EnumStep.TrancheSelected);
             this.ResetBusyAction();
             this.RaiseActionsWhenChangeStep(EnumScreen.FundingSummary, EnumStep.SelectTranche, this.SelectedTranche);
             break;
         case EnumStep.CreateNew:
             this.RaiseActionsWhenChangeStep(EnumScreen.FundingSummary,EnumStep.CreateNew);
             this.FundingDetails = this.NewTrancheViewModel;
             this.FundingDetails.IsConfirmError = false;
             await this.NewTrancheViewModel.OnStepAsync(EnumStep.Start);
             this.ActiveViewModel = this.FundingDetails;
             break;
         case EnumStep.TrancheSaved:
             this.SelectedTranche.FunderName = this.FundingDetails.SelectedFunder.Text;
             break;
         case EnumStep.TrancheAdded:
             this.TrancheSummary = await FundingFunctions.GetAllTranchesAsync();
             await this.ExistingTrancheViewModel.SetTrancheIdAsync(this.AddedTrancheId);
             this._SelectedTranche = this.TrancheSummary.FirstOrDefault(x => x.TrancheId == this.AddedTrancheId);
             this.FundingDetails = this.ExistingTrancheViewModel;
             this.ActiveViewModel = this.FundingDetails;
             await this.FundingDetails.OnStepAsync(ExistingTrancheViewModel.EnumStep.TrancheSelected);
             break;
     }
     this.SetActionCommandsAsync();
     this.OnStepChanged(_CurrentEnumStep.ToString());
 }