FuTu.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using SuperMap.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using WeifenLuo.WinFormsUI.Docking;
  5. using WWPipeLine.MapBasic.Conditions;
  6. using System.Drawing;
  7. using System.Data;
  8. using System.Windows.Forms;
  9. using WWPipeLine.MapBasic;
  10. namespace WWPipeLine.MapTools.Conditions.AnalystToolBar
  11. {
  12. public class FuTu : BasicToolBar
  13. {
  14. GeoRegion m_geo = null;
  15. public FuTu() : base()
  16. {
  17. this.ConditionPanelName = "覆土分析";
  18. var startDrawToolStripButton = new ToolStripButton()
  19. {
  20. DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
  21. Text = "绘制覆土分析区域",
  22. Name = "StartDraw",
  23. AutoToolTip = false
  24. };
  25. var analystToolStripButton = new ToolStripButton()
  26. {
  27. DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
  28. Text = "分析",
  29. Name = "Analyst",
  30. AutoToolTip = false
  31. };
  32. base.ToolStrip.Items.Add(startDrawToolStripButton);
  33. base.ToolStrip.Items.Add(analystToolStripButton);
  34. startDrawToolStripButton.Click += StartDrawToolStripButton_Click;
  35. analystToolStripButton.Click += AnalystToolStripButton_Click;
  36. }
  37. private void AnalystToolStripButton_Click(object sender, EventArgs e)
  38. {
  39. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return; }
  40. Recordset recordset = dvJSLK_cp.Query(m_geo, 0, "1=1", CursorType.Static);
  41. if (recordset is null) { Sunny.UI.UIMessageTip.ShowError("当前图层没有查询到数据"); return; }
  42. DataTable dt = ComsStatic.RecordsetToDataTable(recordset);
  43. dt = ComsStatic.GetJSLKbyJSJDPT(dt);
  44. DataTable dtNew = dt.DefaultView.ToTable(false, new string[] { "smid", "cz", "bsm", "qsdh", "qdgdms", "zddh", "zdgdms" });
  45. dtNew.Columns.Add(new DataColumn { ColumnName = "bzgdms", Caption = "标准埋深" });
  46. dtNew.Columns["bzgdms"].SetOrdinal(2);
  47. Dictionary<string, object> dic = ComsStatic.getGuanXianPeiZhi("覆土配置");
  48. string gxcz = "";
  49. foreach (DataRow dr in dtNew.Rows)
  50. {
  51. gxcz = dr["cz"].ToString() + "_gxms";
  52. if (dic.ContainsKey(gxcz))
  53. dr["bzgdms"] = dic[gxcz];
  54. else
  55. dr["bzgdms"] = "未配置";
  56. }
  57. dtNew.TableName = "覆土分析结果";
  58. DataSet ds = new DataSet();
  59. ds.Tables.Add(dtNew);
  60. AnalystResultTabControl from = new AnalystResultTabControl(ds, "覆土分析结果");
  61. from.ShowDialog();
  62. this.CloseToolBar();
  63. }
  64. private void MapControl_Tracked(object sender, SuperMap.UI.TrackedEventArgs e)
  65. {
  66. if (e.Geometry is null) return;
  67. m_geo = e.Geometry.Clone() as GeoRegion;
  68. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("查询区域绘制失败"); return; }
  69. m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
  70. MapControl.Map.TrackingLayer.Clear();
  71. MapControl.Map.TrackingLayer.Add(m_geo, "GeoRectangle");
  72. MapControl.Map.Refresh();
  73. }
  74. private void StartDrawToolStripButton_Click(object sender, EventArgs e)
  75. {
  76. MapControl.Map.TrackingLayer.Clear();
  77. MapControl.Action = SuperMap.UI.Action.CreatePolygon;
  78. MapControl.Tracked -= MapControl_Tracked;
  79. MapControl.Tracked += MapControl_Tracked;
  80. MapControl.Map.Refresh();
  81. }
  82. public override void AfterClose()
  83. {
  84. MapControl.Tracked -= MapControl_Tracked;
  85. base.AfterClose();
  86. }
  87. private void InitializeComponent()
  88. {
  89. this.SuspendLayout();
  90. //
  91. // ToolsConditions
  92. //
  93. this.Name = "ToolsConditions";
  94. this.ResumeLayout(false);
  95. }
  96. }
  97. }