using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using Cyberpipe.PATM_Forms; using DevComponents.DotNetBar; using GeoScene.Data; using GeoScene.Globe; namespace Cyberpipe { public partial class FrmAllWorkWellStatis : Office2007Form { private MainFrm.DataGridViewDelegate m_InitDataGridViewX1; private Dictionary<string, GSOFeatures> map; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; private MainFrm.PageControlStuct _pageControl; public FrmAllWorkWellStatis(GSOGlobeControl ctl, GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1, MainFrm.PageControlStuct pageControl) { InitializeComponent(); globeControl1 = ctl; m_InitDataGridViewX1 = InitDataGridViewX1; this.polygon = polygon; _pageControl = pageControl; } private void FrmAllPipelineStatis_Load(object sender, EventArgs e) { map = getAccsMap(polygon); drawChart(); } private void drawChart() { try { // Set axis title chartAllAreaPipeline.Series.Add("井盖"); chartAllAreaPipeline.ChartAreas["ChartArea1"].AxisX.Title = "井盖类型"; chartAllAreaPipeline.ChartAreas["ChartArea1"].AxisY.Title = "井盖个数"; chartAllAreaPipeline.ChartAreas["ChartArea1"].AxisX.Interval = 1; LabelStyle labeStyleAxisX = new LabelStyle(); labeStyleAxisX.Angle = -45; labeStyleAxisX.Enabled = true; chartAllAreaPipeline.ChartAreas["ChartArea1"].AxisX.LabelStyle = labeStyleAxisX; chartAllAreaPipeline.Series["井盖"].ChartType = SeriesChartType.Column;//"井盖" chartAllAreaPipeline.Series["井盖"]["DrawingStyle"] = "Cylinder"; Dictionary<string, int> workWellLengthAndType = new Dictionary<string, int>(); foreach (KeyValuePair<string, GSOFeatures> kv in map) { workWellLengthAndType.Add(kv.Key, kv.Value.Length); } chartAllAreaPipeline.Series["井盖"].Points.DataBindXY(workWellLengthAndType.Keys, workWellLengthAndType.Values); for (int m = 0; m < workWellLengthAndType.Values.Count; m++) { if (chartAllAreaPipeline.Series["井盖"].Points[m].YValues[0].ToString().Trim() != "0") { chartAllAreaPipeline.Series["井盖"].Points[m].Label = chartAllAreaPipeline.Series[0].Points[m].YValues[0].ToString(); } } } catch (Exception ex) { LogError.PublishError(ex); } } private void chartAllAreaPipeline_MouseClick(object sender, MouseEventArgs e) { HitTestResult result = chartAllAreaPipeline.HitTest(e.X, e.Y, true); int indexHit = result.PointIndex; if (indexHit < 0) return; //GSOFeatures fs = list[indexHit]; // string sql = ""; string pipetype = chartAllAreaPipeline.Series["井盖"].Points[indexHit].AxisLabel; GSOFeatures fs = map[pipetype]; string layername = ""; if (pipetype.EndsWith("窖井") || pipetype.EndsWith("表井") || (pipetype.EndsWith("窨井")) || pipetype.EndsWith("孔") || pipetype.EndsWith("篦")) { layername = pipetype.Substring(0, pipetype.Length - 2) + "管线附属物"; } else { layername = pipetype.Substring(0, pipetype.Length - 3) + "管线附属物"; } //MainFrm.m_CurrentQueryLayer = layername; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); if (layer == null || fs.Length <= 0) { return; } // sql = "select " + GetpipeLineFields.GetFields(layername, globeControl1) + " from " + layer.Name; // sql += " where 1>2 "; // // for (int i = 0; i < fs.Length; i++) // { // if (fs[i].GetFieldDefn("编号") == null) continue; // sql += " or 编号 = '" + fs[i].GetValue("编号") + "'"; // // } // // DataTable dt = OledbHelper.QueryTable(sql); // string strLable = " 井盖类型:" + pipetype + "||共有:" + Convert.ToString(dt.Rows.Count) + "条记录"; // m_InitDataGridViewX1(dt, strLable, layername, true); List<string> list = new List<string>(); for (int i = 0; i < fs.Length; i++) { string value = (string)fs[i].GetValue("编号"); if (value == null) continue; list.Add(value); } PaginationUtil.ResetPagination(); int total = PaginationUtil.CountSql(layername, "编号", list); if (total > 0) { string strLable = " 井盖类型:" + pipetype + "||共有:" + Convert.ToString(total) + "条记录"; string sql = PaginationUtil.GetQuerySql(globeControl1, layername, "编号", list); PaginationUtil pagination = PaginationUtil.InitPagination(sql, total, _pageControl, m_InitDataGridViewX1, strLable, layername); pagination.FillDataGridView(); } } private void chartAllAreaPipeline_MouseMove(object sender, MouseEventArgs e) { HitTestResult result = chartAllAreaPipeline.HitTest(e.X, e.Y, true); //Cursor cr = this.Cursor; if (result.PointIndex >= 0) { Cursor = Cursors.Hand; } else { Cursor = Cursors.Default; } } private void FrmAllPipelineStatis_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.ClearAnalysis(); //layerTemp.RemoveAllFeature(); //panel.Visible = false; //dataGridViewX1.DataSource = null; //dataGridViewX1.Refresh(); //toolStripNumbers.Text = "类型:"; for (int i = 0; i < globeControl1.Globe.Layers.Count; i++) { GSOLayer layer = globeControl1.Globe.Layers[i]; if (layer is GSOFeatureLayer) { GSOFeatures feats = layer.GetAllFeatures(); for (int j = 0; j < feats.Length; j++) { GSOFeature feat = feats[j]; feat.HighLight = false; } } } globeControl1.Globe.MemoryLayer.RemoveAllFeature(); m_InitDataGridViewX1(null, "", "", false); } private void 导出统计专题图ToolStripMenuItem_Click(object sender, EventArgs e) { F_PATMTitle frm = new F_PATMTitle("S", chartAllAreaPipeline); frm.Show(); } /// <summary> /// 获取指定layer类型的附属物名称列表 /// </summary> /// <param name="layerType"></param> /// <returns></returns> public string[] getLayerAccNames(string layerType) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerType + "管线附属物"); if (layer == null) return null; string sql = "select 附属物名称 from " + layerType + "管线附属物 group by 附属物名称"; DataSet dataset = OledbHelper.getDataSet(sql, layerType + "管线附属物"); if (dataset == null) return null; int count = dataset.Tables[0].Rows.Count; string[] result = new string[count]; for (int i = 0; i < count; i++) { result[i] = dataset.Tables[0].Rows[i][0].ToString(); } return result; } /// <summary> /// 获取区域内各图层的井、孔、蓖的map /// </summary> /// <param name="polygon">区域</param> /// <returns>返回值为:图层+附属物名称,附属物列表</returns> public Dictionary<string, GSOFeatures> getAccsMap(GSOGeoPolygon3D polygon) { //List<GSOFeatures> list = new List<GSOFeatures>(); Dictionary<string, GSOFeatures> map = new Dictionary<string, GSOFeatures>(); ArrayList listpt = Utility.LayerNamesList; if (listpt == null || listpt.Count == 0) return null; for (int i = 0; i < listpt.Count; i++) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(listpt[i] + "管线附属物"); string[] accNames = getLayerAccNames(listpt[i] as string); if (accNames == null || accNames.Length == 0) continue;//排除不合法的值 for (int j = 0; j < accNames.Length; j++) { if (accNames[j].Contains("井") || accNames[j].Contains("孔") || accNames[j].Contains("篦")) { GSOFeatures features = FeatureStatisticsService.Intersect_PointLayerByType(polygon, layer, accNames[j]); if (features == null) continue; map.Add(listpt[i] + accNames[j], features); } } } return map; } } }