private void csvExportButton_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string[] lines; saveFileDialog1.Filter = "Excel CSV (.csv)|*.csv"; // salva em .csvs saveFileDialog1.RestoreDirectory = true; saveFileDialog1.FileName = fileNameBox.Text; try { if (fileNameBox.SelectedIndex == -1) { throw new Exception("Selecione um arquivo de dados!"); } lines = ReactionProgram.readDataFile(path + "/" + fileNameBox.SelectedItem.ToString() + ".txt"); if (saveFileDialog1.ShowDialog() == DialogResult.OK) // abre caixa para salvar { using (TextWriter tw = new StreamWriter(saveFileDialog1.FileName)) { tw.WriteLine(ReactionTest.HeaderOutputFileText); for (int i = 0; i < lines.Length; i++) { tw.WriteLine(lines[i]); // escreve linhas no novo arquivo } tw.Close(); MessageBox.Show("Arquivo exportado com sucesso!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void saveButton_Click(object sender, EventArgs e) { bool hasToSave = true; if (this.ValidateChildren(ValidationConstraints.Enabled)) { ReactionProgram newProgram = configureNewProgram(); if (File.Exists(path + Global.programFolderName + prgNameTextBox.Text + ".prg")) { DialogResult dialogResult = MessageBox.Show(LocRM.GetString("programExists", currentCulture), "", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.Cancel) { hasToSave = false; MessageBox.Show(LocRM.GetString("programNotSave", currentCulture)); } } if (hasToSave && newProgram.saveProgramFile(path + Global.programFolderName, instructionsBox.Text)) { MessageBox.Show(LocRM.GetString("programSave", currentCulture)); } this.Parent.Controls.Remove(this); } else { MessageBox.Show(LocRM.GetString("fieldNotRight", currentCulture)); } }
// preparing shapes checkbox according to shapes in the program that will be edited private void editProgramShapes(ReactionProgram editProgram) { List <string> shapes = editProgram.StimuluShape.Split(',').ToList(); foreach (string shape in shapes) { switch (shape) { case "fullSquare": fullSquareCheckBox.Checked = true; break; case "fullCircle": fullCircleCheckBox.Checked = true; break; case "fullTriangle": fullTriangleCheckBox.Checked = true; break; case "square": squareCheckBox.Checked = true; break; case "circle": circleCheckBox.Checked = true; break; case "triangle": triangleCheckBox.Checked = true; break; } } }
private void saveButton_Click(object sender, EventArgs e) { if (this.ValidateChildren(ValidationConstraints.Enabled)) { ReactionProgram newProgram = configureNewProgram(); if (File.Exists(path + Global.programFolderName + prgNameTextBox.Text + ".prg")) { DialogResult dialogResult = MessageBox.Show("O programa já existe, deseja sobrescrevê-lo?", "", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.Cancel) { throw new Exception("O programa não será salvo!"); } } if (newProgram.saveProgramFile(path + Global.programFolderName, instructionsBox.Text)) { MessageBox.Show("O programa foi salvo com sucesso"); } this.Parent.Controls.Remove(this); } else { MessageBox.Show("Algum campo não foi preenchido de forma correta."); } }
private void reactionButton_Click(object sender, EventArgs e) { if (reactionButton.Checked) { comboBox1.SelectedItem = null; removeOptionsComboBox(); addOptionsComboBox(ReactionProgram.GetProgramsPath()); } }
// show participant instructions to execute during test private async Task showInstructions(ReactionProgram program, CancellationToken token) { if (program.InstructionText != null) { instructionLabel.Enabled = true; instructionLabel.Visible = true; for (int i = 0; i < program.InstructionText.Count; i++) { instructionLabel.Text = program.InstructionText[i]; await Task.Delay(Program.instructionAwaitTime); } instructionLabel.Enabled = false; instructionLabel.Visible = false; } }
// show participant instructions to execute during test private void showInstructions(ReactionProgram program) { if (program.InstructionText != null) { instructionLabel.Enabled = true; instructionLabel.Visible = true; for (int i = 0; i < program.InstructionText.Count; i++) { instructionLabel.Text += program.InstructionText[i]; //await Task.Delay(Program.instructionAwaitTime); } //instructionLabel.Enabled = false; instructionLabel.Visible = false; } }
private void initializeDefaultPrograms() // inicializa programDefault padrão { StroopProgram programDefault = new StroopProgram(); programDefault.ProgramName = DEFAULTPGRNAME; try { programDefault.writeDefaultProgramFile(Global.stroopTestFilesPath + Global.programFolderName + programDefault.ProgramName + ".prg"); // ao inicializar formulario escreve arquivo programa padrao ReactionProgram.writeDefaultProgramFile(); StrList.writeDefaultWordsList(Global.testFilesPath + Global.listFolderName); // escreve lista de palavras padrão StrList.writeDefaultColorsList(Global.testFilesPath + Global.listFolderName); // escreve lista de cores padrão } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } }
private void initializeDefaultPrograms() // inicializa programDefault padrão { StroopProgram programDefault = new StroopProgram(); programDefault.ProgramName = LocRM.GetString("default", currentCulture); try { // writing default program and lists on to disk programDefault.writeDefaultProgramFile(Global.stroopTestFilesPath + Global.programFolderName + programDefault.ProgramName + ".prg"); ReactionProgram defaultProgram = new ReactionProgram(); defaultProgram.writeDefaultProgramFile(); StrList.writeDefaultWordsList(Global.testFilesPath + Global.listFolderName); StrList.writeDefaultColorsList(Global.testFilesPath + Global.listFolderName); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } }
private void addToDestinationList_Click(object sender, EventArgs e) { // if there is any selected row in origin file, transfer it to import list if (originDataGridView.SelectedRows.Count > 0) { string selectedRowType = originDataGridView.SelectedRows[0].Cells[1].Value.ToString(); string selectedRowName = originDataGridView.SelectedRows[0].Cells[0].Value.ToString(); int i = originDataGridView.SelectedRows[0].Index; int index = importDataGridView.Rows.Add(); importDataGridView.Rows[index].Cells[0].Value = (originDataGridView.SelectedRows[0].Cells[0].Value.ToString()); importDataGridView.Rows[index].Cells[1].Value = (originDataGridView.SelectedRows[0].Cells[1].Value.ToString()); importDataGridView.Rows[index].Cells[2].Value = (originDataGridView.SelectedRows[0].Cells[2].Value.ToString()); importDataGridView.Rows[index].DefaultCellStyle.BackColor = originDataGridView.Rows[i].DefaultCellStyle.BackColor; originDataGridView.Rows.Remove(originDataGridView.SelectedRows[0]); if (selectedRowType == LocRM.GetString("stroopTest", currentCulture)) { StroopProgram newProgram = new StroopProgram(); newProgram.readProgramFile(importDirectory + "/StroopProgram/" + selectedRowName + ".prg"); addLists(newProgram); } else if (selectedRowType == LocRM.GetString("reactionTest", currentCulture)) { ReactionProgram newReaction = new ReactionProgram(importDirectory + "/ReactionProgram/" + selectedRowName + ".prg"); addLists(newReaction); } else if (selectedRowType == LocRM.GetString("matchingTest", currentCulture)) { MatchingProgram newProgram = new MatchingProgram(importDirectory + "/MatchingProgram/" + selectedRowName + ".prg"); addLists(newProgram); } else if (selectedRowType == LocRM.GetString("experiment", currentCulture)) { addPrograms(selectedRowName); } } else { } }
private void deleteReactButton_Click(object sender, EventArgs e) { bool screenTranslationAllowed = true; try { if (deleteReactButton.Checked) { if (FileManipulation.GlobalFormMain._contentPanel.Controls.Count > 0) { screenTranslationAllowed = checkSave(); } if (screenTranslationAllowed) { FileManagment deleteProgram = new FileManagment(ReactionProgram.GetProgramsPath(), FileManipulation.ReactionTestFilesBackupPath, 'd', LocRM.GetString("reactionTest", currentCulture)); FileManipulation.GlobalFormMain._contentPanel.Controls.Add(deleteProgram); deleteReactButton.Checked = false; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void addToDestinationList_Click(object sender, EventArgs e) { string selectedRowType = originDataGridView.SelectedRows[0].Cells[1].Value.ToString(); string selectedRowName = originDataGridView.SelectedRows[0].Cells[0].Value.ToString(); int index = exportDataGridView.Rows.Add(); exportDataGridView.Rows[index].Cells[0].Value = (originDataGridView.SelectedRows[0].Cells[0].Value.ToString()); exportDataGridView.Rows[index].Cells[1].Value = (originDataGridView.SelectedRows[0].Cells[1].Value.ToString()); exportDataGridView.Rows[index].Cells[2].Value = (originDataGridView.SelectedRows[0].Cells[2].Value.ToString()); originDataGridView.Rows.Remove(originDataGridView.SelectedRows[0]); if (selectedRowType == LocRM.GetString("stroopTest", currentCulture)) { StroopProgram newProgram = new StroopProgram(); newProgram.readProgramFile(selectedRowName); addLists(newProgram); } else if (selectedRowType == LocRM.GetString("reactionTest", currentCulture)) { ReactionProgram newReaction = new ReactionProgram(reactionPath + selectedRowName + ".prg"); addLists(newReaction); } else if (selectedRowType == LocRM.GetString("matchingTest", currentCulture)) { MatchingProgram newMatching = new MatchingProgram(selectedRowName); addLists(newMatching); } else if (selectedRowType == LocRM.GetString("experiment", currentCulture)) { addPrograms(selectedRowName); } else { /* do nothing*/ } }
private void csvExportButton_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string[] lines; saveFileDialog1.Filter = "Excel CSV (.csv)|*.csv"; // salva em .csvs saveFileDialog1.RestoreDirectory = true; saveFileDialog1.FileName = fileNameBox.Text; try { // checks if there are any results selected if (!(fileNameBox.SelectedIndex == -1)) { lines = ReactionProgram.readDataFile(resultsPath + "/" + fileNameBox.SelectedItem.ToString() + ".txt"); if (saveFileDialog1.ShowDialog() == DialogResult.OK) // abre caixa para salvar { using (TextWriter tw = new StreamWriter(saveFileDialog1.FileName)) { tw.WriteLine(LocRM.GetString("reactionTestHeader", currentCulture)); for (int i = 0; i < lines.Length; i++) { tw.WriteLine(lines[i]); // escreve linhas no novo arquivo } tw.Close(); MessageBox.Show("Arquivo exportado com sucesso!"); } } } else { MessageBox.Show(LocRM.GetString("selectDataFile", currentCulture)); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void editProgram() { ReactionProgram editProgram = new ReactionProgram(); try { editProgram.readProgramFile(path + Global.programFolderName + editPrgName + ".prg"); } catch (FileNotFoundException e) { MessageBox.Show(LocRM.GetString("cantEdìtProgramMissingFiles", currentCulture) + e.Message); return; } prgNameTextBox.Text = editProgram.ProgramName; numExpo.Value = editProgram.NumExpositions; expoTime.Value = editProgram.ExpositionTime; intervalTime.Value = editProgram.IntervalTime; beepingCheckbox.Checked = editProgram.IsBeeping; beepDuration.Value = editProgram.BeepDuration; stimuluSize.Value = (decimal)editProgram.StimuluSize; fontSizeUpDown.Value = editProgram.FontSize; positionsBox.SelectedIndex = editProgram.NumberPositions - 1; expandImageCheck.Checked = editProgram.ExpandImage; if (editProgram.getHasColorList()) { UniqueColorOption.Checked = false; ColorListOption.Checked = true; openColorListButton.Enabled = true; stimulusColor.Enabled = false; } if (editProgram.ExpositionRandom) { isRandomExposition.Checked = true; } if (editProgram.BeepingRandom) { randomBeepCheck.Checked = true; } if (editProgram.StimulusColor != "false") { stimulusColor.Text = editProgram.StimulusColor; stimulusColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.StimulusColor); } else { stimulusColor.Enabled = false; stimulusColorPanel.BackColor = Color.White; } editProgramShapes(editProgram); if (editProgram.ResponseType == "space") { responseTypeBox.SelectedIndex = 0; } else if (editProgram.ResponseType == "arrows") { responseTypeBox.SelectedIndex = 1; } if (editProgram.getWordListFile() == null) { openWordListButton.Enabled = false; } else { openWordListButton.Enabled = true; openWordListButton.Text = editProgram.getWordListFile().ListName; } if (editProgram.getColorListFile() == null) { openColorListButton.Enabled = false; } else { openColorListButton.Enabled = true; openColorListButton.Text = editProgram.getColorListFile().ListName; } if (editProgram.getImageListFile() == null) { openImgListButton.Enabled = false; } else { openImgListButton.Enabled = true; openImgListButton.Text = editProgram.getImageListFile().ListName; } if (editProgram.getAudioListFile() == null) { openAudioListButton.Enabled = false; } else { openAudioListButton.Enabled = true; openAudioListButton.Text = editProgram.getAudioListFile().ListName; } if (editProgram.BackgroundColor.ToLower() == "false") { bgColorPanel.BackColor = Color.White; bgColorButton.Text = LocRM.GetString("choose", currentCulture); } else { if ((Validations.isHexPattern(editProgram.BackgroundColor))) { bgColorButton.Text = editProgram.BackgroundColor; bgColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.BackgroundColor); } } if (editProgram.FixPoint == "+") { fixPointCross.Checked = true; fixPointCircle.Checked = false; fixPointColorButton.Text = editProgram.FixPointColor; fixPointColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.FixPointColor); } else if (editProgram.FixPoint == "o") { fixPointCross.Checked = false; fixPointCircle.Checked = true; fixPointColorButton.Text = editProgram.FixPointColor; fixPointColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.FixPointColor); } else { fixPointCross.Checked = false; fixPointCircle.Checked = false; } // reads program instructions to instruction box if there are any if (editProgram.InstructionText != null) { instructionsBox.ForeColor = Color.Black; instructionsBox.Text = editProgram.InstructionText[0]; for (int i = 1; i < editProgram.InstructionText.Count; i++) { instructionsBox.AppendText(Environment.NewLine + editProgram.InstructionText[i]); } } else { instructionsBox.Text = instructionBoxText; } switch (editProgram.ExpositionType) { case "shapes": chooseExpoType.SelectedIndex = 0; break; case "words": chooseExpoType.SelectedIndex = 1; break; case "images": chooseExpoType.SelectedIndex = 2; break; case "imageAndWord": chooseExpoType.SelectedIndex = 3; break; case "wordWithAudio": chooseExpoType.SelectedIndex = 4; break; case "imageWithAudio": chooseExpoType.SelectedIndex = 5; break; default: throw new Exception(LocRM.GetString("expoType", currentCulture) + editProgram.ExpositionType + LocRM.GetString("invalid", currentCulture)); } }
private void editProgram() { ReactionProgram editProgram = new ReactionProgram(); editProgram.readProgramFile(path + Global.programFolderName + editPrgName + ".prg"); prgNameTextBox.Text = editProgram.ProgramName; numExpo.Value = editProgram.NumExpositions; expoTime.Value = editProgram.ExpositionTime; intervalTime.Value = editProgram.IntervalTime; beepingCheckbox.Checked = editProgram.IsBeeping; beepDuration.Value = editProgram.BeepDuration; stimulusDistance.Value = editProgram.StimulusDistance; stimuluSize.Value = editProgram.StimuluSize; if (editProgram.ExpositionRandom) { isRandomExposition.Checked = true; } if (editProgram.StimulusColor != "false") { stimulusColor.Text = editProgram.StimulusColor; stimulusColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.StimulusColor); } editProgramShapes(editProgram); if (editProgram.getWordListFile() == null) { openWordListButton.Enabled = false; } else { openWordListButton.Enabled = true; openWordListButton.Text = editProgram.getWordListFile().ListName; } if (editProgram.getColorListFile() == null) { openColorListButton.Enabled = false; } else { openColorListButton.Enabled = true; openColorListButton.Text = editProgram.getColorListFile().ListName; } if (editProgram.getImageListFile() == null) { openImgListButton.Enabled = false; } else { openImgListButton.Enabled = true; openImgListButton.Text = editProgram.getImageListFile().ListName; } if (editProgram.getAudioListFile() == null) { openAudioListButton.Enabled = false; } else { openAudioListButton.Enabled = true; openAudioListButton.Text = editProgram.getAudioListFile().ListName; } if (editProgram.BackgroundColor.ToLower() == "false") { bgColorPanel.BackColor = Color.White; bgColorButton.Text = "escolher"; } else { if ((Validations.isHexPattern(editProgram.BackgroundColor))) { bgColorButton.Text = editProgram.BackgroundColor; bgColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.BackgroundColor); } } if (editProgram.FixPoint == "+") { fixPointCross.Checked = true; fixPointCircle.Checked = false; fixPointColorButton.Text = editProgram.FixPointColor; fixPointColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.FixPointColor); } else if (editProgram.FixPoint == "o") { fixPointCross.Checked = false; fixPointCircle.Checked = true; fixPointColorButton.Text = editProgram.FixPointColor; fixPointColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.FixPointColor); } else { fixPointCross.Checked = false; fixPointCircle.Checked = false; } if (editProgram.InstructionText != null) // lê instrução se houver { instructionsBox.ForeColor = Color.Black; instructionsBox.Text = editProgram.InstructionText[0]; for (int i = 1; i < editProgram.InstructionText.Count; i++) { instructionsBox.AppendText(Environment.NewLine + editProgram.InstructionText[i]); } } else { instructionsBox.Text = instructionBoxText; } switch (editProgram.ExpositionType) { case "Formas": chooseExpoType.SelectedIndex = 0; break; case "Palavra": chooseExpoType.SelectedIndex = 1; break; case "Imagem": chooseExpoType.SelectedIndex = 2; break; case "Imagem e Palavra": chooseExpoType.SelectedIndex = 3; break; case "Palavra com Áudio": chooseExpoType.SelectedIndex = 4; break; case "Imagem com Áudio": chooseExpoType.SelectedIndex = 5; break; default: throw new Exception("Tipo de Exposição: " + editProgram.ExpositionType + " inválido!"); } }
private ReactionProgram configureNewProgram() { if (bgColorButton.Text.Equals("escolher")) { bgColorButton.Text = "false"; } ReactionProgram newProgram = new ReactionProgram(); switch (chooseExpoType.SelectedIndex) { // Program type "Formas" case 0: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(stimuluSize.Value), Convert.ToInt32(intervalTime.Value), Convert.ToInt32(stimulusDistance.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value), stimulusColorCheck(), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, shapeValue(), chooseExpoType.Text, randomBeepCheck.Checked, Convert.ToInt32(positionsBox.Text ), responseTypeBox.Text); break; // Program type "Palavra" case 1: // TODO: Add ReactionProgram constructor to "Palavra" type here break; // Program type "Imagem" case 2: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(stimuluSize.Value), Convert.ToInt32(intervalTime.Value), Convert.ToInt32(stimulusDistance.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, openImgListButton.Text, randomBeepCheck.Checked, Convert.ToInt32(positionsBox.Text), responseTypeBox.Text, isRandomExposition.Checked); break; // Program type "Imagem e Palavra" case 3: // TODO: Add ReactionProgram constructor to "Imagem e Palavra" type here break; // Program type "Palavra com Aúdio" case 4: // TODO: Add ReactionProgram constructor to "Palavra com aúdio" type here break; // Program type "Imagem com Aúdio" case 5: // TODO: Add ReactionProgram constructor to "Imagem com aúdio" type here break; // invalid type aws choosen default: throw new Exception("O tipo de programa entrado é invalido!"); } // read instructions and pass them to the new program created string textLines = ""; if (instructionsBox.Lines.Length > 0 && instructionsBox.Text != instructionBoxText) { for (int i = 0; i < instructionsBox.Lines.Length; i++) { newProgram.InstructionText.Add(instructionsBox.Lines[i]); textLines = textLines + "\n" + instructionsBox.Lines[i]; } } else { newProgram.InstructionText = null; } return(newProgram); }
private void editReactButton_Click(object sender, EventArgs e) { bool screenTranslationAllowed = true; if (editReactButton.Checked) { if (FileManipulation.GlobalFormMain._contentPanel.Controls.Count > 0) { screenTranslationAllowed = checkSave(); } if (screenTranslationAllowed) { FormDefine defineProgram; DialogResult result; string editProgramName = "error"; try { defineProgram = new FormDefine(LocRM.GetString("editProgram", currentCulture), ReactionProgram.GetProgramsPath(), "prg", "program", false, false); result = defineProgram.ShowDialog(); if (result == DialogResult.OK) { editProgramName = defineProgram.ReturnValue; FormTRConfig configureProgram = new FormTRConfig(editProgramName); configureProgram.PrgName = editProgramName; FileManipulation.GlobalFormMain._contentPanel.Controls.Add(configureProgram); editReactButton.Checked = false; } else { /*do nothing, user cancelled selection of program*/ } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { /*do nothing*/ } }
private bool filesHasNoDepedency() { if (mode == 'r' && destinationFilesList.Items.Count > 0) { for (int count = 0; count < destinationFilesList.Items.Count; count++) { if (this.type == LocRM.GetString("experiment")) { ExperimentProgram experiment = new ExperimentProgram(); experiment.ExperimentName = Path.GetFileNameWithoutExtension(destinationFilesList.Items[count].ToString()); try { experiment.ReadProgramFile(true); } catch (MissingMemberException e) { MessageBox.Show(e.Message + " " + LocRM.GetString("cantBeFoundPleaseRocoverFirst", currentCulture) + destinationFilesList.Items[count].ToString() + ")"); return(false); } catch (FileNotFoundException e) { MessageBox.Show(LocRM.GetString("cannotRecoverFilesByMotive", currentCulture) + destinationFilesList.Items[count].ToString() + "\":\n" + e.Message); return(false); } } else { if (type == LocRM.GetString("stroopTest", currentCulture)) { StroopProgram program = new StroopProgram(); try { program.readProgramFile(Global.stroopTestFilesBackupPath + destinationFilesList.Items[count].ToString() + ".prg"); } catch (FileNotFoundException e) { MessageBox.Show(LocRM.GetString("cannotRecoverFilesByMotive", currentCulture) + destinationFilesList.Items[count].ToString() + "\":\n" + e.Message); return(false); } } else if (type == LocRM.GetString("reactionTest", currentCulture)) { ReactionProgram program = new ReactionProgram(); try { program.readProgramFile(Global.reactionTestFilesBackupPath + destinationFilesList.Items[count].ToString() + ".prg"); } catch (FileNotFoundException e) { MessageBox.Show(LocRM.GetString("cannotRecoverFilesByMotive", currentCulture) + destinationFilesList.Items[count].ToString() + "\":\n" + e.Message); return(false); } } else if (type == LocRM.GetString("matchingTest", currentCulture)) { MatchingProgram program = new MatchingProgram(); try { program.readProgramFile(Global.matchingTestFilesBackupPath + destinationFilesList.Items[count].ToString() + ".prg"); } catch (FileNotFoundException e) { MessageBox.Show(LocRM.GetString("cannotRecoverFilesByMotive", currentCulture) + destinationFilesList.Items[count].ToString() + "\":\n" + e.Message); return(false); } } } } } return(true); }
private ReactionProgram configureNewProgram() { if (bgColorButton.Text.Equals(LocRM.GetString("choose", currentCulture))) { bgColorButton.Text = "false"; } ReactionProgram newProgram = new ReactionProgram(); switch (chooseExpoType.SelectedIndex) { // Program type "shapes" case 0: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToDouble(stimuluSize.Value), Convert.ToInt32(intervalTime.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value), stimulusColorCheck(), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, shapeValue(), randomBeepCheck.Checked, Convert.ToInt32(positionsBox.Text), responseType(), openColorListButton.Text, ColorListOption.Checked, sstCheckBox.Checked); break; // Program type "words" case 1: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(fontSizeUpDown.Value), Convert.ToInt32(intervalTime.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value), stimulusColorCheck(), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, randomBeepCheck.Checked, Convert.ToInt32(positionsBox.Text), responseType(), openWordListButton.Text, isRandomExposition.Checked, openColorListButton.Text, ColorListOption.Checked, Convert.ToInt32(fontSizeUpDown.Value), sstCheckBox.Checked); break; // Program type "images" case 2: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToDouble(stimuluSize.Value), Convert.ToInt32(intervalTime.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, openImgListButton.Text, randomBeepCheck.Checked, Convert.ToInt32(positionsBox.Text), responseType(), isRandomExposition.Checked, expandImageCheck.Checked, sstCheckBox.Checked); break; // Program type "imageAndWord" case 3: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToDouble(stimuluSize.Value), Convert.ToInt32(intervalTime.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, openImgListButton.Text, openWordListButton.Text, openColorListButton.Text, randomBeepCheck.Checked, Convert.ToInt32(positionsBox.Text), ColorListOption.Checked, responseType(), isRandomExposition.Checked, stimulusColorCheck(), Convert.ToInt32(fontSizeUpDown.Value), expandImageCheck.Checked, sstCheckBox.Checked); break; // Program type "wordWithAudio" case 4: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(intervalTime.Value), stimulusColorCheck(), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, Convert.ToInt32(positionsBox.Text), responseType(), openColorListButton.Text, ColorListOption.Checked, isRandomExposition.Checked, Convert.ToInt32(fontSizeUpDown.Value), openAudioListButton.Text, openWordListButton.Text, sstCheckBox.Checked); break; // Program type "imageWithAudio" case 5: newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(intervalTime.Value), fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, Convert.ToInt32(positionsBox.Text), responseType(), Convert.ToDouble(stimuluSize.Value), isRandomExposition.Checked, openAudioListButton.Text, openImgListButton.Text, expandImageCheck.Checked, sstCheckBox.Checked); break; // invalid type was choosen default: throw new Exception(LocRM.GetString("invalidExpoType", currentCulture)); } // read instructions and pass them to the new program created string textLines = ""; if (instructionsBox.Lines.Length > 0) { for (int i = 0; i < instructionsBox.Lines.Length; i++) { newProgram.InstructionText.Add(instructionsBox.Lines[i]); textLines = textLines + "\n" + instructionsBox.Lines[i]; } } else { newProgram.InstructionText = null; } return(newProgram); }
private bool isListUsed(string listName, string suffix, out bool stopProcess) { string currentProgram = "", originPath = "", programName = "", destinationPath = ""; string[] TRPrograms = ReactionProgram.GetAllPrograms(); string[] StroopPrograms = StroopProgram.GetAllPrograms(); string[] MatchingPrograms = MatchingProgram.GetAllPrograms(); try { foreach (string file in TRPrograms) { originPath = ReactionProgram.GetProgramsPath(); destinationPath = FileManipulation.ReactionTestFilesBackupPath; programName = Path.GetFileNameWithoutExtension(file); currentProgram = Path.GetFileNameWithoutExtension(file) + " (" + LocRM.GetString("reactionTest", currentCulture) + ")"; ReactionProgram program = new ReactionProgram(); program.readProgramFile(file); if (suffix == "_image" && program.getImageListFile() != null && program.getImageListFile().ListName == listName) { stopProcess = false; return(true); } else if (suffix == "_audio" && program.getAudioListFile() != null && program.getAudioListFile().ListName == listName) { stopProcess = false; return(true); } else if (suffix == "_words_color") { if (program.getWordListFile() != null && ((program.getWordListFile().ListName + "_words") == listName)) { stopProcess = false; return(true); } else if (program.getColorListFile() != null && ((program.getColorListFile().ListName + "_color") == listName)) { stopProcess = false; return(true); } } } foreach (string file in StroopPrograms) { originPath = StroopProgram.GetProgramsPath(); destinationPath = FileManipulation.StroopTestFilesBackupPath; programName = Path.GetFileNameWithoutExtension(file); StroopProgram program = new StroopProgram(); currentProgram = Path.GetFileNameWithoutExtension(file) + " (" + LocRM.GetString("stroopTest", currentCulture) + ")"; program.readProgramFile(programName); if (suffix == "_image" && program.getImageListFile() != null && program.getImageListFile().ListName == listName) { stopProcess = false; return(true); } else if (suffix == "_audio" && program.getAudioListFile() != null && program.getAudioListFile().ListName == listName) { stopProcess = false; return(true); } else if (suffix == "_words_color") { if (program.getWordListFile() != null && ((program.getWordListFile().ListName + "_words") == listName)) { stopProcess = false; return(true); } else if (program.getColorListFile() != null && ((program.getColorListFile().ListName + "_color") == listName)) { stopProcess = false; return(true); } } } foreach (string file in MatchingPrograms) { originPath = MatchingProgram.GetProgramsPath(); destinationPath = FileManipulation._matchingTestFilesBackupPath; programName = Path.GetFileNameWithoutExtension(file); MatchingProgram program = new MatchingProgram(); currentProgram = Path.GetFileNameWithoutExtension(file) + " (" + LocRM.GetString("matchingTest", currentCulture) + ")"; program.configureReadProgram(file); if (suffix == "_image" && program.getImageListFile() != null && program.getImageListFile().ListName == listName) { stopProcess = false; return(true); } else if (suffix == "_audio" && program.getAudioListFile() != null && program.getAudioListFile().ListName == listName) { stopProcess = false; return(true); } else if (suffix == "_words_color") { if (program.getWordListFile() != null && ((program.getWordListFile().ListName + "_words") == listName)) { stopProcess = false; return(true); } else if (program.getColorListFile() != null && ((program.getColorListFile().ListName + "_color") == listName)) { stopProcess = false; return(true); } } } } catch (FileNotFoundException e) { DialogResult dialogResult = MessageBox.Show(LocRM.GetString("wanstPossibleToRecoverLists", currentCulture) + "\"" + currentProgram + "\"" + LocRM.GetString("hasMissingLists", currentCulture) + e.Message + "\"" + LocRM.GetString("missingListSolution", currentCulture), LocRM.GetString("error", currentCulture), MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { DialogResult shouldDelete = MessageBox.Show(LocRM.GetString("deleteProgram", currentCulture) + currentProgram + "?", LocRM.GetString("delete", currentCulture), MessageBoxButtons.YesNo); if (shouldDelete == DialogResult.Yes) { try { File.Move(originPath + programName + ".prg", destinationPath + programName + ".prg"); } catch (IOException) { File.Delete(destinationPath + programName + ".prg"); File.Move(originPath + programName + ".prg", destinationPath + programName + ".prg"); } MessageBox.Show(LocRM.GetString("deletedSucessful", currentCulture)); this.Parent.Controls.Remove(this); ListManagment newListManagment = new ListManagment(suffix, mode); FileManipulation.GlobalFormMain._contentPanel.Controls.Add(newListManagment); stopProcess = true; return(false); } else { MessageBox.Show(LocRM.GetString("FilesNotDeleted", currentCulture)); this.Parent.Controls.Remove(this); stopProcess = true; return(false); } } else { this.Parent.Controls.Remove(this); stopProcess = true; return(false); } } stopProcess = false; return(false); }
private void reactionToolStripMenuItem1_Click(object sender, EventArgs e) { FormDefine defineProgram; DialogResult result; string editProgramName = "error"; defineProgram = new FormDefine(LocRM.GetString("editProgram", currentCulture), ReactionProgram.GetProgramsPath(), "prg", "program", false, false); result = defineProgram.ShowDialog(); if (result == DialogResult.OK) { editProgramName = defineProgram.ReturnValue; FormTRConfig configureProgram = new FormTRConfig(editProgramName); configureProgram.PrgName = editProgramName; this.Controls.Add(configureProgram); } }