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 WeifenLuo.WinFormsUI.Docking; using SuperMap.Mapping; using Sunny.UI; using System.IO; namespace WWPipeLine.MapTools.Conditions.AnalystToolBar { public partial class ShiGuDian : ConditionPanel { DatasetVector dv = null; private bool isClick = false; private GeoPoint markPoint = null; public ShiGuDian() { this.ConditionPanelName = "事故点定位"; this.IsShowPanelFooter = false; InitializeComponent(); this.SetSize(500, 500); } protected override void OnLoad(EventArgs e) { dv = ComsStatic.Datasource.Datasets["pyroad"] as DatasetVector; if (dv is null) { UIMessageTip.ShowError("当前系统未配置道路数据集"); this.ParentForm.Close(); return; } //Recordset rd = ComsStatic.QueryRecordset(dv, "", new string[] { "name" }, new string[] { "name" }, new string[] { "name" }); Recordset rd = dv.GetRecordset(false, CursorType.Static); rd.MoveFirst(); while (!rd.IsEOF) { uilbRoad.Items.Add(new DoListItem(rd.GetFieldValue("smid").ToString(), rd.GetFieldValue("name").ToString())); rd.MoveNext(); } ComsStatic.RecordsetDispose(rd); uilbRoad.SelectedIndex = 0; foreach (Layer lyr in ComsStatic.MapLayersUsed) { uicbxLayers.Items.Add(new DoListItem(lyr.Dataset.Name, lyr.Caption)); } uicbxLayers.SelectedIndex = 0; } private void uiButton2_Click(object sender, EventArgs e) { int RoadSmID = ComsStatic.StringToInt((uilbRoad.SelectedItem as DoListItem).Key); Geometry geo = dv.GetAllFeatures()[RoadSmID].GetGeometry(); if (geo is null) { UIMessageTip.ShowError("未查询到当前道路信息,无法完成事故点定位"); return; } DatasetVector dvLayer = ComsStatic.Datasource.Datasets[(uicbxLayers.SelectedItem as DoListItem).Key] as DatasetVector; if (dvLayer is null) { UIMessageTip.ShowError("未查询到当前选择图层的数据集信息"); return; } Recordset rdd = dvLayer.Query(geo, ComsStatic.StringToDouble(uitbBanjing.Text), CursorType.Static); ComsStatic.setUIDataGridView(uidgv, ComsStatic.RecordsetToDataTable(rdd), ",fsw,cd,dzms,qsdw,name,address,"); } private void uidgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { isClick = false; if (uidgv.SelectedRows == null || uidgv.SelectedRows.Count != 1) return; DataGridViewRow selectRow = uidgv.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 uiButton1_Click(object sender, EventArgs e) { MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick; if (markPoint is null) { ComsStatic.ShowOK("请先完成事故点的搜索和定位"); return; } Recordset rd = ComsStatic.dvConfig.GetRecordset(true, CursorType.Dynamic); rd.AddNew(markPoint); if (isClick) { rd.SetFieldValue("pzlx", "事故点"); rd.SetFieldValue("pzKey", "手动添加"); } else { rd.SetFieldValue("pzlx", "事故点"); rd.SetFieldValue("pzKey", uicbxLayers.SelectedItem.ToString()); } ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "标记事故点"); markPoint = null; isClick = false; } private void uiButton3_Click(object sender, EventArgs e) { MapControl.MouseDoubleClick += MapControl_MouseDoubleClick; } private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e) { isClick = true; Point2D pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y)); markPoint = new GeoPoint(pClick); MapControl.Map.TrackingLayer.Clear(); string path = Commons.Paths.ApplicationResourcesDir + "\\shigudian.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(); } public override void AfterClose() { MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick; base.AfterClose(); } } }