Ejemplo n.º 1
0
        private void playAudio()
        {
            string currentAudio = audioList[audioCounter];

            currentStimuli[1] = StrList.outPutItemName(currentAudio);
            currentLists[1]   = executingTest.ProgramInUse.getAudioListFile().ListName;

            Player.SoundLocation = currentAudio;
            audioCounter++;
            if (audioCounter == audioList.Length)
            {
                audioCounter = 0;
            }
            Player.Play();
        }
Ejemplo n.º 2
0
 // place current stimulus in imagebox
 private void drawImage()
 {
     if (imageCounter == imageList.Count())
     {
         imageCounter = 0;
     }
     if (currentTest.ProgramInUse.RotateImage != 0)
     {
         imgPictureBox.Image = RotateImage(imageList[imageCounter], currentTest.ProgramInUse.RotateImage);
     }
     else
     {
         imgPictureBox.Image = Image.FromFile(imageList[imageCounter]);
     }
     currentStimulus = StrList.outPutItemName(imageList[imageCounter]);
     imageCounter++;
 }
Ejemplo n.º 3
0
        private void drawImage()
        {
            imgPictureBox = ExpositionController.InitializeImageBox(executingTest.ProgramInUse.StimuluSize, Image.FromFile(imagesList[imageCounter]),
                                                                    executingTest.ProgramInUse.ExpandImage, this);
            Point screenPosition = ScreenPosition(imgPictureBox.Size);

            imgPictureBox.Location = screenPosition;

            currentStimuli[0] = StrList.outPutItemName(imagesList[imageCounter]);
            currentLists[0]   = executingTest.ProgramInUse.getImageListFile().ListName;

            imageCounter++;
            if (imageCounter == imagesList.Length)
            {
                imageCounter = 0;
            }
            expositionBW.ReportProgress(currentExposition / executingTest.ProgramInUse.NumExpositions * 100, imgPictureBox);
        }
Ejemplo n.º 4
0
        private async Task startImageExposition()
        {
            cts = new CancellationTokenSource();
            try
            {
                configureImagePictureBox();
                outputContent     = new List <string>();
                wordLabel.Visible = false;
                // restart elapsed miliseconds
                elapsedTime = 0;
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                await Task.Delay(currentTest.ProgramInUse.IntervalTime, cts.Token);

                // beginAudio
                if (currentTest.ProgramInUse.AudioCapture)
                {
                    startRecordingAudio();
                }

                for (int counter = 0; counter < currentTest.ProgramInUse.NumExpositions && runExposition; counter++)
                {
                    imgPictureBox.Visible = false;
                    subtitleLabel.Visible = false;
                    await intervalOrFixPoint(currentTest.ProgramInUse, cts.Token);

                    drawImage();

                    if (currentTest.ProgramInUse.ExpositionType == "imgaud")
                    {
                        playAudio();
                    }

                    elapsedTime = stopwatch.ElapsedMilliseconds;
                    SendKeys.SendWait(currentTest.Mark.ToString()); //sending event to neuronspectrum

                    imgPictureBox.Visible = true;

                    showSubtitle();


                    currentTest.writeLineOutputResult(currentStimulus, "false",
                                                      counter + 1, outputContent, elapsedTime,
                                                      StrList.outPutItemName(currentAudio));

                    await Task.Delay(currentTest.ProgramInUse.ExpositionTime, cts.Token);

                    Player.Stop();
                }


                imgPictureBox.Visible = false;
                subtitleLabel.Visible = false;


                await Task.Delay(currentTest.ProgramInUse.IntervalTime, cts.Token);

                // beginAudio
                if (currentTest.ProgramInUse.AudioCapture)
                {
                    stopRecordingAudio();
                }
            }
            catch (TaskCanceledException)
            {
                Player.Stop();
                if (currentTest.ProgramInUse.AudioCapture)
                {
                    stopRecordingAudio();
                }
                finishExposition();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            cts = null;
        }