private void PopulatePresets() { try { P = Presets.LoadFromXml(); this.comboSelectPreset.DataSource = null; this.comboSelectPreset.DataSource = P; this.comboSelectPreset.DisplayMember = "Name"; this.comboSelectPreset.ValueMember = "Position"; } catch { } }
public void SaveToXml() { try { Presets.CheckFilePaths(); XmlSerializer serializer = new XmlSerializer(typeof(Presets)); TextWriter writer = new StreamWriter(xmlLocation); serializer.Serialize(writer, this); writer.Close(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
public static Presets LoadFromXml() { try { Presets.CheckFilePaths(); TextReader reader = new StreamReader(xmlLocation); XmlSerializer serializer = new XmlSerializer(typeof(Presets)); Presets p = (Presets)serializer.Deserialize(reader); reader.Close(); return(p); } catch { return(new Presets()); } }