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();
     }
 }
Beispiel #2
0
        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;
            }
        }