ChaiQian.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using SuperMap.Data;
  2. using SuperMap.Mapping;
  3. using System;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. using WWPipeLine.MapBasic;
  8. using WWPipeLine.MapBasic.Conditions;
  9. namespace WWPipeLine.MapTools.Conditions.AnalystToolBar
  10. {
  11. public class ChaiQian : BasicToolBar
  12. {
  13. GeoRegion m_geo = null;
  14. public ChaiQian() : base()
  15. {
  16. this.ConditionPanelName = "拆迁分析";
  17. var analystToolStripButton = new ToolStripButton()
  18. {
  19. DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
  20. Text = "分析",
  21. Name = "Analyst",
  22. AutoToolTip = false
  23. };
  24. base.ToolStrip.Items.Add(analystToolStripButton);
  25. analystToolStripButton.Click += AnalystToolStripButton_Click;
  26. }
  27. private void AnalystToolStripButton_Click(object sender, EventArgs e)
  28. {
  29. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制拆迁区域"); return; }
  30. DataSet dtsLayer = new DataSet();
  31. DatasetVector dv;
  32. Recordset ds;
  33. DataTable dt;
  34. foreach (Layer lyr in ComsStatic.MapLayersUsed)
  35. {
  36. dv = lyr.Dataset as DatasetVector;
  37. if (dv is null) continue;
  38. ds = dv.Query(m_geo, 0, CursorType.Static);
  39. if (ds is null) continue;
  40. dt = ComsStatic.RecordsetToDataTable(ds);
  41. if (dt.Rows.Count == 0) continue;
  42. dt.TableName = string.Format("{0} 影响{1}个", lyr.Caption, dt.Rows.Count);
  43. dtsLayer.Tables.Add(dt);
  44. }
  45. AnalystResultTabControl from = new AnalystResultTabControl(dtsLayer, "拆迁分析结果");
  46. from.ShowDialog();
  47. this.CloseToolBar();
  48. }
  49. private void MapControl_Tracked(object sender, SuperMap.UI.TrackedEventArgs e)
  50. {
  51. if (e.Geometry is null) return;
  52. m_geo = e.Geometry.Clone() as GeoRegion;
  53. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("区域绘制失败"); return; }
  54. m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
  55. MapControl.Map.TrackingLayer.Clear();
  56. MapControl.Map.TrackingLayer.Add(m_geo, "GeoRectangle");
  57. MapControl.Map.RefreshEx(MapControl.Map.ViewBounds);
  58. }
  59. protected override void OnLoad(EventArgs e)
  60. {
  61. MapControl.Action = SuperMap.UI.Action.CreatePolygon;
  62. MapControl.Tracked += MapControl_Tracked;
  63. }
  64. public override void AfterClose()
  65. {
  66. MapControl.Tracked -= MapControl_Tracked;
  67. base.AfterClose();
  68. }
  69. private void InitializeComponent()
  70. {
  71. this.SuspendLayout();
  72. //
  73. // ToolsConditions
  74. //
  75. this.Name = "ToolsConditions";
  76. this.ResumeLayout(false);
  77. }
  78. }
  79. }