public frmConversion() { options = OptionsDB.GetOptions(); conversions = ConversionsDB.GetConversions(); int count = options.Count; string selectedText = options[count - 1].DefaultConversion; InitializeComponent(); foreach (Conversions row in conversions) { cmbConversion.DisplayMember = "Text"; cmbConversion.ValueMember = "Value"; cmbConversion.Items.Add(new { Text = row.Unit1 + " to " + row.Unit2, Value = row.Multiplier }); } cmbConversion.SelectedIndex = cmbConversion.FindStringExact(selectedText); }
//Read files and load lists. Load defaults for Show Tool Bar public frmOptions() { InitializeComponent(); conversions = ConversionsDB.GetConversions(); options = OptionsDB.GetOptions(); tempChanges = ConversionsDB.GetConversions(); int count = options.Count; if (options[count - 1].ShowToolbar == "true") { cbxShowToolbar.Checked = true; } else { cbxShowToolbar.Checked = false; } }
//Open options form and grabs the options object to write to file. Also changes toolStrip1 visibility if changed private void msbOptions_Click(object sender, EventArgs e) { frmOptions optionsForm = new frmOptions(); optionsForm.StartPosition = FormStartPosition.CenterParent; Options newOp = optionsForm.GetNewOptions(); if (newOp != null) { if (newOp.ShowToolbar == "True") { this.toolStrip1.Visible = true; } else { this.toolStrip1.Visible = false; } options.Add(newOp); OptionsDB.SaveOptions(options); } }