/// <summary> /// Copy user's settings to the local options list /// </summary> /// <param name="orgs">Options list (one category)</param> /// <returns>true if all values are valid</returns> private Boolean OApplyLocal(Dictionary <String, OptionsManager.Option> os) { Boolean parse_error = false; foreach (DataGridViewRow r in optionsGridView.Rows) { OptionsManager.Option o = os[r.Cells[0].Value.ToString()]; if (o.Value == null) { continue; } try { if (o.Value.GetType().IsEnum) { o.Value = Enum.Parse(o.Value.GetType(), r.Cells[1].Value.ToString(), true); } else if (IsNumericType(o.Value.GetType(), ref Parse_MI)) { o.Value = Parse_MI.Invoke(o.Value, new object[] { r.Cells[1].Value.ToString() }); } else if ((o.Value is Boolean) || (o.Value is String)) { o.Value = r.Cells[1].Value; } } catch { r.Cells[1].Style.BackColor = Color.Red; r.Cells[1].Style.SelectionBackColor = Color.Red; parse_error = true; continue; } os[r.Cells[0].Value.ToString()] = o; } if (parse_error) { optionsGridView.Refresh(); System.Threading.Thread.Sleep(500); foreach (DataGridViewRow r in this.optionsGridView.Rows) { r.Cells[1].Style.BackColor = this.optionsGridView.DefaultCellStyle.BackColor; r.Cells[1].Style.SelectionBackColor = this.optionsGridView.DefaultCellStyle.SelectionBackColor; } optionsGridView.Refresh(); } return(!parse_error); }
/// <summary> /// Populate left panel /// </summary> private void PopulateLeft() { if (allopts_local == null) { return; } OptionsManager.Option[] ovs; foreach (KeyValuePair <String, Dictionary <String, OptionsManager.Option> > os in allopts_local) { ovs = new OptionsManager.Option[os.Value.Count]; os.Value.Values.CopyTo(ovs, 0); if (Array.Exists(ovs, ToDisplay) || this.owAdvancedView) { this.categorieslist.Items.Add(os.Key); } } }
private Boolean ToDisplay(OptionsManager.Option o) { return(o.Display); }