Esempio n. 1
0
        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); }
                }
            }
        }
Esempio n. 2
0
 private void matchingButton_Click(object sender, EventArgs e)
 {
     if (matchingButton.Checked)
     {
         comboBox1.SelectedItem = null;
         removeOptionsComboBox();
         addOptionsComboBox(MatchingProgram.GetProgramsPath());
     }
 }
        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);
        }
Esempio n. 4
0
        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/"));
     }
 }