using SuperMap.Data; using System; using System.Collections.Generic; using System.Data; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.MapBasic.Conditions; using WWPipeLine.MapBasic; using SuperMap.Mapping; using SuperMap.UI; using System.Drawing; namespace WWPipeLine.MapTools.Conditions.Statistics { public partial class GDshuliangQY : ConditionPanel { private LayerWithDataListPanel LayerPanel; GeoRegion m_geo = null; public GDshuliangQY() : base() { this.ConditionPanelName = "区域管点数量统计"; InitializeComponent(); } protected override void OnLoad(EventArgs e) { LayerPanel = new LayerWithDataListPanel(); LayerPanel.LoadToVector(true, false); this.Controls.Add(LayerPanel); int index = MapControl.Map.TrackingLayer.IndexOf("ControlToolAddGeoRegion"); if (index == -1) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); this.FindForm().Close(); return; } m_geo = MapControl.Map.TrackingLayer.Get(index) as GeoRegion; if (m_geo is null || m_geo.PartCount != 1) { ComsStatic.ShowErrorLog("绘制区域PartCount参数发生错误"); this.FindForm().Close(); return; } } public override object Do(DockPanel dockPanel = null) { if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false; } if (LayerPanel.SelectLayers.Count == 0) { Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false; } DataTable dt = new DataTable() { TableName = "管点数量统计结果" }; DataRow dr; dt.Columns.Add("统计图层"); foreach (Layer lyr in LayerPanel.SelectLayers) { dt.Columns.Add(lyr.Caption); } dr = dt.NewRow(); dr["统计图层"] = "管点数量"; DatasetVector dv; Recordset rd = null; foreach (Layer lyr in LayerPanel.SelectLayers) { dv = lyr.Dataset as DatasetVector; rd = dv.Query(m_geo, 1, "1=1", CursorType.Static); dr[lyr.Caption] = rd.RecordCount; } dt.Rows.Add(dr); ComsStatic.RecordsetDispose(rd); return dt; } } }