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 = "消防栓搜索"; InitializeComponent(); this.IsShowPanelFooter = false; this.SetSize(700, 535); } protected override void OnLoad(EventArgs e) { Recordset rd = ComsStatic.dvJSLK_PZ.Query(" pzlx='事故点' ", CursorType.Static); ComsStatic.setUIDataGridView(uidgvshigudian, ComsStatic.RecordsetToDataTable(rd), "pzlx,pzkey"); uidgvshigudian.ColumnHeadersVisible = false; } private void uitbBanjing_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8)) e.Handled = true; } private void uiButton1_Click(object sender, EventArgs e) { ComsStatic.ShowOK("在地图中双击手动标注火灾事故位置"); 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.gif"; 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.RefreshEx(MapControl.Map.ViewBounds); } private void uiButton2_Click(object sender, EventArgs e) { MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick; if (markPoint is null || string.IsNullOrEmpty(uitbBanjing.Text)) { ComsStatic.ShowOK("请先完成事故点的搜索和定位"); return; } DatasetVector dv = ComsStatic.Datasource.Datasets["JSXFSPT"] as DatasetVector; if (dv == null) { Sunny.UI.UIMessageTip.ShowError("当前数据源中不包含相应的矢量数据集"); return; } Recordset rd = dv.Query(markPoint, ComsStatic.StringToDouble(uitbBanjing.Text), "", 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]; new DoTrackingPoint().Doing(ComsStatic.StringToDouble(selectRow.Cells["smx"].Value), ComsStatic.StringToDouble(selectRow.Cells["smy"].Value)); //Point2D p2d = new Point2D(ComsStatic.StringToDouble(selectRow.Cells["smx"].Value), ComsStatic.StringToDouble(selectRow.Cells["smy"].Value)); //markPoint = new GeoPoint(p2d); //markPoint.Style = new GeoStyle() { MarkerSize = new Size2D(5, 5), LineColor = Color.Red }; //MapControl.Map.Center = p2d; //MapControl.Map.TrackingLayer.Clear(); //MapControl.Map.TrackingLayer.Add(markPoint, "InterestPoint"); //MapControl.Map.Refresh(); } 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)); } } }