コード例 #1
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);
        }
コード例 #2
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.readProgramBackUpFile(destinationFilesList.Items[count].ToString());
                     }
                     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.readImportProgramFile(destinationFilesList.Items[count].ToString());
                     }
                     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.configureReadProgram(FileManipulation._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);
 }