public GeoInfoLayer(GeoInfoLayer gl) { tableName = gl.tableName; colName = gl.colName; type = gl.type; distance = gl.distance; head = gl.head; foot = gl.foot; }
public FormLayer(GeoInfoLayer gil) { InitializeComponent(); this.SetFormStyle(false, false, false, true); gl = gil; textBoxTableName.Text = gl.TableName; textBoxColName.Text = gl.ColName; comboBoxType.SelectedIndex = gl.Type; textBoxDistance.Text = gl.Distance.ToString(); textBoxDistance.KeyPress += Pub.KeyPress_NumInput; textBoxHead.Text = gl.Head; textBoxFoot.Text = gl.Foot; }
private void ToolStripMenuItemAdd_Click(object sender, EventArgs e) { GeoInfoLayer gl = new GeoInfoLayer(); FormLayer frm = new FormLayer(gl); if (frm.ShowDialog(this) == DialogResult.OK) { ListViewItem item = new ListViewItem(gl.TableName); item.SubItems.Add(gl.ColName); item.SubItems.Add(LAYER_TYPE[gl.Type]); item.SubItems.Add(gl.Distance.ToString()); item.SubItems.Add(gl.Head); item.SubItems.Add(gl.Foot); listViewLayers.Items.Add(item); gList.Add(gl); } }
private void ToolStripMenuItemMod_Click(object sender, EventArgs e) { if (listViewLayers.SelectedItems.Count == 0) { return; } GeoInfoLayer gl = gList[listViewLayers.SelectedItems[0].Index]; FormLayer frm = new FormLayer(gl); if (frm.ShowDialog(this) == DialogResult.OK) { listViewLayers.SelectedItems[0].SubItems[0].Text = gl.TableName; listViewLayers.SelectedItems[0].SubItems[1].Text = gl.ColName; listViewLayers.SelectedItems[0].SubItems[2].Text = LAYER_TYPE[gl.Type]; listViewLayers.SelectedItems[0].SubItems[3].Text = gl.Distance.ToString(); listViewLayers.SelectedItems[0].SubItems[4].Text = gl.Head; listViewLayers.SelectedItems[0].SubItems[5].Text = gl.Foot; } }
private void ToolStripMenuItemAdd_Click(object sender, EventArgs e) { GeoInfoLayer gl = new GeoInfoLayer(); FormLayer frm = new FormLayer(gl); if(frm.ShowDialog(this) == DialogResult.OK) { ListViewItem item = new ListViewItem(gl.TableName); item.SubItems.Add(gl.ColName); item.SubItems.Add(LAYER_TYPE[gl.Type]); item.SubItems.Add(gl.Distance.ToString()); item.SubItems.Add(gl.Head); item.SubItems.Add(gl.Foot); listViewLayers.Items.Add(item); gList.Add(gl); } }
/// <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; }
/// <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); }