/// <summary> /// 载入配置文件 /// </summary> /// <returns></returns> public static bool loadFromFile() { defaultMap.Name = "全国图"; defaultMap.File = APP_PATH + "maps\\china\\map.gst"; defaultMap.GeoInfoList.Clear(); defaultMap.GeoInfoList.Add(new GeoInfoLayer("省界", "Name", 0, 0, "", "")); defaultMap.GeoInfoList.Add(new GeoInfoLayer("市界", "Name", 0, 0, "", "")); defaultMap.GeoInfoList.Add(new GeoInfoLayer("区县界", "Name", 0, 0, "", "")); defaultMap.GeoInfoList.Add(new GeoInfoLayer("高速", "Name", 1, 200, "", "")); defaultMap.GeoInfoList.Add(new GeoInfoLayer("省道", "Name", 1, 200, "", "")); defaultMap.GeoInfoList.Add(new GeoInfoLayer("市道", "Name", 1, 150, "", "")); defaultMap.GeoInfoList.Add(new GeoInfoLayer("县道", "Name", 1, 100, "", "")); defaultMap.GeoInfoList.Add(new GeoInfoLayer("信息点", "Name", 1, 200, "", "附近")); bool ret = false; try { XmlDocument XMLDom = new XmlDocument(); XMLDom.Load(APP_PATH + FILE); XmlElement root = XMLDom.DocumentElement; host = readXmlNode(root, "host"); port = Int32.Parse(readXmlNode(root, "port")); userType = Int32.Parse(readXmlNode(root, "userType")); user = readXmlNode(root, "user"); pw = Pub.decode(readXmlNode(root, "pw")); autoLogin = (readXmlNode(root, "autoLogin") == "1"); autoReconn = (readXmlNode(root, "autoReconn") == "1"); autoAlarmList = (readXmlNode(root, "autoAlarmList") == "1"); autoWatchOnPoint = (readXmlNode(root, "autoWatchOnPoint") == "1"); autoWatchOnHandleAlarm = (readXmlNode(root, "autoWatchOnHandleAlarm") == "1"); autoChatForm = (readXmlNode(root, "autoChatForm") == "1"); autoGetCarGeoInfo = (readXmlNode(root, "autoGetCarGeoInfo") == "1"); gisPort = Int32.Parse(readXmlNode(root, "telPort")); autoStartGis = (readXmlNode(root, "autoStartGis") == "1"); myzoom = double.Parse(readXmlNode(root, "myzoom")); lo = double.Parse(readXmlNode(root, "lo")); la = double.Parse(readXmlNode(root, "la")); XmlNodeList mlist = root.GetElementsByTagName("maps"); mapList.Clear(); for (int i = 0; i < mlist.Count; i++) { MapFile mf = new MapFile(readXmlNode(mlist.Item(i) as XmlElement, "name"), readXmlNode(mlist.Item(i) as XmlElement, "file")); XmlNodeList llist = (mlist[i] as XmlElement).GetElementsByTagName("layers"); for (int j = 0; j < llist.Count; j++) { GeoInfoLayer gi = new GeoInfoLayer(); gi.TableName = readXmlNode(llist.Item(j) as XmlElement, "tableName"); gi.ColName = readXmlNode(llist.Item(j) as XmlElement, "colName"); gi.Type = Int32.Parse(readXmlNode(llist.Item(j) as XmlElement, "type")); gi.Distance = Int32.Parse(readXmlNode(llist.Item(j) as XmlElement, "distance")); gi.Head = readXmlNode(llist.Item(j) as XmlElement, "head"); gi.Foot = readXmlNode(llist.Item(j) as XmlElement, "foot"); mf.GeoInfoList.Add(gi); } mapList.Add(mf); } XmlNodeList hlist = root.GetElementsByTagName("hosts"); hostList.Clear(); for (int i = 0; i < hlist.Count; i++) { hostList.Add(new HostConfig(readXmlNode(hlist.Item(i) as XmlElement, "host"), Int32.Parse(readXmlNode(hlist.Item(i) as XmlElement, "port")))); } XmlNodeList ulist = root.GetElementsByTagName("users"); userList.Clear(); for (int i = 0; i < ulist.Count; i++) { userList.Add(new UserConfig(readXmlNode(ulist.Item(i) as XmlElement, "name"), Int32.Parse(readXmlNode(ulist.Item(i) as XmlElement, "type")))); } ret = true; } catch { saveToFile(); } return(ret); }