示例#1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            // at this point, the only way they could be wrong that we didn't catch in btnClick
            // is if they didn't finish the sequence

            // don't do anything if we are in demo mode
            if (this.testStatus == CogTest.TEST_DEMO)
            {
                return;
            }

            if (curIndex < answerSeq.Count)
            {
                correct = false;
            }

            setEnabledStatus(false);

            if (corsi.nextTrial(correct, ref answerSeq) == true)
            {
                // there is another trial - run it
                System.Threading.Thread.Sleep(500);     // wait about 500 ms between trials
                showNextTrial();
            }
            else
            {
                // end of test
                if (this.testStatus == CogTest.TEST_OFFICIAL)
                {
                    corsi.finishTest();
                }
                CogTest.closeForm(this);
            }
        }
示例#2
0
        /// <summary>
        /// Displays a warning dialog box if the user triggered the FormClosing event.
        /// To close the form normally, use CogTest.closeForm()
        /// </summary>
        public static void FormClosing(object sender, FormClosingEventArgs e)
        {
            Form form = (Form)sender;

            enterStopwatch.Reset();
            if (form.DialogResult == DialogResult.Cancel)
            {
                DialogResult result = MessageBox.Show("Are you sure you want to quit the program early?" +
                                                      Environment.NewLine + "The data for each of the completed tests has already been saved," +
                                                      Environment.NewLine + "but all of the data for the current test will be lost.",
                                                      "Cognitive Assessments - Quit Program", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                                      MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    // we have to sleep for a second before closing or Environment.Exit throws the following error:
                    // "Cannot execute operation because current thread is in a spin, wait, or sleep operation
                    CogTest.closeForm(form);
                    Environment.Exit(1);
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
示例#3
0
 // check the official test stopwatch every second
 // quit early if the test takes longer than 10 minutes
 private void testTimer_Tick(object sender, EventArgs e)
 {
     if (stopwatch.ElapsedMilliseconds >= 600000)
     {
         testTimer.Stop();
         saveResultsFile();
         CogTest.closeForm(this);
     }
 }
示例#4
0
 /// <summary>
 /// Closes form after a double tap on the enter key.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 static void KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (enterStopwatch.IsRunning && enterStopwatch.ElapsedMilliseconds <= DOUBLE_ENTER_INTVL)
         {
             // successful double-tap on the enter key - close form
             CogTest.closeForm(currentSplashForm);
         }
         else
         {
             // first enter key pressed - start stopwatch to wait for second press
             enterStopwatch.Reset();
             enterStopwatch.Start();
         }
     }
 }
示例#5
0
 /* Timer tick - either the practice test ended, or it's time to check the official test stopwatch.
  * A form timer is not used for the official test because form timers aren't very accurate
  * for long intervals (more than a minute). */
 private void formTimer_Tick(object sender, EventArgs e)
 {
     if (this.testStatus == CogTest.TEST_PRACTICE)
     {
         if (testStopwatch.ElapsedMilliseconds >= PRACTICE_DUARTION)
         {
             // practice test ended
             CogTest.closeForm(this);
         }
     }
     else if (this.testStatus == CogTest.TEST_OFFICIAL)
     {
         if (testStopwatch.ElapsedMilliseconds >= OFFICIAL_DURATION)
         {
             // regular test ended
             test.finish();
             CogTest.closeForm(this);
         }
     }
 }
        // pick a new number to display
        private void nextNumber()
        {
            if (numFinished == MAX_NUMBERS)
            {
                // finished all of the trials - close form
                CogTest.closeForm(this);
            }
            else
            {
                string newDigit;
                do
                {
                    newDigit = randGen.Next(1, 10).ToString();
                } while (newDigit == txtInput.Text);

                lblDisplay.Text  = newDigit;
                txtInput.Enabled = true;
                txtInput.Text    = "";
                txtInput.Focus();
            }
        }
示例#7
0
        // process a keypress during the test
        private void frmStroop_KeyPress(object sender, KeyPressEventArgs e)
        {
            // only allow non-numpad number keys to be pressed, and only while a test is running
            if (e.KeyChar >= 49 && e.KeyChar <= 57 && stopwatch.IsRunning && CogTest.ValidateKeyPress() == true)
            {
                stopwatch.Stop();
                int elapsedTime = (int)stopwatch.ElapsedMilliseconds;
                stopwatch.Reset();
                if (curTest.processTrial(e.KeyChar - 48, elapsedTime) == true)
                {
                    // there is another trial to run
                    showFixation();
                }
                else if (curTest.processBlock() == true)
                {
                    // advance to the next block after a 30 second break

                    lblDisplay.BorderStyle = BorderStyle.None;
                    lblDisplay.Text        = "00:30";
                    lblDisplay.Font        = fntNormal;

                    break_time          = 30;
                    breakTimer.Interval = 1000;
                    breakTimer.Start();
                }
                else
                {
                    // we have reached the end of the current test

                    if (testStatus == CogTest.TEST_OFFICIAL)
                    {
                        // save the data only if it is an official test
                        curTest.finish();
                    }

                    CogTest.closeForm(this);
                }
            }
        }
示例#8
0
        private void processInput(bool correct)
        {
            // double clicks (within 350 ms) are ignored
            if (doublePress == true)
            {
                return;
            }

            if (this.testStatus == CogTest.TEST_OFFICIAL)
            {
                if (correct == true)
                {
                    numCorrect++;
                }
            }

            numUnfinished--;
            questions.RemoveAt(0);

            if (numUnfinished == 0)
            {
                // finished with the test
                if (this.testStatus == CogTest.TEST_OFFICIAL)
                {
                    saveResultsFile();
                }
                CogTest.closeForm(this);
            }
            else
            {
                // load the next question
                showNextQuestion();
                doublePress = true;
                clickTimer.Start();
                picBox.Focus();     // focus away from the buttons
            }
        }
 private void btnContinue_Click(object sender, EventArgs e)
 {
     CogTest.closeForm(this);
 }
示例#10
0
 // close break screen after BREAK_TIME milliseconds
 private void breakTimer_Tick(object sender, EventArgs e)
 {
     CogTest.closeForm(this);
 }