Beispiel #1
0
        /// <summary>
        /// Ends the current help session (cannot be reversed)
        /// </summary>
        public void Abandon()
        {
            if (_help == null)
            {
                return;
            }

            if (HostControl.InvokeRequired)
            {
                HostControl.Invoke(new MethodInvoker(Abandon));
                return;
            }
            ProgressProvider.Completed(this);
            _help.Close();
            _help = null;
        }
Beispiel #2
0
        public void ShowStage(HelpStage stage)
        {
            //Abandon must have already been called
            if (_help == null)
            {
                return;
            }

            if (HostControl.InvokeRequired)
            {
                HostControl.Invoke(new MethodInvoker(() => ShowStage(stage)));
                return;
            }

            CurrentStage = stage;

            var helpBox = _help.ShowStage(this, CurrentStage);

            helpBox.OptionTaken += () => ShowStage(CurrentStage.OptionDestination);

            var t = stage.Await(_cancellationTokenSource.Token);

            t.ContinueWith(r =>
            {
                if (r.IsFaulted || r.IsCanceled)
                {
                    Abandon();
                }
                else
                {
                    try
                    {
                        if (r.Result)
                        {
                            ShowNextStageOrClose();
                        }
                    }
                    catch (Exception)
                    {
                        Abandon();
                    }
                }
            });
        }
Beispiel #3
0
        public bool ShowNextStageOrClose()
        {
            //Abandon must have already been called
            if (_help == null)
            {
                return(false);
            }

            if (HostControl.InvokeRequired)
            {
                return((bool)HostControl.Invoke(new Func <bool>(ShowNextStageOrClose)));
            }

            //if there is a next stage and help hasn't been closed
            if (CurrentStage != null && CurrentStage.Next != null && !_helpClosed)
            {
                ShowStage(CurrentStage.Next);
                return(true);
            }

            _help.Close();
            return(false);
        }