public void Save(XmlScribe scribe) { scribe.Attribute("name", Name); scribe.Attribute("x", Position.X); scribe.Attribute("y", Position.Y); scribe.Attribute("w", Size.X); scribe.Attribute("h", Size.Y); if (IsDark) { scribe.Attribute("isDark", IsDark); } scribe.Attribute("description", PrimaryDescription); if (!string.IsNullOrEmpty(Objects) || ObjectsPosition != DefaultObjectsPosition) { scribe.StartElement("objects"); if (ObjectsPosition != DefaultObjectsPosition) { scribe.Attribute("at", ObjectsPosition); } if (!string.IsNullOrEmpty(Objects)) { scribe.Value(Objects.Replace("\r", string.Empty).Replace("|", "\\|").Replace("\n", "|")); } scribe.EndElement(); } }
public static void Save(XmlScribe scribe) { // save colors scribe.StartElement("colors"); for (int index = 0; index < Colors.Count; ++index) { string colorName; if (Colors.ToName(index, out colorName)) { scribe.Element(colorName, Color[index]); } } scribe.EndElement(); // save fonts scribe.StartElement("fonts"); SaveFont(scribe, s_largeFont, "room"); SaveFont(scribe, s_smallFont, "object"); SaveFont(scribe, s_lineFont, "line"); scribe.EndElement(); scribe.StartElement("grid"); scribe.Element("snapTo", s_snapToGrid); scribe.Element("visible", s_isGridVisible); scribe.Element("showOrigin", s_showOrigin); scribe.Element("size", s_gridSize); scribe.EndElement(); scribe.StartElement("lines"); scribe.Element("width", s_lineWidth); scribe.Element("handDrawn", s_handDrawn); scribe.Element("arrowSize", s_connectionArrowSize); scribe.Element("textOffset", s_textOffsetFromConnection); scribe.EndElement(); scribe.StartElement("rooms"); scribe.Element("darknessStripeSize", s_darknessStripeSize); scribe.Element("objectListOffset", s_objectListOffsetFromRoom); scribe.Element("connectionStalkLength", s_connectionStalkLength); scribe.Element("preferredDistanceBetweenRooms", s_preferredDistanceBetweenRooms); scribe.EndElement(); scribe.StartElement("ui"); scribe.Element("handleSize", s_handleSize); scribe.Element("snapToElementSize", s_snapToElementSize); scribe.EndElement(); scribe.StartElement("keypadNavigation"); scribe.Element("creationModifier", ModifierKeysToString(s_keypadNavigationCreationModifier)); scribe.Element("unexploredModifier", ModifierKeysToString(s_keypadNavigationUnexploredModifier)); scribe.EndElement(); SaveApplicationSettings(); }
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); } }
private void SaveElement(XmlScribe scribe, Element element) { if (element is Room) { scribe.StartElement("room"); scribe.Attribute("id", element.ID); ((Room)element).Save(scribe); scribe.EndElement(); } else if (element is Connection) { scribe.StartElement("line"); scribe.Attribute("id", element.ID); ((Connection)element).Save(scribe); scribe.EndElement(); } }
private static void saveElement(XmlScribe scribe, Element element) { if (element.GetType() == typeof(Room)) { scribe.StartElement("room"); scribe.Attribute("id", element.ID); ((Room)element).Save(scribe); scribe.EndElement(); } else if (element.GetType() == typeof(Connection)) { scribe.StartElement("line"); scribe.Attribute("id", element.ID); ((Connection)element).Save(scribe); scribe.EndElement(); } }
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) { } }
private static void SaveFont(XmlScribe scribe, Font font, string name) { scribe.StartElement(name); scribe.Attribute("size", font.Size); if ((font.Style & FontStyle.Bold) == FontStyle.Bold) { scribe.Attribute("bold", true); } if ((font.Style & FontStyle.Italic) == FontStyle.Italic) { scribe.Attribute("italic", true); } if ((font.Style & FontStyle.Underline) == FontStyle.Underline) { scribe.Attribute("underline", true); } if ((font.Style & FontStyle.Strikeout) == FontStyle.Strikeout) { scribe.Attribute("strikeout", true); } scribe.Value(Drawing.FontName(font)); scribe.EndElement(); }
private static void saveElement(XmlScribe scribe, Element element) { if (element.GetType() == typeof(Room)) { scribe.StartElement("room"); scribe.Attribute("id", element.ID); ((Room) element).Save(scribe); scribe.EndElement(); } else if (element.GetType() == typeof(Connection)) { scribe.StartElement("line"); scribe.Attribute("id", element.ID); ((Connection) element).Save(scribe); scribe.EndElement(); } }
public void Save(XmlScribe scribe) { if (ConnectionColor != Color.Transparent) { scribe.Attribute("color", Colors.SaveColor(ConnectionColor)); } if (Style != DefaultStyle) { switch (Style) { case ConnectionStyle.Solid: scribe.Attribute("style", "solid"); break; case ConnectionStyle.Dashed: scribe.Attribute("style", "dashed"); break; } } if (Flow != DefaultFlow) { switch (Flow) { case ConnectionFlow.OneWay: scribe.Attribute("flow", "oneWay"); break; case ConnectionFlow.TwoWay: scribe.Attribute("flow", "twoWay"); break; } } if (!string.IsNullOrEmpty(StartText)) { scribe.Attribute("startText", StartText); } if (!string.IsNullOrEmpty(MidText)) { scribe.Attribute("midText", MidText); } if (!string.IsNullOrEmpty(EndText)) { scribe.Attribute("endText", EndText); } var index = 0; foreach (var vertex in VertexList) { if (vertex.Port != null) { scribe.StartElement("dock"); scribe.Attribute("index", index); scribe.Attribute("id", vertex.Port.Owner.ID); scribe.Attribute("port", vertex.Port.ID); scribe.EndElement(); } else { scribe.StartElement("point"); scribe.Attribute("index", index); scribe.Attribute("x", vertex.Position.X); scribe.Attribute("y", vertex.Position.Y); scribe.EndElement(); } ++index; } }
public void Save(XmlScribe scribe) { if (ConnectionColor != Color.Transparent) scribe.Attribute("color", Colors.SaveColor(ConnectionColor)); if (Style != DefaultStyle) { switch (Style) { case ConnectionStyle.Solid: scribe.Attribute("style", "solid"); break; case ConnectionStyle.Dashed: scribe.Attribute("style", "dashed"); break; } } if (Flow != DefaultFlow) { switch (Flow) { case ConnectionFlow.OneWay: scribe.Attribute("flow", "oneWay"); break; case ConnectionFlow.TwoWay: scribe.Attribute("flow", "twoWay"); break; } } if (!string.IsNullOrEmpty(StartText)) { scribe.Attribute("startText", StartText); } if (!string.IsNullOrEmpty(MidText)) { scribe.Attribute("midText", MidText); } if (!string.IsNullOrEmpty(EndText)) { scribe.Attribute("endText", EndText); } var index = 0; foreach (var vertex in VertexList) { if (vertex.Port != null) { scribe.StartElement("dock"); scribe.Attribute("index", index); scribe.Attribute("id", vertex.Port.Owner.ID); scribe.Attribute("port", vertex.Port.ID); scribe.EndElement(); } else { scribe.StartElement("point"); scribe.Attribute("index", index); scribe.Attribute("x", vertex.Position.X); scribe.Attribute("y", vertex.Position.Y); scribe.EndElement(); } ++index; } }
public void Save(XmlScribe scribe) { scribe.Attribute("name", Name); scribe.Attribute("x", Position.X); scribe.Attribute("y", Position.Y); scribe.Attribute("w", Size.X); scribe.Attribute("h", Size.Y); if (IsDark) { scribe.Attribute("isDark", IsDark); } scribe.Attribute("description", PrimaryDescription); if (!string.IsNullOrEmpty(Objects) || ObjectsPosition != DefaultObjectsPosition) { scribe.StartElement("objects"); if (ObjectsPosition != DefaultObjectsPosition) { scribe.Attribute("at", ObjectsPosition); } if (!string.IsNullOrEmpty(Objects)) { scribe.Value(Objects.Replace("\r", string.Empty).Replace("|", "\\|").Replace("\n","|")); } scribe.EndElement(); } }
public void Save(XmlScribe scribe) { scribe.Attribute("name", Name); scribe.Attribute("x", Position.X); scribe.Attribute("y", Position.Y); scribe.Attribute("w", Size.X); scribe.Attribute("h", Size.Y); if (IsDark) { scribe.Attribute("isDark", IsDark); } scribe.Attribute("description", PrimaryDescription); // Added for room specific fill color, down to the next comment string rValue = ""; string bValue = ""; string gValue = ""; if (RoomFill.R < 16) { rValue = "0" + RoomFill.R.ToString("X"); } else { rValue = RoomFill.R.ToString("X"); } if (RoomFill.G < 16) { gValue = "0" + RoomFill.G.ToString("X"); } else { gValue = RoomFill.G.ToString("X"); } if (RoomFill.B < 16) { bValue = "0" + RoomFill.B.ToString("X"); } else { bValue = RoomFill.B.ToString("X"); } string colorValue = "#" + rValue + "" + gValue + "" + bValue; scribe.Attribute("roomFill", colorValue); if (SecondFill.R < 16) { rValue = "0" + SecondFill.R.ToString("X"); } else { rValue = SecondFill.R.ToString("X"); } if (SecondFill.G < 16) { gValue = "0" + SecondFill.G.ToString("X"); } else { gValue = SecondFill.G.ToString("X"); } if (SecondFill.B < 16) { bValue = "0" + SecondFill.B.ToString("X"); } else { bValue = SecondFill.B.ToString("X"); } colorValue = "#" + rValue + "" + gValue + "" + bValue; scribe.Attribute("secondFill", colorValue); scribe.Attribute("secondFillLocation", SecondFillLocation); if (RoomBorder.R < 16) { rValue = "0" + RoomBorder.R.ToString("X"); } else { rValue = RoomBorder.R.ToString("X"); } if (RoomBorder.G < 16) { gValue = "0" + RoomBorder.G.ToString("X"); } else { gValue = RoomBorder.G.ToString("X"); } if (RoomBorder.B < 16) { bValue = "0" + RoomBorder.B.ToString("X"); } else { bValue = RoomBorder.B.ToString("X"); } colorValue = "#" + rValue + "" + gValue + "" + bValue; scribe.Attribute("roomBorder", colorValue); if (RoomLargeText.R < 16) { rValue = "0" + RoomLargeText.R.ToString("X"); } else { rValue = RoomLargeText.R.ToString("X"); } if (RoomLargeText.G < 16) { gValue = "0" + RoomLargeText.G.ToString("X"); } else { gValue = RoomLargeText.G.ToString("X"); } if (RoomLargeText.B < 16) { bValue = "0" + RoomLargeText.B.ToString("X"); } else { bValue = RoomLargeText.B.ToString("X"); } colorValue = "#" + rValue + "" + gValue + "" + bValue; scribe.Attribute("roomLargeText", colorValue); if (RoomSmallText.R < 16) { rValue = "0" + RoomSmallText.R.ToString("X"); } else { rValue = RoomSmallText.R.ToString("X"); } if (RoomSmallText.G < 16) { gValue = "0" + RoomSmallText.G.ToString("X"); } else { gValue = RoomSmallText.G.ToString("X"); } if (RoomSmallText.B < 16) { bValue = "0" + RoomSmallText.B.ToString("X"); } else { bValue = RoomSmallText.B.ToString("X"); } colorValue = "#" + rValue + "" + gValue + "" + bValue; scribe.Attribute("roomSmallText", colorValue); // Up to this point was added to turn colors to Hex code for xmpl saving/loading if (!string.IsNullOrEmpty(Objects) || ObjectsPosition != DefaultObjectsPosition) { scribe.StartElement("objects"); if (ObjectsPosition != DefaultObjectsPosition) { scribe.Attribute("at", ObjectsPosition); } if (!string.IsNullOrEmpty(Objects)) { scribe.Value(Objects.Replace("\r", string.Empty).Replace("|", "\\|").Replace("\n", "|")); } scribe.EndElement(); } }