internal static MapProject ReadXml(XmlElement projectElement, string rootPath, TiledSFMap mapRef) { MapProject mapProject = new MapProject(); XmlNodeList colorList = projectElement.GetElementsByTagName("MapBackColor"); if (colorList != null && colorList.Count > 0) { mapProject.BackgroundColor = ColorTranslator.FromHtml(colorList[0].InnerText); } else if (mapRef != null) { mapProject.BackgroundColor = mapRef.BackColor; } //clear layers List<EGIS.ShapeFileLib.ShapeFile> myShapefiles = new List<EGIS.ShapeFileLib.ShapeFile>(); XmlNodeList layerNodeList = projectElement.GetElementsByTagName("layers"); XmlNodeList sfList = ((XmlElement)layerNodeList[0]).GetElementsByTagName("shapefile"); if (sfList != null && sfList.Count > 0) { for (int n = 0; n < sfList.Count; n++) { EGIS.ShapeFileLib.ShapeFile sf = new EGIS.ShapeFileLib.ShapeFile(); XmlElement elem = sfList[n] as XmlElement; elem.GetElementsByTagName("path")[0].InnerText = rootPath + elem.GetElementsByTagName("path")[0].InnerText; sf.ReadXml(elem); myShapefiles.Add(sf); } } //EGIS.ShapeFileLib.ShapeFile.UseMercatorProjection = false; mapProject.Layers = myShapefiles; return mapProject; }
internal static MapProject ReadProject(string absPath, TiledSFMap mapRef) { string basePath = absPath.Substring(0, absPath.LastIndexOf('\\') + 1); XmlDocument doc = new XmlDocument(); doc.Load(absPath); XmlElement prjElement = (XmlElement)doc.GetElementsByTagName("sfproject").Item(0); //string version = prjElement.GetAttribute("version"); return ReadXml(prjElement, basePath, mapRef); }