private void saveButton_Click(object sender, EventArgs e) { bool hasToSave = true; if (this.ValidateChildren(ValidationConstraints.Enabled)) { ReactionProgram newProgram = configureNewProgram(); if (File.Exists(ReactionProgram.GetProgramsPath() + 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(ReactionProgram.GetProgramsPath(), instructionsBox.Text)) { MessageBox.Show(LocRM.GetString("programSave", currentCulture)); } this.Parent.Controls.Remove(this); } else { MessageBox.Show(LocRM.GetString("fieldNotRight", currentCulture)); } }
private void reactionButton_Click(object sender, EventArgs e) { if (reactionButton.Checked) { comboBox1.SelectedItem = null; removeOptionsComboBox(); addOptionsComboBox(ReactionProgram.GetProgramsPath()); } }
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 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); } }
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 void editProgram() { ReactionProgram editProgram = new ReactionProgram(); try { editProgram.readProgramFile(ReactionProgram.GetProgramsPath() + 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; intervalBetweenAttempts.Value = editProgram.IntervalBetweenAttempts; 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)); } }