コード例 #1
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            startButton.Name = "Test Running...";
            Thread.Sleep(10);


            // startButton.Visibility = System.Windows.Visibility.Collapsed;  // was .Hidden; for Win PC
            startButton.IsEnabled = false;

            // These are fixed for now
            // TODO  add way to change test parameters
            //
            pTest.SetNumTests(PasatTest.MIN_NUM_PRACTICE_TESTS);

            pTest.SetDelayBetweenPairs(PasatTest.MIN_DELAY_BETWEEN_PAIRS);

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

            pTest.SetPracticeTestFlag(true);

            pThread.PASATTestThreadInit(pTest);

            pTest.SetTestDoneFlag(false);

            // Create Timer to simulate the XNA game loop (SoundEffect class is from the XNA Framework)
            if (null == gameTimer)
            {
                gameTimer = new GameTimer();
                gameTimer.UpdateInterval = TimeSpan.FromMilliseconds(33);

                // Call FrameworkDispatcher.Update to update the XNA Framework internals.
                gameTimer.Update += delegate { try { CheckForDone(); } catch { } };
            }

            // Start the GameTimer running.
            gameTimer.Start();

            // Prime the pump or we'll get an exception.
            FrameworkDispatcher.Update();

            pThread.RunTest();  // run the test

/* KEEP this as comment for now...
 * currently using common approach to create/start a thread: see RunTest
 *
 *          // IF the worker thread is idle start it async, need to call bw.CancelAsync() later to stop test early
 *          if (bw.IsBusy != true)
 *          {
 *              bw.RunWorkerAsync();
 *          }
 */
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: jbyrnescu/PASAT
        // 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();
        }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: jbyrnescu/PASAT
    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
    }