private void btnSave_Click(object sender, EventArgs e) { AutoSettings autoSettings = new AutoSettings(); foreach (var cotrl in tableLayoutPanel1.Controls) { AutoClickControl ctrl = ((AutoClickControl)cotrl); ctrl.UpdateSetings(); ctrl.Dock = DockStyle.Fill; autoSettings.settings.Add(ctrl.autoSetting); } SaveLoad.Save(autoSettings); }
public static string Serialise(AutoSettings autoSetting) { XmlSerializer xsSubmit = new XmlSerializer(typeof(AutoSettings)); var xml = ""; using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww)) { xsSubmit.Serialize(writer, autoSetting); xml = sww.ToString(); // Your XML } } return(xml); }
public static void Save(AutoSettings autoSettings) { File.WriteAllText(fileName, Serialiser.Serialise(autoSettings)); }