Пример #1
0
        private void openFilesForEdition()
        {
            try
            {
                FormDefine defineFilePath = new FormDefine(LocRM.GetString("wordList", currentCulture), FileManipulation._listFolderName, "lst", "_words_color", true, false);
                var        result         = defineFilePath.ShowDialog();

                if (result == DialogResult.OK)
                {
                    isListNameValid = true;
                    string fileName = defineFilePath.ReturnValue;

                    if (fileName == "")
                    {
                        isListNameValid = false;
                        return;
                    }

                    fileName             = fileName.Remove(fileName.Length - 6);
                    listNameTextBox.Text = fileName;

                    string wFile = FileManipulation._listFolderName + "/" + fileName + "_words.lst";
                    string cFile = FileManipulation._listFolderName + "/" + fileName + "_color.lst";
                    if (!File.Exists(wFile) && !File.Exists(cFile))
                    {
                        return;
                    }
                    if (File.Exists(wFile))
                    {
                        string[] wordsArray = StrList.readListFile(wFile);
                        foreach (string word in wordsArray)
                        {
                            wordsList.Add(word);
                        }
                        wordsListCheckBox.Checked = true;
                    }
                    if (File.Exists(cFile))
                    {
                        string[] colorsArray = StrList.readListFile(cFile);
                        foreach (string color in colorsArray)
                        {
                            colorsList.Add(color);
                        }
                        colorsListCheckBox.Checked = true;
                    }
                    addItems();
                }
                else
                {
                    wordsListCheckBox.Checked  = true;
                    colorsListCheckBox.Checked = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
 public void ReadStandardWordListTest()
 {
     string[] expected = wordList;
     string[] actual   = StrList.readListFile(listsPath + "padrao_words.lst");
     Assert.AreEqual(expected[0], actual[0]);
     Assert.AreEqual(expected[1], actual[1]);
     Assert.AreEqual(expected[2], actual[2]);
     Assert.AreEqual(expected[3], actual[3]);
 }
Пример #3
0
        private void openFilesForEdition(string filePath)
        {
            try
            {
                FormDefine defineFilePath = new FormDefine("Listas de Palavras: ", filePath, "lst", "_words_color", true);
                var        result         = defineFilePath.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string fileName = defineFilePath.ReturnValue;
                    fileName             = fileName.Remove(fileName.Length - 6);
                    listNameTextBox.Text = fileName;

                    string wFile = filePath + "/" + fileName + "_words.lst";
                    string cFile = filePath + "/" + fileName + "_color.lst";

                    if (File.Exists(wFile))
                    {
                        string[] wordsArray = StrList.readListFile(wFile);
                        foreach (string word in wordsArray)
                        {
                            wordsList.Add(word);
                        }
                        wordsListCheckBox.Checked = true;
                    }
                    if (File.Exists(cFile))
                    {
                        string[] colorsArray = StrList.readListFile(cFile);
                        foreach (string color in colorsArray)
                        {
                            colorsList.Add(color);
                        }
                        colorsListCheckBox.Checked = true;
                    }
                    checkTypeOfList();
                    numberItens.Text = wordsDataGridView.RowCount.ToString();
                }
                else
                {
                    wordsListCheckBox.Checked  = true;
                    colorsListCheckBox.Checked = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #4
0
 private void configureSubtitle()
 {
     string[] subtitlesArray = null;
     if (currentTest.ProgramInUse.SubtitleShow)
     {
         subtitlesArray = StrList.readListFile(defaultFolderPath + "/Lst/" + currentTest.ProgramInUse.SubtitlesListFile);
         if (currentTest.ProgramInUse.SubtitleColor.ToLower() != "false")
         {
             subtitleLabel.ForeColor = ColorTranslator.FromHtml(currentTest.ProgramInUse.SubtitleColor);
         }
         else
         {
             subtitleLabel.ForeColor = Color.Black;
         }
         subtitleLabel.Enabled = true;
         subtitleLabel.Left    = (this.ClientSize.Width - subtitleLabel.Width) / 2; // centraliza label da palavra
         subtitleLabel.Top     = (imgPictureBox.Bottom + 50);
     }
     subtitleList = subtitlesArray;
 }
Пример #5
0
 private string[] configureSubtitle()
 {
     string[] subtitlesArray = null;
     if (programInUse.SubtitleShow)
     {
         subtitlesArray = StrList.readListFile(path + "/lst/" + programInUse.SubtitlesListFile);
         if (programInUse.SubtitleColor.ToLower() != "false")
         {
             subtitleLabel.ForeColor = ColorTranslator.FromHtml(programInUse.SubtitleColor);
         }
         else
         {
             subtitleLabel.ForeColor = Color.Black;
         }
         subtitleLabel.Enabled = true;
         subtitleLabel.Left    = (this.ClientSize.Width - subtitleLabel.Width) / 2; // centraliza label da palavra
         subtitleLabel.Top     = (imgPictureBox.Bottom + 50);
     }
     return(subtitlesArray);
 }
Пример #6
0
        private async Task startImageExposition() // inicia exposição de imagem
        {
            cts = new CancellationTokenSource();
            int j, subtitleCounter = 0;
            int arrayCounter = 0;

            string[] labelText       = null, imageDirs = null, audioDirs = null, subtitlesArray = null;
            string   actualImagePath = "";
            string   audioDetail     = "false";

            try
            {
                BackColor           = Color.White;
                wordLabel.ForeColor = Color.Red;


                if (programInUse.ExpandImage)
                {
                    imgPictureBox.Dock = DockStyle.Fill;
                }
                else
                {
                    imgPictureBox.Dock = DockStyle.None;
                }

                imageDirs = StroopProgram.readDirListFile(path + "/lst/" + programInUse.ImagesListFile); // auxiliar recebe o vetor original
                if (programInUse.ExpositionRandom)                                                       // se exposição aleatória, randomiza itens de acordo com o numero de estimulos
                {
                    imageDirs = ExpositionController.shuffleArray(imageDirs, programInUse.NumExpositions, 3);
                }

                subtitlesArray = configureSubtitle();


                if (programInUse.AudioListFile != "false")
                {
                    audioDirs = StroopProgram.readDirListFile(path + "/lst/" + programInUse.AudioListFile);
                    if (programInUse.ExpositionRandom)
                    {
                        audioDirs = ExpositionController.shuffleArray(audioDirs, programInUse.NumExpositions, 6);
                    }
                }
                if (programInUse.WordsListFile.ToLower() != "false")
                {
                    labelText = StrList.readListFile(path + "/lst/" + programInUse.WordsListFile);
                }

                await showInstructions(programInUse, cts.Token); // Apresenta instruções se houver

                outputContent = new List <string>();

                while (true)
                {
                    changeBackgroundColor(programInUse, true); // muda cor de fundo se houver parametro
                    imgPictureBox.BackColor = BackColor;

                    elapsedTime  = 0; // zera tempo em milissegundos decorrido
                    j            = 0; subtitleCounter = 0;
                    arrayCounter = 0;
                    var       audioCounter = 0;
                    Stopwatch stopwatch    = new Stopwatch();
                    stopwatch.Start();
                    await Task.Delay(programInUse.IntervalTime, cts.Token);

                    string printCount = "";
                    // beginAudio
                    if (programInUse.AudioCapture)
                    {
                        startRecordingAudio();
                    }                                                         // inicia gravação áudio
                    // endAudio

                    if (programInUse.ExpositionType == "imgtxt")
                    {
                        for (int counter = 0; counter < programInUse.NumExpositions; counter++) // AQUI ver estimulo -> palavra ou imagem como um só e ter intervalo separado
                        {
                            if (counter < 10)                                                   // contador p/ arquivo de audio
                            {
                                printCount = "0" + counter.ToString();
                            }
                            else
                            {
                                printCount = counter.ToString();
                            }


                            imgPictureBox.Visible = false;
                            wordLabel.Visible     = false;
                            subtitleLabel.Visible = false;
                            await intervalOrFixPoint(programInUse, cts.Token);

                            if (arrayCounter == imageDirs.Count())
                            {
                                arrayCounter = 0;
                            }
                            if (programInUse.RotateImage != 0)
                            {
                                imgPictureBox.Image = RotateImage(imageDirs[arrayCounter], programInUse.RotateImage);
                            }
                            else
                            {
                                imgPictureBox.Image = Image.FromFile(imageDirs[arrayCounter]);
                            }

                            elapsedTime = stopwatch.ElapsedMilliseconds; // grava tempo decorrido
                            SendKeys.SendWait("=");
                            imgPictureBox.Visible = true;
                            if (programInUse.SubtitleShow)
                            {
                                subtitleCounter = showSubtitle(subtitleCounter, subtitlesArray);
                            }
                            wordLabel.Visible = false;
                            actualImagePath   = Path.GetFileName(imageDirs[arrayCounter].ToString());
                            arrayCounter++;


                            StroopProgram.writeLineOutput(programInUse, actualImagePath, "false", counter + 1, outputContent, elapsedTime, "img", audioDetail);

                            await Task.Delay(programInUse.ExpositionTime, cts.Token);

                            imgPictureBox.Visible = false;
                            wordLabel.Visible     = false;

                            await Task.Delay(programInUse.DelayTime, cts.Token);

                            if (programInUse.WordsListFile.ToLower() != "false") // se tiver palavras intercala elas com a imagem
                            {
                                if (j == labelText.Count() - 1)
                                {
                                    j = 0;
                                }
                                wordLabel.Text = labelText[j];


                                elapsedTime = stopwatch.ElapsedMilliseconds; // grava tempo decorrido
                                SendKeys.SendWait("=");
                                imgPictureBox.Visible = false;
                                subtitleLabel.Visible = false;
                                wordLabel.ForeColor   = ColorTranslator.FromHtml(programInUse.WordColor);
                                wordLabel.Visible     = true;
                                if (programInUse.SubtitleShow)
                                {
                                    subtitleCounter = showSubtitle(subtitleCounter, subtitlesArray);
                                }
                                actualImagePath = wordLabel.Text;
                                j++;

                                StroopProgram.writeLineOutput(programInUse, actualImagePath, "false", counter + 1, outputContent, elapsedTime, "txt", audioDetail);

                                await Task.Delay(programInUse.ExpositionTime, cts.Token);
                            }

                            await Task.Delay(programInUse.IntervalTime, cts.Token);
                        }
                    }
                    else
                    {
                        for (int counter = 0; counter < programInUse.NumExpositions; counter++) // AQUI ver estinulo -> palavra ou imagem como um só e ter intervalo separado
                        {
                            imgPictureBox.Visible = false;
                            wordLabel.Visible     = false;
                            subtitleLabel.Visible = false;
                            await intervalOrFixPoint(programInUse, cts.Token);


                            if (arrayCounter == imageDirs.Count())
                            {
                                arrayCounter = 0;
                            }
                            if (programInUse.RotateImage != 0)
                            {
                                imgPictureBox.Image = RotateImage(imageDirs[arrayCounter], programInUse.RotateImage);
                            }
                            else
                            {
                                imgPictureBox.Image = Image.FromFile(imageDirs[arrayCounter]);
                            }

                            if (programInUse.AudioListFile.ToLower() != "false" && programInUse.ExpositionType == "imgaud")
                            {
                                if (audioCounter == audioDirs.Length)
                                {
                                    audioCounter = 0;
                                }
                                audioDetail          = audioDirs[audioCounter];
                                Player.SoundLocation = audioDetail;
                                audioCounter++;
                                Player.Play();
                            }

                            elapsedTime = stopwatch.ElapsedMilliseconds; // grava tempo decorrido
                            SendKeys.SendWait("=");

                            imgPictureBox.Visible = true;

                            if (programInUse.SubtitleShow)
                            {
                                subtitleCounter = showSubtitle(subtitleCounter, subtitlesArray);
                            }

                            StroopProgram.writeLineOutput(programInUse, Path.GetFileName(imageDirs[arrayCounter].ToString()), "false", counter + 1, outputContent, elapsedTime, programInUse.ExpositionType, Path.GetFileNameWithoutExtension(audioDetail));

                            arrayCounter++;
                            await Task.Delay(programInUse.ExpositionTime, cts.Token);
                        }
                    }

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


                    await Task.Delay(programInUse.IntervalTime, cts.Token);

                    // beginAudio
                    if (programInUse.AudioCapture)
                    {
                        stopRecordingAudio();
                    }                                           // para gravação áudio
                    // endAudio
                    changeBackgroundColor(programInUse, false); // retorna à cor de fundo padrão

                    break;

                    /*
                     * DialogResult dialogResult = MessageBox.Show("Deseja repetir o teste?", "", MessageBoxButtons.YesNo); // pergunta se deseja repetir o programa
                     *
                     * if (dialogResult == DialogResult.Yes) { MessageBox.Show("O teste será repetido!"); } // se deseja repetir o programa mantém o laço while
                     * if (dialogResult == DialogResult.No) { break; } // se não deseja repetir quebra o laço
                     */
                }
                imgPictureBox.Dock  = DockStyle.None;
                wordLabel.Font      = new Font(wordLabel.Font.FontFamily, 160);
                wordLabel.ForeColor = Color.Black;
                StroopProgram.writeOutputFile(outputFile, string.Join("\n", outputContent.ToArray()));
                Close();
            }
            catch (TaskCanceledException)
            {
                StroopProgram.writeOutputFile(outputFile, string.Join("\n", outputContent.ToArray()));
                if (programInUse.AudioCapture)
                {
                    stopRecordingAudio();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            cts = null;
        }
Пример #7
0
        private async Task startWordExposition() // starts colored words exposition - classic Stroop
        {
            cts = new CancellationTokenSource();
            string textCurrent = null, colorCurrent = null, audioDetail = "false";

            string[]      labelText = null, labelColor = null, audioDirs = null, subtitlesArray = null;
            int           textArrayCounter = 0, colorArrayCounter = 0, audioCounter = 0, subtitleCounter = 0;
            List <string> outputContent = new List <string>();

            var interval   = Task.Run(async delegate { await Task.Delay(programInUse.IntervalTime, cts.Token); });
            var exposition = Task.Run(async delegate { await Task.Delay(programInUse.ExpositionTime, cts.Token); });

            try
            {
                // reading list files:
                labelText      = StrList.readListFile(path + "/lst/" + programInUse.WordsListFile);  // string array receives wordsList itens from list file
                labelColor     = StrList.readListFile(path + "/lst/" + programInUse.ColorsListFile); // string array receives colorsList itens from list file
                subtitlesArray = configureSubtitle();
                if (programInUse.ExpositionRandom)                                                   // if the presentation is random, shuffles arrays
                {
                    labelText  = ExpositionController.shuffleArray(labelText, programInUse.NumExpositions, 1);
                    labelColor = ExpositionController.shuffleArray(labelColor, programInUse.NumExpositions, 5);
                }
                if (programInUse.AudioListFile != "false") // if there is an audioFile to be played, string array receives audioList itens from list file
                {
                    audioDirs = StroopProgram.readDirListFile(path + "/lst/" + programInUse.AudioListFile);
                    if (programInUse.ExpositionRandom)
                    {
                        audioDirs = ExpositionController.shuffleArray(audioDirs, programInUse.NumExpositions, 6);
                    }                                                                                                                                // if the presentation is random, shuffles array
                }
                if (!Validations.allHexPattern(labelColor))
                {
                    throw new Exception("A lista de cores '" + programInUse.ColorsListFile + "' contém valores inválidos!\n A lista de" +
                                        "cores deve conter apenas valores hexadecimais (ex: #000000)");
                }

                // presenting test instructions:
                await showInstructions(programInUse, cts.Token);

                string printCount = "";
                while (true)
                {
                    textArrayCounter  = 0;                     // counters to zero
                    colorArrayCounter = 0;
                    elapsedTime       = 0;                     // elapsed time to zero
                    subtitleCounter   = 0;
                    changeBackgroundColor(programInUse, true); // changes background color, if there is one defined
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    await Task.Delay(programInUse.IntervalTime, cts.Token); // first interval before exposition begins

                    if (programInUse.AudioCapture && programInUse.ExpositionType != "txtaud")
                    {
                        startRecordingAudio();
                    }

                    // exposition loop:
                    for (int counter = 1; counter <= programInUse.NumExpositions; counter++)
                    {
                        subtitleLabel.Visible = false;
                        wordLabel.Visible     = false;
                        await intervalOrFixPoint(programInUse, cts.Token);

                        if (counter < 10)// contador p/ arquivo de audio
                        {
                            printCount = "0" + counter.ToString();
                        }
                        else
                        {
                            printCount = counter.ToString();
                        }

                        textCurrent  = labelText[textArrayCounter];
                        colorCurrent = labelColor[colorArrayCounter];

                        if (textArrayCounter == labelText.Count() - 1)
                        {
                            textArrayCounter = 0;
                        }
                        else
                        {
                            textArrayCounter++;
                        }
                        if (colorArrayCounter == labelColor.Count() - 1)
                        {
                            colorArrayCounter = 0;
                        }
                        else
                        {
                            colorArrayCounter++;
                        }
                        wordLabel.Text      = textCurrent;
                        wordLabel.ForeColor = ColorTranslator.FromHtml(colorCurrent);

                        if (programInUse.AudioListFile.ToLower() != "false" && programInUse.ExpositionType == "txtaud") // reproduz audio
                        {
                            if (audioCounter == audioDirs.Length)
                            {
                                audioCounter = 0;
                            }
                            audioDetail          = audioDirs[audioCounter];
                            Player.SoundLocation = audioDetail;
                            audioCounter++;
                            Player.Play();
                        }

                        elapsedTime = stopwatch.ElapsedMilliseconds; // grava tempo decorrido
                        SendKeys.SendWait("=");
                        if (programInUse.SubtitleShow)
                        {
                            subtitleCounter = showSubtitle(subtitleCounter, subtitlesArray);
                        }
                        wordLabel.Visible = true;



                        StroopProgram.writeLineOutput(programInUse, textCurrent, colorCurrent, counter, outputContent, elapsedTime, programInUse.ExpositionType, audioDetail);

                        await Task.Delay(programInUse.ExpositionTime, cts.Token);
                    }
                    wordLabel.Visible     = false;
                    subtitleLabel.Visible = false;
                    await Task.Delay(programInUse.IntervalTime, cts.Token);

                    // beginAudio
                    if (programInUse.AudioCapture && programInUse.ExpositionType != "txtaud")
                    {
                        stopRecordingAudio();
                    }                                           // para gravação áudio
                    // endAudio
                    changeBackgroundColor(programInUse, false); // retorna à cor de fundo padrão

                    break;

                    /*
                     * DialogResult dialogResult = MessageBox.Show("Deseja repetir o teste?", "", MessageBoxButtons.YesNo); // pergunta se deseja repetir o programa
                     * if (dialogResult == DialogResult.Yes) { MessageBox.Show("O teste será repetido!"); } // se deseja repetir o programa mantém o laço while
                     * if (dialogResult == DialogResult.No) { break; } // se não deseja repetir quebra o laço
                     */
                }
                StroopProgram.writeOutputFile(outputFile, string.Join("\n", outputContent.ToArray()));
                Close(); // finaliza exposição após execução
            }
            catch (TaskCanceledException)
            {
                StroopProgram.writeOutputFile(outputFile, string.Join("\n", outputContent.ToArray()));
                if (programInUse.AudioCapture)
                {
                    stopRecordingAudio();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cts = null;
        }
Пример #8
0
 public void TestReadInexistentList()
 {
     StrList.readListFile(null);
 }
Пример #9
0
        private void editList(string fileName)
        {
            StroopProgram program = new StroopProgram();
            string        wordsFilePath = "", colorsFilePath = "";

            string[] list = null, wordsArray = null, colorsArray = null;

            try
            {
                //MessageBox.Show(fileName);

                /*
                 * var typeOfList = fileName.Substring(fileName.Length - 6, fileName.Length);
                 * switch (typeOfList.ToLower())
                 * {
                 *  case "_words":
                 *      fileName = fileName.Remove(fileName.Length - 6);
                 *      break;
                 *  case "_color":
                 *      fileName = fileName.Remove(fileName.Length - 6);
                 *      break;
                 *  default:
                 *      break;
                 * }
                 */
                fileName = fileName.Remove(fileName.Length - 6);

                wordsFilePath  = path + fileName + "_words.lst";
                colorsFilePath = path + fileName + "_colors.lst";

                listNameTextBox.Text = fileName;

                checkWords.Checked  = false;
                checkColors.Checked = false;

                if (File.Exists(wordsFilePath))
                {
                    wordsArray         = StrList.readListFile(wordsFilePath);
                    checkWords.Checked = true;
                    foreach (string item in wordsArray)
                    {
                        wordsColoredList.Items.Add(item);
                    }
                }
                if (File.Exists(colorsFilePath))
                {
                    colorsArray         = StrList.readListFile(colorsFilePath);
                    checkColors.Checked = true;
                    for (int i = 0; i < colorsArray.Length; i++)
                    {
                        if (Validations.isHexPattern(colorsArray[i]))
                        {
                            hexColorsList.Items.Add(colorsArray[i]);
                            hexColorsList.Items[i].ForeColor = ColorTranslator.FromHtml(colorsArray[i]);
                            if (File.Exists(wordsFilePath))
                            {
                                wordsColoredList.Items[i].ForeColor = ColorTranslator.FromHtml(colorsArray[i]);
                            }
                        }
                    }
                }

                /*
                 * wordsListLabel.Text = testFileName(lst) + "_Words";
                 * colorsListLabel.Text = testFileName(lst) + "_Color";
                 * listNameTextBox.Text = testFileName(lst);
                 *
                 * wordsArray = program.readListFile(path + appendType + ".lst");
                 * list = program.readListFile(path + appendType + ".lst");
                 *
                 * if (editLstName != "error")
                 * {
                 *  list = program.readListFile(path + editLstName + ".lst");
                 *  if (Regex.IsMatch(list[0], hexPattern))
                 *  {
                 *      checkColors.Checked = true;
                 *      checkWords.Checked = false;
                 *      for (int i = 0; i < list.Length; i++)
                 *      {
                 *          hexColorsList.Items.Add(list[i]);
                 *          hexColorsList.Items[i].ForeColor = ColorTranslator.FromHtml(list[i]);
                 *      }
                 *  }
                 *  else
                 *  {
                 *      checkColors.Checked = false;
                 *      checkWords.Checked = true;
                 *      for (int i = 0; i < list.Length; i++)
                 *      {
                 *          wordsColoredList.Items.Add(list[i]);
                 *      }
                 *  }
                 *
                 * }*/
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Close();
            }
        }