private 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 override bool Save(string fileName) { try { using (var scribe = XmlScribe.Create(fileName)) { scribe.StartElement("trizbort"); scribe.Attribute("version", System.Windows.Forms.Application.ProductVersion); scribe.StartElement("info"); if (!string.IsNullOrEmpty(project.Title)) { scribe.Element("title", project.Title); } if (!string.IsNullOrEmpty(project.Author)) { scribe.Element("author", project.Author); } if (!string.IsNullOrEmpty(project.Description)) { scribe.Element("description", project.Description); } if (!string.IsNullOrEmpty(project.History)) { scribe.Element("history", project.History); } scribe.EndElement(); scribe.StartElement("map"); foreach (var element in project.Elements) { saveElement(scribe, element); } scribe.EndElement(); scribe.StartElement("settings"); Settings.Save(scribe); scribe.EndElement(); } return(true); } catch (Exception ex) { throw; } }
public void Save(XmlScribe scribe) { scribe.Attribute("name", Name); scribe.Attribute("description", Description); if (Door != null) { scribe.Attribute("door", true); scribe.Attribute("lockable", door.Lockable); scribe.Attribute("openable", door.Openable); scribe.Attribute("locked", door.Locked); scribe.Attribute("open", door.Open); } if (ConnectionColor != Color.Transparent) { scribe.Attribute("color", Colors.SaveColor(ConnectionColor)); } if (Style != DEFAULT_STYLE) { switch (Style) { case ConnectionStyle.Solid: scribe.Attribute("style", "solid"); break; case ConnectionStyle.Dashed: scribe.Attribute("style", "dashed"); break; } } if (Flow != DEFAULT_FLOW) { 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; } }