XiaoFangShuan.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using WWPipeLine.MapBasic.Conditions;
  11. using WWPipeLine.MapBasic;
  12. using SuperMap.Data;
  13. using Sunny.UI;
  14. using System.IO;
  15. namespace WWPipeLine.MapTools.Conditions.AnalystToolBar
  16. {
  17. public partial class XiaoFangShuan : ConditionPanel
  18. {
  19. private GeoPoint markPoint = null;
  20. public XiaoFangShuan()
  21. {
  22. this.ConditionPanelName = "消防栓搜索";
  23. this.IsShowPanelFooter = false;
  24. InitializeComponent();
  25. this.SetSize(500, 500);
  26. }
  27. protected override void OnLoad(EventArgs e)
  28. {
  29. Recordset rd = ComsStatic.dvConfig.Query(" pzlx='事故点' ", CursorType.Static);
  30. ComsStatic.setUIDataGridView(uidgvshigudian, ComsStatic.RecordsetToDataTable(rd), "pzlx,pzkey");
  31. uidgvshigudian.ColumnHeadersVisible = false;
  32. }
  33. private void uiButton1_Click(object sender, EventArgs e)
  34. {
  35. MapControl.MouseDoubleClick += MapControl_MouseDoubleClick;
  36. }
  37. private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e)
  38. {
  39. Point2D pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y));
  40. markPoint = new GeoPoint(pClick);
  41. MapControl.Map.TrackingLayer.Clear();
  42. string path = Commons.Paths.ApplicationResourcesDir + "\\huozai.png";
  43. if (File.Exists(path))
  44. {
  45. GeoPicture geoPicture = new GeoPicture(path, pClick, 10, 10, 0);
  46. MapControl.Map.TrackingLayer.Add(geoPicture, "InterestPoint");
  47. }
  48. else
  49. {
  50. markPoint.Style = new GeoStyle { MarkerSize = new Size2D(5, 5), LineColor = Color.Red };
  51. MapControl.Map.TrackingLayer.Add(markPoint, "InterestPoint");
  52. }
  53. MapControl.Map.RefreshTrackingLayer();
  54. }
  55. private void uiButton2_Click(object sender, EventArgs e)
  56. {
  57. MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick;
  58. if (markPoint is null || string.IsNullOrEmpty(uitbBanjing.Text)) { ComsStatic.ShowOK("请先完成事故点的搜索和定位"); return; }
  59. Recordset rd = ComsStatic.gsGuanDian.Query(markPoint, ComsStatic.StringToDouble(uitbBanjing.Text), " FLDM='消防栓' ", CursorType.Static);
  60. DataTable dt = ComsStatic.RecordsetToDataTable(rd);
  61. dt.Columns.Add(new DataColumn { ColumnName = "cd", Caption = "距离(米)", DataType = Type.GetType("System.Double") });
  62. GeoPoint gp = null;
  63. foreach (DataRow dr in dt.Rows)
  64. {
  65. gp = new GeoPoint(ComsStatic.StringToDouble(dr["smx"]), ComsStatic.StringToDouble(dr["smy"]));
  66. dr["cd"] = Math.Round(Geometrist.Distance(gp, markPoint), 0);
  67. }
  68. DataView dataView = dt.DefaultView;
  69. dataView.Sort = "cd asc";
  70. ComsStatic.setUIDataGridView(uidgvxiaofangshuan, dataView.ToTable(), "cd,fsw,dzms,qsdw,");
  71. uidgvxiaofangshuan.Columns["cd"].DisplayIndex = 0;
  72. }
  73. public override void AfterClose()
  74. {
  75. MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick;
  76. base.AfterClose();
  77. }
  78. private void uidgvshigudian_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  79. {
  80. if (uidgvshigudian.SelectedRows == null || uidgvshigudian.SelectedRows.Count != 1) return;
  81. DataGridViewRow selectRow = uidgvshigudian.SelectedRows[0];
  82. markPoint = new GeoPoint(ComsStatic.GetPoint2D(selectRow.Cells["smx"].Value, selectRow.Cells["smy"].Value));
  83. new DoTrackingPoint().Doing(ComsStatic.StringToDouble(selectRow.Cells["smx"].Value), ComsStatic.StringToDouble(selectRow.Cells["smy"].Value));
  84. }
  85. private void uidgvxiaofangshuan_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  86. {
  87. if (uidgvxiaofangshuan.SelectedRows == null || uidgvxiaofangshuan.SelectedRows.Count != 1) return;
  88. DataGridViewRow selectRow = uidgvxiaofangshuan.SelectedRows[0];
  89. new DoTrackingPoint().Doing(ComsStatic.StringToDouble(selectRow.Cells["smx"].Value), ComsStatic.StringToDouble(selectRow.Cells["smy"].Value));
  90. }
  91. }
  92. }