Example #1
0
 private void EnvironmentLoading_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_isLoading)
     {
         return;
     }
     Settings.EnvironmentLoading = EnvironmentLoading.SelectedItem.ToString();
     Settings.SaveEnvironment();
 }
Example #2
0
        private void SaveSettings_Click(object sender, EventArgs e)
        {
            // Save the settings to the XML file
            Settings.Save();

            // DirtyData tells the CC the data has possibly changed and it needs to reload it
            Settings.DirtyData = true;
            Close();
        }
Example #3
0
        private void Environment_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_isLoading)
            {
                return;
            }

            if (_dirtyData)
            {
                DialogResult manswer = MessageBox.Show("Some settings have been changed, do you want to save your changes?", "Save changes", MessageBoxButtons.YesNo);
                if (manswer == DialogResult.Yes)
                {
                    Settings.Save();
                }
                _dirtyData = false;
            }


            _tempEnvironment     = Environment.SelectedItem.ToString();
            Settings.Environment = _tempEnvironment;
            Settings.SaveEnvironment();
            LoadSettings(false);
        }
Example #4
0
        public void LoadSettings(bool silent)
        {
            // Load the settings from the XML file
            if (_tempEnvironment != "")
            {
                Settings.Environment = _tempEnvironment;
            }
            Settings.LoadEnvironment();
            Settings.Load(silent);

            if (_tempEnvironment == "")
            {
                Environment.SelectedItem = Settings.Environment;
            }
            EnvironmentLoading.SelectedItem = Settings.EnvironmentLoading;

            _isLoading = true;

            // Populate the controls on the UI with the values from the settings
            // Through the wonders of Reflection this is an automated process
            Type type = typeof(Settings);

            PropertyInfo[] props = type.GetProperties();
            foreach (var p in props)
            {
                if (p.Name == "DirtyData")
                {
                    continue;
                }
                if (p.Name == "Environment")
                {
                    continue;
                }
                if (p.Name == "EnvironmentLoading")
                {
                    continue;
                }

                PropertyInfo pInfo     = type.GetProperty(p.Name);
                object       propValue = pInfo.GetValue(p.Name, null);

                foreach (TabPage tab in tabControl1.Controls)
                {
                    foreach (GroupBox gb in tab.Controls)
                    {
                        foreach (object obj in gb.Controls)
                        {
                            // Populate all combo boxes, this will be the most common
                            if (obj is ComboBox)
                            {
                                ComboBox cbox = (ComboBox)obj;
                                if (cbox.Name == p.Name)
                                {
                                    cbox.SelectedItem = propValue.ToString();
                                    break;
                                }
                            }

                            // Populate all progress bars, mostly for health or mana
                            else if (obj is ProgressBar)
                            {
                                ProgressBar pbar = (ProgressBar)obj;
                                if (pbar.Name == p.Name)
                                {
                                    pbar.Value = (int)propValue;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            _isLoading = false;
        }