private void downRoadCross() { GaoDeRoads r = new GaoDeRoads(); r.roadCrossDowningHandler += new GaoDeRoads.RoadCrossDowningHandler(roadCrossDownHandler); r.downOverHandler += new GaoDeRoads.DownOverHandler(downEnd); r.downLoadRoadCrossByCityName(this.currentCity); }
/// <summary> /// 根据道路交叉口检测道路名称 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (this.cmbCity.SelectedItem == null) { return; } var cityName = ((ComboboxItem)this.cmbCity.SelectedItem).Text; var roadMap = new GaoDeRoads(); this.rtxbRoadNames.ReadOnly = true; var list = new List <string>(); roadMap.roadCrossDowningHandler += (roadcross, index, count) => { this.BeginInvoke(new MethodInvoker( () => { if (this.IsDisposed) { return; } this.labMessage.Text = string.Format( "{0}_{1}", roadcross.first_name, roadcross.second_name); })); list.Add(roadcross.first_name); list.Add(roadcross.second_name); }; roadMap.downOverHandler += () => { list = list.Distinct().ToList(); var temp = list; this.BeginInvoke( new MethodInvoker( () => { if (this.IsDisposed) { return; } this.rtxbRoadNames.ReadOnly = false; this.rtxbRoadNames.Text = string.Join(",", temp.Distinct().ToArray()); this.labMessage.Text = string.Format("更新成功,新增{0}条数据", temp.Count); })); var currentCity = CityRoadConfig.GetInstance().GetRoadName(cityName); list.AddRange(currentCity.Roads); list = list.Distinct().ToList(); list.Sort((m, n) => { return(string.Compare(m, n)); }); currentCity.Roads = list; CityRoadConfig.GetInstance().SaveConfig(); }; new Thread( () => { roadMap.downLoadRoadCrossByCityName(cityName); }).Start(); }
/// <summary> /// 路口数据下载 /// </summary> public void DownLoadRoadCross() { var crossDataTable = new DataTable(); crossDataTable.Columns.Add("first_name", Type.GetType("System.String")); crossDataTable.Columns.Add("second_name", Type.GetType("System.String")); crossDataTable.Columns.Add("x", Type.GetType("System.String")); crossDataTable.Columns.Add("y", Type.GetType("System.String")); crossDataTable.Columns.Add("name", Type.GetType("System.String")); var directory = this.GetCityDirectory(); var path = Path.Combine(directory, this.CityPinyin + "_roadcross.xlsx"); var road = new GaoDeRoads(); road.roadCrossDowningHandler += (roadCross, index, count) => { DataRow row = crossDataTable.NewRow(); row["first_name"] = roadCross.first_name; row["second_name"] = roadCross.second_name; row["x"] = roadCross.wgs_x; row["y"] = roadCross.wgs_y; row["name"] = string.Format("{0}_{1}", roadCross.first_name, roadCross.second_name); crossDataTable.Rows.Add(row); }; road.downOverHandler += () => { try { AsposeCellsHelper.ExportToExcel(crossDataTable, path); crossDataTable.Rows.Clear(); } catch (Exception) { Console.WriteLine("Error" + this.City); } }; road.downLoadRoadCrossByCityName(this.City); }