Пример #1
0
        private void editProgram()
        {
            ReactionProgram editProgram = new ReactionProgram();

            editProgram.readProgramFile(path + Global.programFolderName + editPrgName + ".prg");

            prgNameTextBox.Text     = editProgram.ProgramName;
            numExpo.Value           = editProgram.NumExpositions;
            expoTime.Value          = editProgram.ExpositionTime;
            intervalTime.Value      = editProgram.IntervalTime;
            beepingCheckbox.Checked = editProgram.IsBeeping;
            beepDuration.Value      = editProgram.BeepDuration;
            stimulusDistance.Value  = editProgram.StimulusDistance;
            stimuluSize.Value       = editProgram.StimuluSize;

            if (editProgram.ExpositionRandom)
            {
                isRandomExposition.Checked = true;
            }

            if (editProgram.StimulusColor != "false")
            {
                stimulusColor.Text           = editProgram.StimulusColor;
                stimulusColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.StimulusColor);
            }

            editProgramShapes(editProgram);

            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     = "escolher";
            }

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

            if (editProgram.InstructionText != null) // lê instrução se houver
            {
                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 "Formas":
                chooseExpoType.SelectedIndex = 0;
                break;

            case "Palavra":
                chooseExpoType.SelectedIndex = 1;
                break;

            case "Imagem":
                chooseExpoType.SelectedIndex = 2;
                break;

            case "Imagem e Palavra":
                chooseExpoType.SelectedIndex = 3;
                break;

            case "Palavra com Áudio":
                chooseExpoType.SelectedIndex = 4;
                break;

            case "Imagem com Áudio":
                chooseExpoType.SelectedIndex = 5;
                break;

            default:
                throw new Exception("Tipo de Exposição: " + editProgram.ExpositionType + " inválido!");
            }
        }
        private void editProgram()
        {
            ReactionProgram editProgram = new ReactionProgram();

            try
            {
                editProgram.readProgramFile(path + Global.programFolderName + 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;
            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));
            }
        }
Пример #3
0
 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);
 }
Пример #4
0
        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);
        }