private void deleteMatchButton_Click(object sender, EventArgs e) { { bool screenTranslationAllowed = true; if (FileManipulation.GlobalFormMain._contentPanel.Controls.Count > 0) { screenTranslationAllowed = checkSave(); } if (screenTranslationAllowed) { try { if (deleteMatchButton.Checked) { FileManagment deleteProgram = new FileManagment(MatchingProgram.GetProgramsPath(), FileManipulation._matchingTestFilesBackupPath, 'd', LocRM.GetString("matchingTest", currentCulture)); FileManipulation.GlobalFormMain._contentPanel.Controls.Add(deleteProgram); deleteMatchButton.Checked = false; } else { /*do nothing */ } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void matchingButton_Click(object sender, EventArgs e) { if (matchingButton.Checked) { comboBox1.SelectedItem = null; removeOptionsComboBox(); addOptionsComboBox(MatchingProgram.GetProgramsPath()); } }
public MatchingExposition(string prgName, string participantName, char mark) { this.FormBorderStyle = FormBorderStyle.None; this.MaximizeBox = true; this.StartPosition = FormStartPosition.Manual; ExpositionController.formSecondScreen(this); InitializeComponent(); startTime = hour + "_" + minutes + "_" + seconds; executingTest.ParticipantName = participantName; executingTest.setProgramInUse(prgName); executingTest.Mark = mark; stimuluControls = new List <Control>(); outputFile = MatchingProgram.GetResultsPath() + executingTest.ParticipantName + "_" + executingTest.ProgramInUse.ProgramName + ".txt"; startExposition(); this.ShowDialog(); }
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 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 saveButton_Click(object sender, EventArgs e) { if (saveButton.Enabled) { if (this.ValidateChildren(ValidationConstraints.Enabled)) { bool hasToSave = true; if (this.ValidateChildren(ValidationConstraints.Enabled)) { MatchingProgram newProgram = configureNewProgram(); if (File.Exists(path + Global.programFolderName + programName.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)); } } 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 = MatchingProgram.readDataFile(path + "/" + 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() { MatchingProgram editProgram = new MatchingProgram(); try { editProgram.readProgramFile(path + Global.programFolderName + editPrgName + ".prg"); } catch (FileNotFoundException e) { MessageBox.Show(LocRM.GetString("cantEdìtProgramMissingFiles", currentCulture) + e.Message); return; } if (editProgram.getImageListFile() != null) { openImgListButton.Text = editProgram.getImageListFile().ListName; this.stimuluType.SelectedIndex = 0; } else if (editProgram.getColorListFile() != null) { openColorListButton.Text = editProgram.getColorListFile().ListName; openWordListButton.Text = editProgram.getWordListFile().ListName; this.stimuluType.SelectedIndex = 2; } else { openWordListButton.Text = editProgram.getWordListFile().ListName; this.stimuluType.SelectedIndex = 1; } if (editProgram.WordColor != "false") { wordSingleColor.Text = editProgram.WordColor; WordColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.WordColor); } programName.Text = editProgram.ProgramName; stimuluNumber.Value = editProgram.StimuluNumber; attemptNumber.Value = editProgram.AttemptsNumber; expositionSize.Value = editProgram.StimuluSize; randomStimuluPosition.Checked = editProgram.RandomStimulusPosition; randomModelPosition.Checked = editProgram.RandomModelPosition; closeExpoAWithClick.Checked = editProgram.EndExpositionWithClick; stimulusInterval.Value = editProgram.IntervalTime; randomAttemptTime.Checked = editProgram.IntervalTimeRandom; stimulusExpoTime.Value = editProgram.ExpositionTime; modelExpoTime.Value = editProgram.ModelExpositionTime; omissionAudioResponse.Checked = editProgram.OmissionAudioResponse; commissionAudioFeedback.Checked = editProgram.CommissionAudioResponse; attemptInterval.Value = editProgram.AttemptsIntervalTime; randomOrder.Checked = editProgram.ExpositionRandom; DMTSBackgroundColor.Text = editProgram.BackgroundColor; DNMTSBackgroundColor.Text = editProgram.DNMTSBackground; DMTSColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.BackgroundColor); DNMTSColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.DNMTSBackground); feedbackAudioResponse.Checked = editProgram.FeedbackAudioResponse; expositonAudioResponse.Checked = editProgram.ExpositionAudioResponse; randomModelStimulusTime.Checked = editProgram.RandomIntervalModelStimulus; switch (editProgram.getExpositionType()) { case "DMTS": this.expositionType.SelectedIndex = 0; break; case "DNMTS": this.expositionType.SelectedIndex = 1; break; case "DMTS/DNMTS": this.expositionType.SelectedIndex = 2; break; } // 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 = ""; } switch (stimuluType.SelectedIndex) { case 1: if (openImgListButton.Text != LocRM.GetString("open", currentCulture)) { StrList imagesListFile = new StrList(openImgListButton.Text, 0); if (imagesListFile.ListContent.Count < stimuluNumber.Value) { errorProvider1.SetError(openImgListButton, LocRM.GetString("impossibleUseListWarn", currentCulture)); errorProvider2.Clear(); saveButton.Enabled = false; } else if (imagesListFile.ListContent.Count < attemptNumber.Value * stimuluNumber.Value) { errorProvider2.SetError(openImgListButton, LocRM.GetString("smallImageList", currentCulture)); saveButton.Enabled = true; } else { saveButton.Enabled = true; } } break; case 2: case 3: StrList wordListFile = new StrList(openWordListButton.Text, 2); if (wordListFile.ListContent.Count < stimuluNumber.Value) { errorProvider1.SetError(openWordListButton, LocRM.GetString("impossibleUseListWarn", currentCulture)); errorProvider2.Clear(); saveButton.Enabled = false; } else if (wordListFile.ListContent.Count < attemptNumber.Value * stimuluNumber.Value) { errorProvider2.SetError(openWordListButton, LocRM.GetString("smallImageList", currentCulture)); saveButton.Enabled = true; } else { saveButton.Enabled = true; } break; } }
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 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 editMatchButton_Click(object sender, EventArgs e) { bool screenTranslationAllowed = true; if (editMatchButton.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), MatchingProgram.GetProgramsPath(), "prg", "program", false, false); result = defineProgram.ShowDialog(); if (result == DialogResult.OK) { editProgramName = defineProgram.ReturnValue; FormMatchConfig configureProgram = new FormMatchConfig(editProgramName); configureProgram.PrgName = editProgramName; FileManipulation.GlobalFormMain._contentPanel.Controls.Add(configureProgram); editMatchButton.Checked = false; } else { /*do nothing, user cancelled selection of program*/ } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { /*do nothing*/ } }
private void startExposition() { if (executingTest.ProgramInUse.Ready()) { currentExpositionType = this.executingTest.ProgramInUse.getExpositionType(); if (this.currentExpositionType == LocRM.GetString("alternatingDMTS_DNMTS", currentCulture)) { shouldChangeExpositionType = true; this.currentExpositionType = "DMTS"; } if (this.currentExpositionType == LocRM.GetString("randomDMTS_DNMTS", currentCulture)) { int rand = randGen.Next(2); shouldRandomizeExpositionType = true; if (rand == 0) { this.currentExpositionType = "DMTS"; } else { this.currentExpositionType = "DNMTS"; } } initializeExposition(); } else { throw new Exception(LocRM.GetString("file", currentCulture) + executingTest.ProgramInUse.ProgramName + ".prg" + LocRM.GetString("notFoundIn", currentCulture) + Path.GetDirectoryName(MatchingProgram.GetProgramsPath() + "/prg/")); } }