public bool Save() { var settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; settings.Indent = true; settings.IndentChars = "\t"; try { using (var scribe = XmlScribe.Create(FileName)) { scribe.StartElement("trizbort"); scribe.StartElement("info"); if (!string.IsNullOrEmpty(Title)) { scribe.Element("title", Title); } if (!string.IsNullOrEmpty(Author)) { scribe.Element("author", Author); } if (!string.IsNullOrEmpty(Description)) { scribe.Element("description", Description); } if (!string.IsNullOrEmpty(History)) { scribe.Element("history", History); } scribe.EndElement(); scribe.StartElement("map"); foreach (var element in Elements) { SaveElement(scribe, element); } scribe.EndElement(); scribe.StartElement("settings"); Settings.Save(scribe); scribe.EndElement(); } IsDirty = false; return(true); } catch (Exception ex) { MessageBox.Show(Program.MainForm, string.Format("There was a problem saving the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
public static void SaveApplicationSettings() { try { Directory.CreateDirectory(Path.GetDirectoryName(ApplicationSettingsPath)); using (var scribe = XmlScribe.Create(ApplicationSettingsPath)) { scribe.StartElement("settings"); scribe.Element("dontCareAboutVersion", DontCareAboutVersion.ToString()); scribe.Element("infiniteScrollBounds", InfiniteScrollBounds); scribe.Element("showMiniMap", ShowMiniMap); scribe.Element("invertMouseWheel", InvertMouseWheel); scribe.Element("defaultImageType", DefaultImageType); scribe.Element("saveAt100", SaveAt100); scribe.Element("saveToPDF", SaveToPDF); scribe.Element("saveToImage", SaveToImage); scribe.Element("lastProjectFileName", LastProjectFileName); scribe.Element("lastExportedImageFileName", LastExportImageFileName); scribe.Element("lastExportedInform7FileName", LastExportInform7FileName); scribe.Element("lastExportedInform6FileName", LastExportInform6FileName); scribe.Element("lastExportedTadsFileName", LastExportTadsFileName); scribe.StartElement("recentProjects"); var index = 0; foreach (var fileName in RecentProjects) { scribe.Element(string.Format("fileName{0}", index++), fileName); } scribe.EndElement(); scribe.StartElement("automap"); scribe.Element("transcriptFileName", s_automap.FileName); scribe.Element("verboseTranscript", s_automap.VerboseTranscript); scribe.Element("assumeRoomsWithSameNameAreSameRoom", s_automap.AssumeRoomsWithSameNameAreSameRoom); scribe.Element("guessExits", s_automap.GuessExits); scribe.Element("addObjectCommand", s_automap.AddObjectCommand); scribe.Element("addRegionCommand", s_automap.AddRegionCommand); scribe.EndElement(); } } catch (Exception) { } }