private void reportModeRun() { //委托删除和添加 DelegateClearAllMarks dcam = new DelegateClearAllMarks(clearAllMarker_delegate); this.Invoke(dcam, new Object[] { }); DelegateAddMarker dam = new DelegateAddMarker(addMarker_delegate); int i = 0; while (m_bReportMode && i < m_markerInfoList.Count) { if (m_bCertainKeyPressed) { MarkerInfo markInfo = (MarkerInfo)m_markerInfoList[i]; this.Invoke(dam, new Object[] { markInfo }); Thread.Sleep(10); m_bCertainKeyPressed = false; i++; } else { Thread.Sleep(30); } } m_bReportMode = false; DelegateUpdateUIControl duic = new DelegateUpdateUIControl(updateUiControl_delegate); this.Invoke(duic, new object[] { }); }
//////////////////////////////////////////////////////////////////////////**********20141014 //将每一个标志牌都以富标注的形式添加到百度地图上 private void button_MarkPointOnce_Click(object sender, EventArgs e) { if (m_markerInfoList.Count == 0) { MessageBox.Show("请先加载EXCEL数据文件!"); return; } //调用JS脚本完成删除和添加功能 webBrowser_BaiduMap.Document.InvokeScript("CSharpCallJs_clearAllMarker", new Object[] { }); for (int i = 0; i < m_markerInfoList.Count; i++) { MarkerInfo markInfo = (MarkerInfo)m_markerInfoList[i]; webBrowser_BaiduMap.Document.InvokeScript("CSharpCallJs_addMarker", new Object[] { markInfo.m_strTitle, markInfo.m_strContent, markInfo.m_strLocation, markInfo.m_strImageName }); } }
//////////////////////////////////////////////////////////////////////////**********20141014 //从EXCEL文件中读入数据, 生成一个对象链表 private void OpenExcel(string strFileName) { Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); if (excel == null) { MessageBox.Show("无法访问Excel文件!"); return; } excel.Visible = false; excel.UserControl = true; // 以只读的形式打开EXCEL文件 Microsoft.Office.Interop.Excel._Workbook xBook = excel.Application.Workbooks.Open(strFileName, Missing.Value, true, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, true, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); //取得第一个工作薄 Microsoft.Office.Interop.Excel._Worksheet xSheet = (Microsoft.Office.Interop.Excel._Worksheet)xBook.Worksheets.get_Item(1); int numRow = xSheet.UsedRange.Cells.Rows.Count; //得到行数 int numCol = xSheet.UsedRange.Cells.Columns.Count; //得到列数 string[] strArray = { "序号", "线路名称", "检查时间", "桩号", "经度", "纬度", "左/右侧", "标志类型", "架设形式", "版面形式", "版面宽度", "版面高度", "照片名称" }; int numCol2 = strArray.Length; //for (int i = 0; i < numCol; i++ ) for (int i = 0; i < numCol2; i++) { if (!xSheet.Cells[1, i + 1].Text.ToString().Equals(strArray[i])) { excel.Quit(); MessageBox.Show("错误, 数据格式不一致!"); return; } } m_markerInfoList.Clear(); for (int i = 1; i < numRow; i++) { string strRoadName = xSheet.Cells[i + 1, 2].Text.ToString(); if (strRoadName.Trim().Equals("")) { break; } string strCheckTime = xSheet.Cells[i + 1, 3].Text.ToString(); string strPointNumber = xSheet.Cells[i + 1, 4].Text.ToString(); string strLongitude = xSheet.Cells[i + 1, 5].Text.ToString(); string strLatitude = xSheet.Cells[i + 1, 6].Text.ToString(); string strLeftRight = xSheet.Cells[i + 1, 7].Text.ToString(); string strMarkType = xSheet.Cells[i + 1, 8].Text.ToString(); string strlayStyle = xSheet.Cells[i + 1, 9].Text.ToString(); string strPlateStyle = xSheet.Cells[i + 1, 10].Text.ToString(); string strImageName = xSheet.Cells[i + 1, 13].Text.ToString(); string strTitle = "道路" + strLeftRight + "侧, " + "桩号: " + strPointNumber; string strContent = "线路名称: " + strRoadName + "<br>检查时间: " + strCheckTime + "<br>标志类型: " + strMarkType + "<br>架设形式: " + strlayStyle + "<br>版面形式: " + strPlateStyle; string strLocation = Convert.ToDouble(strLongitude) / 1e6 + "|" + Convert.ToDouble(strLatitude) / 1e6; //每条记录生成一个对象 MarkerInfo markInfo = new MarkerInfo(strTitle, strContent, strLocation, strImageName); m_markerInfoList.Add(markInfo); } excel.Quit(); MessageBox.Show("数据加载完毕!"); }
private void addMarker_delegate(MarkerInfo markInfo) { //调用JS脚本完成添加功能 webBrowser_BaiduMap.Document.InvokeScript("CSharpCallJs_addMarker_ReportMode", new Object[] { markInfo.m_strTitle, markInfo.m_strContent, markInfo.m_strLocation, markInfo.m_strImageName }); }