| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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 SuperMap.Analyst.NetworkAnalyst;
- using System.IO;
- namespace WWPipeLine.MapTools.Conditions.AnalystToolBar
- {
- public partial class GuanFa : ConditionPanel
- {
- private int objectidJSLK = 0;
- DatasetVector dv = null;
- public GuanFa()
- {
- this.ConditionPanelName = "关阀分析";
- InitializeComponent();
- this.IsShowPanelFooter = false;
- this.SetSize(500, 600);
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.MouseDoubleClick += MapControl_MouseDoubleClick;
- string dviName = ComsStatic.DatasourceMemory.Datasets.GetAvailableDatasetName("GuanFaNetwork");
- dv = NetworkBuilder.BuildNetwork(ComsStatic.gsGuanXian, ComsStatic.gsGuanDian, "objectid", "qsdh", "zddh", "bsm", ComsStatic.DatasourceMemory, dviName);
- }
- private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- Point2D pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y));
- GeoPoint pointClick = new GeoPoint(pClick);
- Recordset rdJSLK = ComsStatic.gsGuanXian.Query(pointClick, 10, " enabled=1 ", CursorType.Static);
- if (rdJSLK.RecordCount == 0)
- {
- Sunny.UI.UIMessageTip.ShowError("当前鼠标双击点附近没有找到管线信息"); return;
- }
- double distance_temp = 0.0D;
- double distance = 0.0D;
- GeoLine line_temp;
- GeoLine line = null;
- int smidJSLK = 0;
- rdJSLK.MoveFirst();
- while (!rdJSLK.IsEOF)
- {
- line_temp = rdJSLK.GetGeometry() as GeoLine;
- distance_temp = Geometrist.Distance(pointClick, line_temp);
- if (distance_temp <= distance || distance == 0.0D)
- {
- distance = distance_temp;
- line = line_temp;
- smidJSLK = rdJSLK.GetID();
- }
- rdJSLK.MoveNext();
- }
- pClick = Geometrist.NearestPointToVertex(pClick, line);
- GeoPoint markPoint = new GeoPoint(pClick);
- MapControl.Map.TrackingLayer.Clear();
- string path = Commons.Paths.ApplicationResourcesDir + "\\baoguan.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();
- rdJSLK.SeekID(smidJSLK);
- uitb_bsm.Text = rdJSLK.GetFieldValue("bsm").ToString();
- uitb_zcbh.Text = rdJSLK.GetFieldValue("zcbh")?.ToString();
- uitbGdbh.Text = rdJSLK.GetFieldValue("gdbh")?.ToString();
- uitb_tz.Text = rdJSLK.GetFieldValue("tz")?.ToString();
- uitb_cz.Text = rdJSLK.GetFieldValue("cz")?.ToString();
- uitb_gj.Text = rdJSLK.GetFieldValue("gj").ToString();
- uitb_yl.Text = rdJSLK.GetFieldValue("yl")?.ToString();
- uitb_cd.Text = rdJSLK.GetFieldValue("cd").ToString();
- uitb_msfs.Text = rdJSLK.GetFieldValue("msfs")?.ToString();
- uidp_msrq.Text = rdJSLK.GetFieldValue("msrq")?.ToString();
- uitb_dzms.Text = rdJSLK.GetFieldValue("dzms")?.ToString();
- uitb_qsdw.Text = rdJSLK.GetFieldValue("qsdw")?.ToString();
- uitb_bz.Text = rdJSLK.GetFieldValue("bz")?.ToString();
- objectidJSLK = ComsStatic.StringToInt(rdJSLK.GetFieldValue("objectid"));
- ComsStatic.RecordsetDispose(rdJSLK);
- }
- public override void AfterClose()
- {
- MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick;
- base.AfterClose();
- }
- private void uiButton1_Click(object sender, EventArgs e)
- {
- if (objectidJSLK == 0) { UIMessageTip.ShowError("请选择爆管的管线"); return; }
- FacilityAnalystSetting analystSetting = new FacilityAnalystSetting();
- analystSetting.NetworkDataset = dv;
- analystSetting.NodeIDField = "SmNodeID";
- analystSetting.EdgeIDField = "objectid";
- analystSetting.FNodeIDField = "SmFNode";
- analystSetting.TNodeIDField = "SmTNode";
- analystSetting.DirectionField = "lx";
- analystSetting.Tolerance = 0.001;
- FacilityAnalyst m_facilityAnalyst = new FacilityAnalyst();
- m_facilityAnalyst.AnalystSetting = analystSetting;
- bool isLoad = m_facilityAnalyst.Load();
- Recordset rdChild = dv.ChildDataset.Query(" FLDM='供水阀门' ", CursorType.Static);
- if (rdChild.RecordCount == 0) { UIMessageTip.ShowError("无法查找到任何阀门信息"); return; }
- List<int> listNodeIDs = new List<int>();
- rdChild.MoveFirst();
- while (!rdChild.IsEOF)
- {
- listNodeIDs.Add(ComsStatic.StringToInt(rdChild.GetFieldValue("SmNodeID")));
- rdChild.MoveNext();
- }
- FacilityAnalystResult resultEdges = m_facilityAnalyst.FindCriticalFacilitiesUpFromEdge(listNodeIDs.ToArray(), objectidJSLK, true);
- if (resultEdges is null) { Sunny.UI.UIMessageTip.ShowWarning("未找到有效阀门"); return; }
- rdChild = dv.ChildDataset.Query(string.Format("SmNodeID in ({0})", string.Join(",", resultEdges.Nodes)), CursorType.Static);
- ComsStatic.setUIDataGridView(uidgv, ComsStatic.RecordsetToDataTable(rdChild), ",tz,fsw,xh,gg,cz,kj,dzms,bz,");
- m_facilityAnalyst.Dispose();
- }
- private void uidgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (uidgv.SelectedRows == null || uidgv.SelectedRows.Count != 1) return;//选择不是一行
- DataGridViewRow selectRow = uidgv.SelectedRows[0];
- new DoTrackingPoint().Doing(ComsStatic.StringToDouble(selectRow.Cells["smx"].Value), ComsStatic.StringToDouble(selectRow.Cells["smy"].Value));
- }
- }
- }
|