//loads existing settings if they exist private void load_Settings() { if (System.IO.File.Exists("settings.sd") == false) return; SimpleD.Group g = new SimpleD.Group(); String results = null; using (System.IO.StreamReader sr = new System.IO.StreamReader("settings.sd")) { results = g.FromString(sr.ReadToEnd()); } //if there is nothing to show then fill the check boxes if (results == null || results.Length == 0) { foreach (SimpleD.Property p in g.Properties) { bool chk; switch (p.Name.ToLowerInvariant()) { case "saveserver": if (bool.TryParse(p.Value, out chk)) chkSaveServer.Checked = chk; break; case "savedatabase": if (bool.TryParse(p.Value, out chk)) chkSaveDatabase.Checked = chk; break; case "savetable": if (bool.TryParse(p.Value, out chk)) chkSaveTable.Checked = chk; break; case "saveuid": if (bool.TryParse(p.Value, out chk)) chkSaveUID.Checked = chk; break; case "server": txtServer.Text = p.Value; break; case "database": txtDatabase.Text = p.Value; break; case "table": txtTable.Text = p.Value; break; case "uid": txtUID.Text = p.Value; txtPassword.Focus(); break; } } } else { MessageBox.Show("Could not parse settings.sd file!", "buggyer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void load_Settings() { if (System.IO.File.Exists("settings.sd") == false) { return; } SimpleD.Group g = new SimpleD.Group(); String results = null; using (System.IO.StreamReader sr = new System.IO.StreamReader("settings.sd")) { results = g.FromString(sr.ReadToEnd()); } if (results == null || results.Length == 0) { foreach (SimpleD.Property p in g.Properties) { bool chk; switch (p.Name.ToLowerInvariant()) { case "saveserver": if (bool.TryParse(p.Value, out chk)) { chkSaveServer.Checked = chk; } break; case "savedatabase": if (bool.TryParse(p.Value, out chk)) { chkSaveDatabase.Checked = chk; } break; case "savetable": if (bool.TryParse(p.Value, out chk)) { chkSaveTable.Checked = chk; } break; case "saveuid": if (bool.TryParse(p.Value, out chk)) { chkSaveUID.Checked = chk; } break; case "server": txtServer.Text = p.Value; break; case "database": txtDatabase.Text = p.Value; break; case "table": txtTable.Text = p.Value; break; case "uid": txtUID.Text = p.Value; txtPassword.Focus(); break; } } } else { MessageBox.Show("Could not parse settings.sd file!", "buggyer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }