Example #1
0
 public FormDefineTest(CultureInfo currentCulture)
 {
     this.currentCulture = currentCulture;
     InitializeComponent();
     AutoValidate = AutoValidate.Disable;
     addOptionsComboBox(StroopProgram.GetProgramsPath());
 }
Example #2
0
 private void stroopButton_Click(object sender, EventArgs e)
 {
     if (stroopButton.Checked)
     {
         comboBox1.SelectedItem = null;
         removeOptionsComboBox();
         addOptionsComboBox(StroopProgram.GetProgramsPath());
     }
 }
Example #3
0
        private void stroopToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            FormDefine   defineProgram;
            DialogResult result;
            string       editProgramName = "error";

            try
            {
                defineProgram = new FormDefine(LocRM.GetString("editProgram", currentCulture),
                                               StroopProgram.GetProgramsPath(), "prg", "program", false, false);
                result = defineProgram.ShowDialog();
                if (result == DialogResult.OK)
                {
                    editProgramName = defineProgram.ReturnValue;
                    FormPrgConfig configureProgram = new FormPrgConfig(editProgramName);
                    this.Controls.Add(configureProgram);
                }
            }
            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);
        }