예제 #1
0
        /// <summary>
        /// This method does the actual loading of the fragment depending on current step.
        /// </summary>
        private void LoadFragment()
        {
            if (_currentFragmentType == null)
            {
                throw new InvalidOperationException("Cannot load fragment if there is CurrentFragmentType == null.");
            }

            // load the fragment needed
            CurrentFragment = Activator.CreateInstance(_currentFragmentType) as WizardStepFragment;

            if (CurrentFragment == null)
            {
                throw new Exception("Fragments used for steps in the wizard must inherit WizardStepFragment. Yours does not.");
            }


            if (!StepsHistory.ContainsKey(_currentStep))
            {
                StepsHistory.Add(_currentStep, CurrentFragment.GetType());
            }
            else
            {
                StepsHistory[_currentStep] = CurrentFragment.GetType();
            }

            if (!_serializedData.IsBlank())
            {
                RunOnUiThread(() => { CurrentFragment.SetData(_serializedData); });
            }

            // load the actual fragment needed
            if (!_isHidden)
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.frameContent, CurrentFragment, CurrentFragment.FragmentTag)
                .Commit();
            }


            this.SetButtonTitles();

            _fragmentButtons.SelectStep(_currentStep);
            HideKeyboard(true);
        }
예제 #2
0
        /// <summary>
        /// This method will initiate going back or forward depending on boolean given.
        /// </summary>
        /// <param name="goNext">True if go next, otherwise pass false</param>
        public void Go(bool goNext)
        {
            _serializedData = CurrentFragment.GetData();

            bool goPrevious = !goNext;

            if (goNext)
            {
                if (!CurrentFragment.IsLastStep)
                {
                    _currentStep++;
                }

                _currentFragmentType = CurrentFragment.GetNextFragment();
            }
            else
            {
                _currentStep--;
                if (!StepsHistory.ContainsKey(_currentStep))
                {
                    return;
                }

                _currentFragmentType = StepsHistory[_currentStep];
            }

            // if the final step, finish the wizard, otherwise load fragment
            if (!CurrentFragment.IsLastStep || goPrevious)
            {
                LoadFragment();
            }
            else
            {
                CurrentFragment.FinishWizard();
                WizardFinished = true;
            }
        }
예제 #3
0
 public void AddLog(string message)
 {
     StepsHistory.Items.Add(message);
     StepsHistory.ScrollIntoView(message);
 }