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 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); }