Exemple #1
0
        // Run Test button
        private void buttonRunTest_Click(object sender, RoutedEventArgs e)
        {
            // Hide the Run Test button
            buttonRunTest.Visibility = System.Windows.Visibility.Hidden;

            // set the test Form
            pTest.SetFormAFlag(true == radioButtonFormA.IsChecked);

            // get values from other controls
            // Delay 3 or 2 Seconds
            int delayBetweenPairs = PasatTest.MIN_DELAY_BETWEEN_PAIRS;

            if (true == radioButton3seconds.IsChecked)
            {
                delayBetweenPairs = PasatTest.MAX_DELAY_BETWEEN_PAIRS;
            }

            pTest.SetDelayBetweenPairs(delayBetweenPairs);

            // If Practice, get number of tests from the Practice textbox
            pTest.SetPracticeTestFlag(true == radioButtonPractice.IsChecked);
            int numTests = 1;

            if (true == radioButtonPractice.IsChecked)
            {
                try
                {
                    //Console.WriteLine("Text in textbox1: " + PASATTestThread.mainWindow.textBox1.Text);
                    numTests = Int32.Parse(textBoxNumOfPracticeTests.Text);
                }
                catch
                {
                    numTests = PasatTest.MIN_NUM_PRACTICE_TESTS;
                }

                // TODO: use a spin control or parsing during user changes in Edit box to have these limits
                if (numTests < PasatTest.MIN_NUM_PRACTICE_TESTS)
                {
                    numTests = PasatTest.MIN_NUM_PRACTICE_TESTS;

                    // Change UI to show number of tests actually used
                    textBoxNumOfPracticeTests.Text = numTests.ToString();
                }

                if (PasatTest.MAX_NUM_PRACTICE_TESTS < numTests)
                {
                    numTests = PasatTest.MAX_NUM_PRACTICE_TESTS;

                    // Change UI to show number of tests actually used
                    textBoxNumOfPracticeTests.Text = numTests.ToString();
                }
            }
            else
            {
                numTests = PasatTest.DEFAULT_NUM_TESTS;
            }
            pTest.SetNumTests(numTests);

            pThread.PASATTestThreadInit(pTest);

            // Show estimated test time needed
            int    minutes, seconds;
            string estTime = pTest.GetTestTimeEstimate(out minutes, out seconds);

            textBlockEstTime.Text = estTime;

            //myMessageBox( "Before running test..." );

            // Set up to check for test completion every 1 Second
            pTest.SetTestDoneFlag(false);
            if (null == isDoneTimer)
            {
                isDoneTimer          = new Timer(1000); // Set up the timer for 1 Second
                isDoneTimer.Elapsed += new ElapsedEventHandler(CheckForDone);
            }
            isDoneTimer.Enabled = true; // Enable the timer

            pThread.RunTest();          // run the test

            //MessageBox.Show("After return from call to RunTest ...");
            //button1.Visibility = Visibility.Visible;
            //button1.UpdateLayout();
            //this.UpdateLayout();
        }
Exemple #2
0
    protected void RunTestOnClicked(object sender, System.EventArgs e)
    {
        //throw new System.NotImplementedException ();
        int numTests = 1;

        // Hide the Run Test button
        this.buttonRunTest.Visible = false;

        // Set test values from the controls

        // If Practice, get number of tests from the Practice spinbutton
        if (true == this.radiobuttonPractice.Active)
        {
            try
            {
                numTests = this.spinbuttonNumPractice.ValueAsInt;
            }
            catch
            {
                numTests = PasatTest.MIN_NUM_PRACTICE_TESTS;
            }

            if (numTests < PasatTest.MIN_NUM_PRACTICE_TESTS)
            {
                numTests = PasatTest.MIN_NUM_PRACTICE_TESTS;
            }

            if (PasatTest.MAX_NUM_PRACTICE_TESTS < numTests)
            {
                numTests = PasatTest.MAX_NUM_PRACTICE_TESTS;
            }
        }
        else
        {
            numTests = PasatTest.DEFAULT_NUM_TESTS;
        }
        pTest.SetNumTests(numTests);

        // get values from other controls
        // Delay 3 or 2 Seconds
        int delayBetweenPairs = PasatTest.MIN_DELAY_BETWEEN_PAIRS;

        if (true == this.radiobutton3seconds.Active)
        {
            delayBetweenPairs = PasatTest.MAX_DELAY_BETWEEN_PAIRS;
        }

        pTest.SetDelayBetweenPairs(delayBetweenPairs);

        // set the test Form
        pTest.SetFormAFlag(true == radiobuttonFormA.Active);

        pTest.SetPracticeTestFlag(true == radiobuttonPractice.Active);

        pThread.PASATTestThreadInit(pTest);

        // Show estimated test time needed
        int    minutes, seconds;
        string estTime = pTest.GetTestTimeEstimate(out minutes, out seconds);

        labelTimeEstimate.Text = estTime;

        // Set up to check for test completion every 1 Second
        pTest.SetTestDoneFlag(false);
        GLib.Timeout.Add(1000, new GLib.TimeoutHandler(CheckForDone));

        //myMessageBox( "Before running test..." );

        pThread.RunTest();          // run the test
    }