Esempio n. 1
0
        public static globalSettings readInSettings(System.Threading.Thread splashThread)
        {
            globalSettings settings;

            try
            {
                ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
                fileMap.ExeConfigFilename = @"GraphSynthSettings.config";
                // relative path names possible

                // Open another config file
                Configuration config =
                    ConfigurationManager.OpenMappedExeConfiguration(fileMap,
                                                                    ConfigurationUserLevel.None);
                if (config.Sections["GraphSynthSettings"] == null)
                {
                    throw new FileNotFoundException();
                }
                else
                {
                    settings = (globalSettings)config.GetSection("GraphSynthSettings");
                }
                Program.output("GraphSynthSettings.config loaded successfully.");
            }

            catch (FileNotFoundException)
            {
                if (DialogResult.Yes ==
                    MessageBox.Show("Welcome to GraphSynth. This very well might be your first time with this program, " +
                                    "since no configuration file (\"GraphSynthSettings.config\") was found in the executing directory (" +
                                    Directory.GetCurrentDirectory().ToString() + ".\n\nYou can create a new configuration file now (by clicking YES)" +
                                    ", or exit, put an already established \"GraphSynthSettings.config\" in that directory and restart (by " +
                                    "clicking NO).\n\nCreate a configuration file now?", "Welcome to GraphSynth", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                    globalSettingsDisplay settingsDisplay = new globalSettingsDisplay();
                    settingsDisplay.applyButton.Enabled = false;
                    settingsDisplay.ShowDialog();
                    return(globalSettings.readInSettings(splashThread));
                }
                else
                {
                    splashThread.Abort();
                    Program.main.Close();
                }
                return(null);
            }
            catch (Exception e)
            {
                MessageBox.Show("The configuration file, \"GraphSynthSettings.config\" produced an error. " +
                                "The defaults will be loaded instead. Error :" + e.ToString(), "No config file.",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                settings      = new globalSettings();
                settings.hDir = settings.tryToFindHelpDir();
            }
            return(settings);
        }
Esempio n. 2
0
 public globalSettings copyTo(globalSettings copyOfSettings)
 {
     if (Program.seed != null)
     {
         copyOfSettings.defaultSeedFileName = Program.seed.name;
     }
     copyOfSettings.compiledparamRules    = this.compiledparamRules;
     copyOfSettings.confirmEachUserChoice = this.confirmEachUserChoice;
     copyOfSettings.defaultGenSteps       = this.defaultGenSteps;
     copyOfSettings.defaultSeedFileName   = this.defaultSeedFileName;
     copyOfSettings.defaultVerbosity      = this.defaultVerbosity;
     copyOfSettings.execDir = this.execDir;
     copyOfSettings.generationAfterChoice      = this.generationAfterChoice;
     copyOfSettings.generationAfterCycleLimit  = this.generationAfterCycleLimit;
     copyOfSettings.generationAfterNormal      = this.generationAfterNormal;
     copyOfSettings.generationAfterNoRules     = this.generationAfterNoRules;
     copyOfSettings.generationAfterTriggerRule = this.generationAfterTriggerRule;
     copyOfSettings.getHelpFromOnline          = this.getHelpFromOnline;
     copyOfSettings.iDir                        = this.iDir;
     copyOfSettings.hDir                        = this.hDir;
     copyOfSettings.maxRulesToApply             = this.maxRulesToApply;
     copyOfSettings.maxRulesToDisplay           = this.maxRulesToDisplay;
     copyOfSettings.numOfRuleSets               = this.numOfRuleSets;
     copyOfSettings.onlineHelpURL               = this.onlineHelpURL;
     copyOfSettings.oDir                        = this.oDir;
     copyOfSettings.recompileRules              = this.recompileRules;
     copyOfSettings.rDir                        = this.rDir;
     copyOfSettings.searchControllerInMain      = this.searchControllerInMain;
     copyOfSettings.searchControllerPlayOnStart = this.searchControllerPlayOnStart;
     copyOfSettings.defaultLayoutAlgorithm      = this.defaultLayoutAlgorithm;
     copyOfSettings.wDir                        = this.wDir;
     for (int i = 0; i != copyOfSettings.numOfRuleSets; i++)
     {
         if (Program.rulesets[i] != null)
         {
             copyOfSettings.defaultRSFileNames.Add(Program.rulesets[i].name);
         }
         else if ((Program.settings.defaultRSFileNames.Count > i) &&
                  (Program.settings.defaultRSFileNames[i] != null))
         {
             copyOfSettings.defaultRSFileNames.Add(
                 Path.GetFileName(Program.settings.defaultRSFileNames[i]));
         }
         else
         {
             copyOfSettings.defaultRSFileNames.Add("");
         }
     }
     return(copyOfSettings);
 }