//TODO This method does not do any type checking private void ioHandle(Control con, IniMode im) { foreach (Control c in con.Controls) { string strSection = con.Text; // Any control with the "exclude" tag will not be saved if (c.Tag != null && c.Tag.ToString() == "exclude") { continue; } if (c.GetType().ToString() == "System.Windows.Forms.TextBox") { if (im == IniMode.Write) { store(strSection, c.Name, c.Text); } else if (im == IniMode.Read) { ((TextBox)c).Text = retrieve(strSection, c.Name); } } else if (c.GetType().ToString() == "System.Windows.Forms.NumericUpDown") { if (im == IniMode.Write) { store(strSection, c.Name, ((NumericUpDown)c).Value.ToString()); } else if (im == IniMode.Read) { ((NumericUpDown)c).Value = Convert.ToDecimal(retrieveDecimal(strSection, c.Name)); } } else if (c.GetType().ToString() == "System.Windows.Forms.RadioButton") { if (im == IniMode.Write) { store(strSection, c.Name, ((RadioButton)c).Checked.ToString()); } else if (im == IniMode.Read) { ((RadioButton)c).Checked = Convert.ToBoolean(retrieveBoolean(strSection, c.Name)); } } else if (c.GetType().ToString() == "System.Windows.Forms.CheckBox") { if (im == IniMode.Write) { store(strSection, c.Name, ((CheckBox)c).Checked.ToString()); } else if (im == IniMode.Read) { ((CheckBox)c).Checked = Convert.ToBoolean(retrieveBoolean(strSection, c.Name)); } } } }
//TODO This method does not do any type checking private void ioHandle(Control con, IniMode im) { foreach (Control c in con.Controls) { string strSection = con.Text; // Any control with the "exclude" tag will not be saved if (c.Tag != null && c.Tag.ToString()=="exclude") continue; if (c.GetType().ToString() == "System.Windows.Forms.TextBox") { if (im == IniMode.Write) store(strSection,c.Name,c.Text); else if (im == IniMode.Read) ((TextBox)c).Text = retrieve(strSection,c.Name); } else if (c.GetType().ToString() == "System.Windows.Forms.NumericUpDown") { if (im == IniMode.Write) store(strSection,c.Name,((NumericUpDown)c).Value.ToString()); else if (im == IniMode.Read) ((NumericUpDown)c).Value = Convert.ToDecimal(retrieveDecimal(strSection,c.Name)); } else if (c.GetType().ToString() == "System.Windows.Forms.RadioButton") { if (im == IniMode.Write) store(strSection,c.Name,((RadioButton)c).Checked.ToString()); else if (im == IniMode.Read) ((RadioButton)c).Checked = Convert.ToBoolean(retrieveBoolean(strSection,c.Name)); } else if (c.GetType().ToString() == "System.Windows.Forms.CheckBox") { if (im == IniMode.Write) store(strSection,c.Name,((CheckBox)c).Checked.ToString()); else if (im == IniMode.Read) ((CheckBox)c).Checked = Convert.ToBoolean(retrieveBoolean(strSection,c.Name)); } } }