using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using GeoScene.Data; using GeoScene.Globe; using DevComponents.DotNetBar; using System.Collections; namespace Cyberpipe { public partial class FrmAllPipelineStatis : DevComponents.DotNetBar.Office2007Form { Dictionary<string, double> pipelineLengthAndType = new Dictionary<string, double>(); List<GSOFeatures> list = new List<GSOFeatures>(); GSOGlobeControl globeControl1; int type; static FrmAllPipelineStatis frm; private MainFrm.DataGridViewDelegate m_InitDataGridViewX1; DataTable table = new DataTable(); string strLable = ""; public static void ShowForm(int _type, Dictionary<string, double> pipeLen, List<GSOFeatures> _list, GSOGlobeControl ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1) { if (frm == null) { frm = new FrmAllPipelineStatis(_type, pipeLen, _list, ctl, InitDataGridViewX1); frm.Show(ctl.Parent); } else { if (frm.WindowState == FormWindowState.Minimized) { frm.WindowState = FormWindowState.Normal; } } } public FrmAllPipelineStatis(int _type, Dictionary<string, double> pipeLen, List<GSOFeatures> _list, GSOGlobeControl ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); type = _type; pipelineLengthAndType = pipeLen; list = _list; globeControl1 = ctl; m_InitDataGridViewX1 = InitDataGridViewX1; } private void FrmAllPipelineStatis_Load(object sender, EventArgs e) { try { if (type == 0) { Text = "管线距离统计"; } else { Text = "空间查询"; } chartAllAreaPipeline.Series.Add("管线"); // Set axis title 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"; chartAllAreaPipeline.Series["管线"].Points.DataBindXY(pipelineLengthAndType.Keys, pipelineLengthAndType.Values); for (int m = 0; m < pipelineLengthAndType.Values.Count; m++) { if (chartAllAreaPipeline.Series["管线"].Points[m].YValues[0].ToString() != "0") { chartAllAreaPipeline.Series["管线"].Points[m].Label = chartAllAreaPipeline.Series[0].Points[m].YValues[0].ToString(); } string axisLabel = chartAllAreaPipeline.Series["管线"].Points[m].AxisLabel; chartAllAreaPipeline.Series["管线"].Points[m].AxisLabel = axisLabel.Substring(0, axisLabel.IndexOf("管线")); } } 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) { GSOFeatures fs = list[indexHit]; string pipetype = chartAllAreaPipeline.Series["管线"].Points[indexHit].AxisLabel; foreach (string key in pipelineLengthAndType.Keys) { if (key.StartsWith(pipetype)) { pipetype = key; break; } } GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipetype); if (layer == null) { return; } string[] fields = ClassSearchAnalysis.getFields(pipetype, globeControl1); table = ClassSearchAnalysis.convertGSOFeatures2DataTable(fs, fields); if (table != null && table.Rows.Count > 0) { string strLable = "共有:" + Convert.ToString(table.Rows.Count) + "条记录" + " 管线里程:" + chartAllAreaPipeline.Series["管线"].Points[indexHit].YValues[0].ToString("0.00") + " 米"; m_InitDataGridViewX1(table, strLable, pipetype, true); } } } private void chartAllAreaPipeline_MouseMove(object sender, MouseEventArgs e) { HitTestResult result = chartAllAreaPipeline.HitTest(e.X, e.Y, true); if (result.PointIndex >= 0) { this.Cursor = Cursors.Hand; } else { this.Cursor = Cursors.Default; } } private void FrmAllPipelineStatis_FormClosing(object sender, FormClosingEventArgs e) { frm = null; m_InitDataGridViewX1(table, strLable, "", false); } private void 导出统计专题图ToolStripMenuItem_Click(object sender, EventArgs e) { PATM_Forms.F_PATMTitle frm = new PATM_Forms.F_PATMTitle("S", chartAllAreaPipeline); frm.Show(); } } }