private void btnExport_Click(object sender, EventArgs e) { if (!CheckJoystick()) { return; } if (sfdExport.ShowDialog(this.ParentForm) != DialogResult.OK) { return; } using (var sfw = new StreamWriter(sfdExport.FileName, false, Encoding.UTF8)) { var xdoc = new XDocument(_joystickInfo.Serialize()); xdoc.Save(sfw); } }
private void SaveFile(string fname) { var file = new XDocument(); var root = new XElement("Config"); file.Add(root); if (__JoyInfo != null) { root.Add(__JoyInfo.Serialize()); } if (__Settings != null) { root.Add(__Settings.Serialize()); } if (modelsTabSwitch.TabPages.Count > 0) { var xpanels = new XElement("Models"); root.Add(xpanels); foreach (var panel in Panels) { xpanels.Add(panel.Serialize()); } } using (var writer = File.CreateText(fname)) { file.Save(writer); writer.Flush(); } CurrentFileName = fname; SetSavedState(); SetFileState(); AddFileToLastFiles(fname); SaveLastList(); }