using SuperMap.Data; using SuperMap.Mapping; using System; using System.Data; using System.Drawing; using System.Windows.Forms; using WWPipeLine.MapBasic; using WWPipeLine.MapBasic.Conditions; namespace WWPipeLine.MapTools.Conditions.AnalystToolBar { public class ChaiQian : BasicToolBar { GeoRegion m_geo = null; public ChaiQian() : base() { this.ConditionPanelName = "拆迁分析"; var startDrawToolStripButton = new ToolStripButton() { DisplayStyle = ToolStripItemDisplayStyle.ImageAndText, Text = "绘制拆迁区域", Name = "StartDraw", AutoToolTip = false }; var analystToolStripButton = new ToolStripButton() { DisplayStyle = ToolStripItemDisplayStyle.ImageAndText, Text = "分析", Name = "Analyst", AutoToolTip = false }; base.ToolStrip.Items.Add(startDrawToolStripButton); base.ToolStrip.Items.Add(analystToolStripButton); startDrawToolStripButton.Click += StartDrawToolStripButton_Click; analystToolStripButton.Click += AnalystToolStripButton_Click; } private void AnalystToolStripButton_Click(object sender, EventArgs e) { if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制拆迁区域"); return; } DataSet dtsLayer = new DataSet(); DatasetVector dv; Recordset ds; DataTable dt; //foreach (LayerEx lyr in ComsStatic.layerExs) //{ // dv = ComsStatic.Datasource.Datasets[lyr.Dataset] as DatasetVector; // if (dv is null) continue; // ds = dv.Query(m_geo, 0, CursorType.Static); // if (ds is null) continue; // dt = ComsStatic.RecordsetToDataTable(ds); // if (dt.Rows.Count == 0) continue; // dt.TableName = string.Format("{0} 影响{1}个", lyr.Caption, dt.Rows.Count); // dtsLayer.Tables.Add(dt); //} DataTable dtLayers = ComsStatic.getLayers(); foreach (DataRow dr in dtLayers.Rows) { dv = ComsStatic.Datasource.Datasets[dr["LayerDatasetName"].ToString()] as DatasetVector; if (dv is null) continue; ds = dv.Query(m_geo, 0, CursorType.Static); if (ds is null) continue; dt = MapBasic.ComsStatic.RecordsetToDataTable(ds); if (dt.Rows.Count == 0) continue; dt.TableName = string.Format("{0} 影响{1}个", dr["LayerCaption"], dt.Rows.Count); dtsLayer.Tables.Add(dt); } AnalystResultTabControl from = new AnalystResultTabControl(dtsLayer, "拆迁分析结果"); from.ShowDialog(); this.CloseToolBar(); } private void MapControl_Tracked(object sender, SuperMap.UI.TrackedEventArgs e) { if (e.Geometry is null) return; m_geo = e.Geometry.Clone() as GeoRegion; if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("区域绘制失败"); return; } m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.TrackingLayer.Add(m_geo, "GeoRectangle"); MapControl.Map.RefreshEx(MapControl.Map.ViewBounds); } private void StartDrawToolStripButton_Click(object sender, EventArgs e) { MapControl.Map.TrackingLayer.Clear(); MapControl.Action = SuperMap.UI.Action.CreatePolygon; MapControl.Tracked += MapControl_Tracked; } public override void AfterClose() { MapControl.Tracked -= MapControl_Tracked; base.AfterClose(); } private void InitializeComponent() { this.SuspendLayout(); // // ToolsConditions // this.Name = "ToolsConditions"; this.ResumeLayout(false); } } }