Exemplo n.º 1
0
        private void BuildAndRun(object state)
        {
            //if no file opened
            if (Interactivity.codes.CurrentFile == null)
            {
                return;
            }

            //clear and initiate
            Interactivity.codes.BeginInvoke((MethodInvoker) delegate
            {
                ClearOutputFile();             //clear output file
                saveInputOutputData();         //save input output data
                saveToolButton.PerformClick(); //save code
                codeTextBox.ClearHints();      //clear hints
                compilerOutput.Clear();        //clear prev compiler report
                compileToolButton.Enabled   = false;
                buildRunToolButton.Enabled  = false;
                runtestToolButton.Enabled   = false;
                forceStopToolButton.Enabled = true;
                //show compiler output
                if (compilerOutputIsHidden)
                {
                    ToggleCompilerOutput();
                }
            });

            //run task
            bool ok = CodeCompiler.BuildAndRun((BuildRunType)state,
                                               CurrentFile, SelectedPNUM, RunTimeLimit);


            //re-enable all data
            Interactivity.codes.BeginInvoke((MethodInvoker) delegate
            {
                //enable the build and run buttons
                compileToolButton.Enabled   = true;
                buildRunToolButton.Enabled  = true;
                forceStopToolButton.Enabled = false;
                //if no problem is selected do not enable runtest button
                runtestToolButton.Enabled = (SelectedPNUM != -1);
                //go to end of output
                compilerOutput.GoEnd();
                //wait a little before processing message data
                Thread.Sleep(100);
                this.BeginInvoke((MethodInvoker) delegate { ProcessErrorData(); });
                //if no error and runtest
                if ((BuildRunType)state == BuildRunType.RunTest && ok)
                {
                    tabControl1.SelectedTab           = ioTAB;
                    inputOutputTabControl.SelectedTab = inputTab;
                }
            });
        }
Exemplo n.º 2
0
        //
        // Build And Run Code
        //
        public static bool BuildAndRun(BuildRunType state, FileInfo currentProblem, long pnum = -1, double timelimit = 3000)
        {
            if (IsRunning)
            {
                return(false);
            }

            IsRunning          = true;
            cancelationPending = false;

            CurrentProblem = currentProblem;
            SelectedPNUM   = pnum;
            RunTimeLimit   = timelimit;

            try
            {
                //type of task to be done
                bool buildonly = (state == BuildRunType.BuildOnly);
                bool runtest   = (state == BuildRunType.RunTest);

                //compile task
                CodeCompiler.StartBuildTask();

                //run builded file
                if (!buildonly)
                {
                    CodeCompiler.StartRunTask(runtest);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Add(ex.Message, "Codes|BuildAndRun()");
                ReportCompileStatus(ex.Message + "\n", HighlightSyntax.CommentStyle);
                return(false);
            }
            finally
            {
                IsRunning = false;
            }
        }
Exemplo n.º 3
0
 private void forceStopToolButton_Click(object sender, EventArgs e)
 {
     CodeCompiler.ForceStopTask();
 }