示例#1
0
        private void Runner_ExecutionStateChanged(object sender, ExecutionStateChangedEventArgs e)
        {
            App.Current.Dispatcher.Invoke(() =>
            {
                switch (e.ExecutionState)
                {
                case ExecutionState.Stopped:
                    ProgramCode.HighlightedLineNumber = 0;
                    ProgramInteraction.HideInputPrompt();
                    break;

                case ExecutionState.Paused:
                    if (SingleStepMode)
                    {
                        ProgramCode.HighlightedLineNumber = runner.LineNumber;
                        ProgramInteraction.HideInputPrompt();
                    }
                    else
                    {
                        // Want to run at full speed
                        runner.ExecuteNextLine();
                    }
                    break;

                case ExecutionState.Running:
                    if (SingleStepMode)
                    {
                        ProgramCode.HighlightedLineNumber = 0;
                        ProgramInteraction.HideInputPrompt();
                    }
                    break;

                case ExecutionState.WaitingForInput:
                    ProgramInteraction.ShowInputPrompt(!string.IsNullOrWhiteSpace(runner.Prompt) ? runner.Prompt : "Please enter your response:");
                    if (SingleStepMode)
                    {
                        ProgramCode.HighlightedLineNumber = runner.LineNumber;
                    }
                    break;
                }

                OnPropertyChanged(nameof(ExecutionState));
                GoCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
            });
        }
示例#2
0
        private void ProgramInteraction_Input(object sender, InputEventArgs e)
        {
            // The user has sumbitted an answer to the interactive input prompt
            // So hide the input box
            ProgramInteraction.HideInputPrompt();

            // Show the original prompt (if any)
            if (!string.IsNullOrWhiteSpace(runner.Prompt))
            {
                ProgramInteraction.OutputText(runner.Prompt.Trim() + " ");
            }

            // Show the user's response
            ProgramInteraction.OutputText(e.Answer + Environment.NewLine);

            // Submit the user's answer to the Python program, so it can continue
            runner.SubmitInput(e.Answer);
        }