Esempio n. 1
0
        public void WriteStyleMap(StyleMap map)
        {
            try
            {
                if (map != null && map.HightLightedStyleUrl != null && map.NormalStyleUrl != null)
                {
                    WriteStartElement("StyleMap");
                    WriteAttributeString("id", map.ID);

                    WriteStartElement("Pair");
                    WriteElementString("key", "normal");
                    WriteElementString("styleUrl", map.NormalStyleUrl);
                    WriteEndElement();

                    WriteStartElement("Pair");
                    WriteElementString("key", "highlight");
                    WriteElementString("styleUrl", map.HightLightedStyleUrl);
                    WriteEndElement();

                    WriteEndElement();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("WriteStyleMap Error: " + ex.Message);
            }
        }
Esempio n. 2
0
        private static StyleMap ParseStyleMap(XmlNode xnode)
        {
            StyleMap map = new StyleMap(xnode.Attributes[ATTR_ID]?.FirstChild.Value);

            foreach (XmlNode node in xnode.ChildNodes)
            {
                if (node.Name.ToLower() == "pair")
                {
                    bool   isHighlight = false;
                    string url         = null;

                    foreach (XmlNode inode in node.ChildNodes)
                    {
                        switch (inode.Name.ToLower())
                        {
                        case "key": isHighlight = inode.FirstChild.Value.ToLower() != "normal"; break;

                        case "styleurl": url = inode.FirstChild.Value; break;
                        }
                    }

                    if (url != null)
                    {
                        if (isHighlight)
                        {
                            map.HightLightedStyleUrl = url;
                        }
                        else
                        {
                            map.NormalStyleUrl = url;
                        }
                    }
                }
            }

            return(map);
        }