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 KuoJian : BasicToolBar { GeoRegion m_geo = null; public KuoJian() : base() { this.ConditionPanelName = "道路扩建分析"; var analystToolStripButton = new ToolStripButton() { DisplayStyle = ToolStripItemDisplayStyle.ImageAndText, Text = "开始分析", Name = "Analyst", AutoToolTip = false }; base.ToolStrip.Items.Add(analystToolStripButton); 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 (Layer lyr in ComsStatic.MapLayersUsed) { dv = 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); } 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.Refresh(); } protected override void OnLoad(EventArgs e) { 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(); // // KuoJian // this.Name = "KuoJian"; this.ResumeLayout(false); this.PerformLayout(); } } }