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(); } }
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(); }
public static void Save(XmlScribe scribe) { // save colors scribe.StartElement("colors"); for (var index = 0; index < Colors.Count; ++index) { string colorName; if (Colors.ToName(index, out colorName)) { scribe.Element(colorName, Color[index]); } } scribe.EndElement(); scribe.StartElement("regions"); foreach (var region in Regions.OrderBy(p => p.RegionName)) { scribe.StartElement(region.FixupRegionNameForSave()); scribe.Attribute("Name", region.RegionName); scribe.Attribute("TextColor", region.TextColor); scribe.Value(region.RColor); scribe.EndElement(); } 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", HandDrawnUnchecked); 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 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 (var index = 0; index < Colors.Count; ++index) { string colorName; if (Colors.ToName(index, out colorName)) { scribe.Element(colorName, Color[index]); } } scribe.EndElement(); scribe.StartElement("regions"); foreach (var region in Regions.OrderBy(p=>p.RegionName)) { scribe.StartElement(region.FixupRegionNameForSave()); scribe.Attribute("Name", region.RegionName); scribe.Attribute("TextColor", region.TextColor); scribe.Value(region.RColor); scribe.EndElement(); } 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", HandDrawnUnchecked); 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 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(); } }