| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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 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.RefreshEx(MapControl.Map.ViewBounds);
- }
- 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();
- //
- // ToolsConditions
- //
- this.Name = "ToolsConditions";
- this.ResumeLayout(false);
- }
- }
- }
|