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; namespace Cyberpipe { public partial class FrmValveStatistics : DevComponents.DotNetBar.Office2007Form { Dictionary<string, int> workWellLengthAndType = new Dictionary<string, int>(); List<GSOFeatures> list = new List<GSOFeatures>(); DataGridView dataGridViewX1; ToolStripStatusLabel toolStripNumbers; GSOGlobeControl globeControl1; PanelEx panel; public FrmValveStatistics(Dictionary<string, int> wellLen, List<GSOFeatures> _list, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl,PanelEx p) { InitializeComponent(); panel = p; workWellLengthAndType = wellLen; list = _list; dataGridViewX1 = dataGridViewX11; toolStripNumbers = toolStripNumbers1; globeControl1 = ctl; } /// <summary> /// 窗体初始化事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmLayerSelectedQuery_Load(object sender, EventArgs e) { try { chaFamenStatis.ChartAreas["ChartArea1"].AxisX.Title = "阀门类型"; chaFamenStatis.ChartAreas["ChartArea1"].AxisY.Title = "阀门个数"; chaFamenStatis.ChartAreas["ChartArea1"].AxisX.Interval = 1; LabelStyle labeStyleAxisX = new LabelStyle(); labeStyleAxisX.Angle = -45; labeStyleAxisX.Enabled = true; chaFamenStatis.ChartAreas["ChartArea1"].AxisX.LabelStyle = labeStyleAxisX; chaFamenStatis.Series["阀门"].ChartType = SeriesChartType.Column; chaFamenStatis.Series["阀门"]["DrawingStyle"] = "Cylinder"; chaFamenStatis.Series["阀门"].IsValueShownAsLabel = true; chaFamenStatis.Series["阀门"].Points.DataBindXY(workWellLengthAndType.Keys, workWellLengthAndType.Values); for (int m = 0; m < workWellLengthAndType.Values.Count; m++) { if (chaFamenStatis.Series["阀门"].Points[m].YValues[0].ToString() != "0") { chaFamenStatis.Series["阀门"].Points[m].Label = chaFamenStatis.Series[0].Points[m].YValues[0].ToString(); } } } catch (Exception ex) { //LogError.PublishError(ex); } } /// <summary> /// 图表鼠标单击事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void chaFamenStatis_MouseClick(object sender, MouseEventArgs e) { HitTestResult result = chaFamenStatis.HitTest(e.X, e.Y, true); int indexHit = result.PointIndex; if (indexHit >= 0) { GSOFeatures fs = list[indexHit]; string sql = ""; string pipetype = chaFamenStatis.Series["阀门"].Points[indexHit].AxisLabel; string layername = pipetype.Substring(0, pipetype.Length - 2) + "管线附属物"; MainFrm.m_CurrentQueryLayer = layername; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); if (layer == null) { return; } if (fs.Length > 0) { sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where "; for (int i = 0; i < fs.Length; i++) { if (i == 0) { if (fs[i].GetFieldDefn("编号") != null) { sql += " 编号='" + fs[i].GetValue("编号").ToString() + "'"; } } else { if (fs[i].GetFieldDefn("编号") != null) { sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } } } DataTable dt = OledbHelper.QueryTable(sql); if (dt.Rows.Count > 0) { dataGridViewX1.DataSource = dt; panel.Visible = true; toolStripNumbers.Text = " 阀门类型:" + pipetype + "||共有:" + Convert.ToString(dt.Rows.Count) + "条记录"; } else { dataGridViewX1.DataSource = null; panel.Visible = false; toolStripNumbers.Text = "类型: "; } } } } /// <summary> /// 图表鼠标移动事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void chaFamenStatis_MouseMove(object sender, MouseEventArgs e) { HitTestResult result = chaFamenStatis.HitTest(e.X, e.Y, true); //Cursor cr = this.Cursor; if (result.PointIndex >= 0) { this.Cursor = Cursors.Hand; } else { this.Cursor = Cursors.Default; } } /// <summary> /// 窗体关闭事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmLayerSelectedQuery_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.ClearAnalysis(); panel.Visible = false; dataGridViewX1.DataSource = null; dataGridViewX1.Refresh(); toolStripNumbers.Text = "类型:"; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); } private void 导出统计专题图ToolStripMenuItem_Click(object sender, EventArgs e) { PATM_Forms.F_PATMTitle frm = new PATM_Forms.F_PATMTitle("S", chaFamenStatis); frm.Show(); } } }