using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WWPipeLine.MapBasic.Conditions; using WWPipeLine.MapBasic; using SuperMap.Data; using Sunny.UI; using System.IO; namespace WWPipeLine.MapTools.Conditions.AnalystToolBar { public partial class XiaoFangShuan : ConditionPanel { private GeoPoint markPoint = null; public XiaoFangShuan() { this.ConditionPanelName = "消防栓搜索"; this.IsShowPanelFooter = false; InitializeComponent(); this.SetSize(500, 500); } protected override void OnLoad(EventArgs e) { Recordset rd = ComsStatic.dvConfig.Query(" pzlx='事故点' ", CursorType.Static); ComsStatic.setUIDataGridView(uidgvshigudian, ComsStatic.RecordsetToDataTable(rd), "pzlx,pzkey"); uidgvshigudian.ColumnHeadersVisible = false; } private void uiButton1_Click(object sender, EventArgs e) { MapControl.MouseDoubleClick += MapControl_MouseDoubleClick; } private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e) { Point2D pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y)); markPoint = new GeoPoint(pClick); MapControl.Map.TrackingLayer.Clear(); string path = Commons.Paths.ApplicationResourcesDir + "\\huozai.png"; if (File.Exists(path)) { GeoPicture geoPicture = new GeoPicture(path, pClick, 10, 10, 0); MapControl.Map.TrackingLayer.Add(geoPicture, "InterestPoint"); } else { markPoint.Style = new GeoStyle { MarkerSize = new Size2D(5, 5), LineColor = Color.Red }; MapControl.Map.TrackingLayer.Add(markPoint, "InterestPoint"); } MapControl.Map.RefreshTrackingLayer(); } private void uiButton2_Click(object sender, EventArgs e) { MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick; if (markPoint is null || string.IsNullOrEmpty(uitbBanjing.Text)) { ComsStatic.ShowOK("请先完成事故点的搜索和定位"); return; } Recordset rd = ComsStatic.gsGuanDian.Query(markPoint, ComsStatic.StringToDouble(uitbBanjing.Text), " FLDM='消防栓' ", CursorType.Static); DataTable dt = ComsStatic.RecordsetToDataTable(rd); dt.Columns.Add(new DataColumn { ColumnName = "cd", Caption = "距离(米)", DataType = Type.GetType("System.Double") }); GeoPoint gp = null; foreach (DataRow dr in dt.Rows) { gp = new GeoPoint(ComsStatic.StringToDouble(dr["smx"]), ComsStatic.StringToDouble(dr["smy"])); dr["cd"] = Math.Round(Geometrist.Distance(gp, markPoint), 0); } DataView dataView = dt.DefaultView; dataView.Sort = "cd asc"; ComsStatic.setUIDataGridView(uidgvxiaofangshuan, dataView.ToTable(), "cd,fsw,dzms,qsdw,"); uidgvxiaofangshuan.Columns["cd"].DisplayIndex = 0; } public override void AfterClose() { MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick; base.AfterClose(); } private void uidgvshigudian_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (uidgvshigudian.SelectedRows == null || uidgvshigudian.SelectedRows.Count != 1) return; DataGridViewRow selectRow = uidgvshigudian.SelectedRows[0]; markPoint = new GeoPoint(ComsStatic.GetPoint2D(selectRow.Cells["smx"].Value, selectRow.Cells["smy"].Value)); new DoTrackingPoint().Doing(ComsStatic.StringToDouble(selectRow.Cells["smx"].Value), ComsStatic.StringToDouble(selectRow.Cells["smy"].Value)); } private void uidgvxiaofangshuan_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (uidgvxiaofangshuan.SelectedRows == null || uidgvxiaofangshuan.SelectedRows.Count != 1) return; DataGridViewRow selectRow = uidgvxiaofangshuan.SelectedRows[0]; new DoTrackingPoint().Doing(ComsStatic.StringToDouble(selectRow.Cells["smx"].Value), ComsStatic.StringToDouble(selectRow.Cells["smy"].Value)); } } }