// check keypress and ignore anything that isn't a number
 void txtInput_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (CogTest.ValidateKeyPress() == false || e.KeyChar < 49 || e.KeyChar > 57)
     {
         e.Handled = true;
     }
 }
示例#2
0
 private void frmRaven_KeyPress(object sender, KeyPressEventArgs e)
 {
     // accept either 1-6 or 1-8
     if (this.testStatus != CogTest.TEST_DEMO && CogTest.ValidateKeyPress() == true)
     {
         if (e.KeyChar >= 49 && (e.KeyChar <= 54 || e.KeyChar <= 56 && lbl7.Visible == true))
         {
             processInput((e.KeyChar - 48) == answer);
         }
     }
 }
示例#3
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);
                }
            }
        }
示例#4
0
        private void frmSpeed_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (reactStopwatch.IsRunning && testStatus != CogTest.TEST_DEMO && CogTest.ValidateKeyPress() == true)
            {
                switch (e.KeyChar)
                {
                case (char)49:      // the '1' key
                    processInput(btnA.Text);
                    break;

                case (char)50:      // the '2' key
                    processInput(btnB.Text);
                    break;

                case (char)51:      // the '3' key
                    processInput(btnC.Text);
                    break;

                case (char)52:      // the '4' key
                    processInput(btnD.Text);
                    break;
                }
            }
        }