Exemplo n.º 1
0
        }        //Form1

        private void LoadSettings()
        {
            log_richTextBox.Text += "Loading settings...\n";
            try            //Settings
            {
                if (ini.KeyExists("probability", mainConfigSection))
                {
                    probability_numericUpDown.Value = decimal.Parse(ini.ReadINI(mainConfigSection, "probability"));
                }
                else
                {
                    Default(false, false, true);
                }
                if (ini.KeyExists("number_of_experiments", mainConfigSection))
                {
                    numberOfExperiments_numericUpDown.Value = decimal.Parse(ini.ReadINI(mainConfigSection, "number_of_experiments"));
                }
                else
                {
                    Default(false, true);
                }
                if (ini.KeyExists("height_of_matrix", mainConfigSection))
                {
                    heightOfMatrix_numericUpDown.Value = decimal.Parse(ini.ReadINI(mainConfigSection, "height_of_matrix"));
                }
                else
                {
                    Default(false, false, false, false, true);
                }
                if (ini.KeyExists("width_of_matrix", mainConfigSection))
                {
                    widthOfMatrix_numericUpDown.Value = decimal.Parse(ini.ReadINI(mainConfigSection, "width_of_matrix"));
                }
                else
                {
                    Default(false, false, false, false, false, true);
                }
                if (ini.KeyExists("probability_step", mainConfigSection))
                {
                    probabilityStep_numericUpDown.Value = decimal.Parse(ini.ReadINI(mainConfigSection, "probability_step"));
                }
                else
                {
                    Default(false, false, false, true);
                }
                if (ini.KeyExists("experimental_mode", mainConfigSection))
                {
                    experimentalMode_checkBox.Checked = bool.Parse(ini.ReadINI(mainConfigSection, "experimental_mode"));
                }
                else
                {
                    Default(false, false, false, false, false, false, true);
                }
                if (ini.KeyExists("finished", experimentConfigSection))
                {
                    finished_label.Text = ini.ReadINI(experimentConfigSection, "finished");
                }
                else
                {
                    RefreshGUI(false, true);
                }
                if (ini.KeyExists("fully_finished", experimentConfigSection))
                {
                    if (bool.Parse(ini.ReadINI(experimentConfigSection, "fully_finished")))
                    {
                        resume_button.Enabled = false;
                    }
                }
                RefreshData(true, true, true, true, true);
                RefreshGUI(true);
            }
            catch (Exception)
            {
                MessageBox.Show("config.ini is corrupted!\nAll values is set to default");
                log_richTextBox.Text += "config.ini is corrupted!\nAll values is set to default\n";
                Default(false, true, true, true, true, true, true);
                RefreshData(true, true, true, true, true);
                RefreshGUI(true);
            }
            finally
            {
                log_richTextBox.Text += "config.ini loaded correctly.\n";
            }

            try            //Deserialization
            {
                if (File.Exists(pathToPoints))
                {
                    points = Serialization.Deserialize <PointPairList>(pathToPoints);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("point of graph.xml is corrupted!\nList of points is set to empty");
                log_richTextBox.Text += "point of graph.xml is corrupted!\nList of points is set to empty\n";
            }
            finally
            {
                log_richTextBox.Text += " point of graph.xml loaded corectly\n";
            }
        }        //Loads settings