using Sunny.UI; using SuperMap.Data; using SuperMap.Mapping; using SuperMap.UI; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.MapBasic.Conditions; using WWPipeLine.MapBasic; namespace WWPipeLine.MapTools.Conditions.EditGuanWang { public class GuanDianLianJie : ConditionPanel { private UILabel uilbRemark; private UIButton uibtnLianjie; private UIButton uiButton2; private UILabel uilbStart; private Panel plMain; private GeoLine _geoLine = null; private Point2Ds _goeLinePoints = new Point2Ds(); private string _qsdh = "未确认"; private string _zddh = "未确认"; private UILabel uilbEnd; private GeoStyle m_GeoStyle = new GeoStyle { MarkerSize = new Size2D(5, 5), LineColor = Color.Red, LineWidth = 3 }; public GuanDianLianJie() : base() { this.ConditionPanelName = "连接管点信息"; InitializeComponent(); uilbRemark.Text = "首先在界面上标记需要连接的管点。一般为2个,起点和终点。\r\n 在地图上双击选择管点"; } protected override void OnLoad(EventArgs e) { ComsStatic.SetLayerIsEditableFalse(); MapControl.MouseDoubleClick += MapControl_MouseDoubleClick; } private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e) { Point2D point = this.MapControl.Map.PixelToMap(new Point(e.X, e.Y)); GeoPoint _clickPoint = new GeoPoint(point); Recordset rdJSJDPT = ComsStatic.dvJSJDPT.Query(_clickPoint, 30, CursorType.Static); if (rdJSJDPT.RecordCount == 0) { Sunny.UI.UIMessageTip.ShowError("当前鼠标双击点附近没有找到管线节点"); return; } double distance = 0.0D; double distance_temp = 0.0D; GeoPoint _rdPoint = new GeoPoint(); GeoPoint _rdPoint_temp; string bsm = ""; rdJSJDPT.MoveFirst(); while (!rdJSJDPT.IsEOF) { _rdPoint_temp = new GeoPoint((double)rdJSJDPT.GetFieldValue("x"), (double)rdJSJDPT.GetFieldValue("y")); distance_temp = Geometrist.Distance(_clickPoint, _rdPoint_temp); if (distance_temp <= distance || distance == 0.0D) { distance = distance_temp; _rdPoint = _rdPoint_temp; bsm = rdJSJDPT.GetFieldValue("bsm").ToString(); } rdJSJDPT.MoveNext(); } if (_goeLinePoints.Count == 2) _goeLinePoints.Remove(1); _goeLinePoints.Add(new Point2D(_rdPoint.X, _rdPoint.Y)); if (_goeLinePoints.Count == 1) { _qsdh = bsm; int index = MapControl.Map.TrackingLayer.IndexOf("GuanDianLianJie_Start"); if (index >= 0) { MapControl.Map.TrackingLayer.Remove(index); } MapControl.Map.TrackingLayer.Add(_rdPoint, "GuanDianLianJie_Start"); MapControl.Map.Refresh(); uilbStart.Text = string.Format("起点X坐标:{0:F2},Y坐标:{1:F2}。\r\n 起点标识码:{2}", _rdPoint.X, _rdPoint.Y, _qsdh); } if (_goeLinePoints.Count == 2) { _zddh = bsm; int index = MapControl.Map.TrackingLayer.IndexOf("GuanDianLianJie_End"); if (index >= 0) { MapControl.Map.TrackingLayer.Remove(index); } MapControl.Map.TrackingLayer.Add(_rdPoint, "GuanDianLianJie_End"); MapControl.Map.Refresh(); uilbEnd.Text = string.Format("终点X坐标:{0:F2},Y坐标:{1:F2}。\r\n 起点标识码:{2}", _rdPoint.X, _rdPoint.Y, _zddh); } } private void uibtnLianjie_Click(object sender, EventArgs e) { if (_goeLinePoints.Count != 2) { Sunny.UI.UIMessageTip.ShowError("必须在界面上标记需要连接的2个管点!"); return; } _geoLine = new GeoLine(_goeLinePoints); _goeLinePoints.Clear(); _geoLine.Style = m_GeoStyle; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.TrackingLayer.Add(_geoLine, "GuanDianLianJie_geoLine"); MapControl.Map.Refresh(); } public override object Do(DockPanel dockPanel = null) { if (_qsdh == _zddh) { Sunny.UI.UIMessageTip.ShowError("起始点号和终点点号不能相同"); return false; } this.IsShowResultWindow = false; Recordset _rd = dvJSLK_cp.GetRecordset(false, CursorType.Dynamic); if (_geoLine is null) { Sunny.UI.UIMessageTip.ShowError("请先确认连接的管点和管线"); return false; } _rd.AddNew(_geoLine); _rd.SetFieldValue("qsdh", _qsdh); _rd.SetFieldValue("zddh", _zddh); _rd.SetFieldValue("lrrq", DateTime.Now); _rd.SetFieldValue("enabled", 1); _rd.SetFieldValue("cd", Math.Round(_geoLine.Length, 2)); _rd.SetFieldValue("shape_length", _geoLine.Length); Int32 objID = Int32.Parse(ComsStatic.GetMaxValue(ComsStatic.dvJSLK, "OBJECTID").ToString()) + 1; _rd.SetFieldValue("objectid", objID); _rd.SetFieldValue("fldm", "供水管线"); _rd.SetFieldValue("bsm", "JSLK" + objID); _rd.SetFieldValue("cqbh", "管点连接"); if (_rd.Update()) { _rd.Close(); _rd.Dispose(); Sunny.UI.UIMessageTip.ShowOk("信息更新成功!"); MapControl.Map.TrackingLayer.Clear(); } else { Sunny.UI.UIMessageTip.ShowError("信息更新失败,请重新操作!"); return false; } return true; } private void uiButton2_Click(object sender, EventArgs e) { _goeLinePoints.Clear(); base.AfterClose(); } public override void AfterClose() { MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick; base.AfterClose(); } private void InitializeComponent() { this.plMain = new System.Windows.Forms.Panel(); this.uilbEnd = new Sunny.UI.UILabel(); this.uilbStart = new Sunny.UI.UILabel(); this.uiButton2 = new Sunny.UI.UIButton(); this.uibtnLianjie = new Sunny.UI.UIButton(); this.uilbRemark = new Sunny.UI.UILabel(); this.plMain.SuspendLayout(); this.SuspendLayout(); // // plMain // this.plMain.AutoScroll = true; this.plMain.Controls.Add(this.uilbEnd); this.plMain.Controls.Add(this.uilbStart); this.plMain.Controls.Add(this.uiButton2); this.plMain.Controls.Add(this.uibtnLianjie); this.plMain.Controls.Add(this.uilbRemark); this.plMain.Dock = System.Windows.Forms.DockStyle.Fill; this.plMain.Location = new System.Drawing.Point(0, 0); this.plMain.Name = "plMain"; this.plMain.Size = new System.Drawing.Size(399, 268); this.plMain.TabIndex = 0; // // uilbEnd // this.uilbEnd.AutoSize = true; this.uilbEnd.Font = new System.Drawing.Font("微软雅黑", 12F); this.uilbEnd.Location = new System.Drawing.Point(7, 179); this.uilbEnd.Name = "uilbEnd"; this.uilbEnd.Size = new System.Drawing.Size(74, 21); this.uilbEnd.Style = Sunny.UI.UIStyle.Gray; this.uilbEnd.TabIndex = 4; this.uilbEnd.Text = "终点信息"; this.uilbEnd.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // uilbStart // this.uilbStart.AutoSize = true; this.uilbStart.Font = new System.Drawing.Font("微软雅黑", 12F); this.uilbStart.Location = new System.Drawing.Point(8, 104); this.uilbStart.Name = "uilbStart"; this.uilbStart.Size = new System.Drawing.Size(74, 21); this.uilbStart.Style = Sunny.UI.UIStyle.Gray; this.uilbStart.TabIndex = 3; this.uilbStart.Text = "起点信息"; this.uilbStart.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // uiButton2 // this.uiButton2.Cursor = System.Windows.Forms.Cursors.Hand; this.uiButton2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uiButton2.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165))))); this.uiButton2.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uiButton2.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uiButton2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiButton2.Location = new System.Drawing.Point(176, 53); this.uiButton2.MinimumSize = new System.Drawing.Size(1, 1); this.uiButton2.Name = "uiButton2"; this.uiButton2.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uiButton2.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165))))); this.uiButton2.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uiButton2.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uiButton2.Size = new System.Drawing.Size(100, 35); this.uiButton2.Style = Sunny.UI.UIStyle.Gray; this.uiButton2.TabIndex = 2; this.uiButton2.Text = "取消连接"; this.uiButton2.Click += new System.EventHandler(this.uiButton2_Click); // // uibtnLianjie // this.uibtnLianjie.Cursor = System.Windows.Forms.Cursors.Hand; this.uibtnLianjie.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uibtnLianjie.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165))))); this.uibtnLianjie.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uibtnLianjie.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uibtnLianjie.Font = new System.Drawing.Font("微软雅黑", 12F); this.uibtnLianjie.Location = new System.Drawing.Point(33, 53); this.uibtnLianjie.MinimumSize = new System.Drawing.Size(1, 1); this.uibtnLianjie.Name = "uibtnLianjie"; this.uibtnLianjie.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.uibtnLianjie.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165))))); this.uibtnLianjie.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uibtnLianjie.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129))))); this.uibtnLianjie.Size = new System.Drawing.Size(100, 35); this.uibtnLianjie.Style = Sunny.UI.UIStyle.Gray; this.uibtnLianjie.TabIndex = 1; this.uibtnLianjie.Text = "管点连接"; this.uibtnLianjie.Click += new System.EventHandler(this.uibtnLianjie_Click); // // uilbRemark // this.uilbRemark.AutoSize = true; this.uilbRemark.Font = new System.Drawing.Font("微软雅黑", 12F); this.uilbRemark.Location = new System.Drawing.Point(4, 4); this.uilbRemark.Name = "uilbRemark"; this.uilbRemark.Size = new System.Drawing.Size(74, 21); this.uilbRemark.Style = Sunny.UI.UIStyle.Gray; this.uilbRemark.TabIndex = 0; this.uilbRemark.Text = "操作步骤"; this.uilbRemark.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // GuanDianLianJie // this.Controls.Add(this.plMain); this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244))))); this.Name = "GuanDianLianJie"; this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140))))); this.Size = new System.Drawing.Size(399, 268); this.Style = Sunny.UI.UIStyle.Gray; this.plMain.ResumeLayout(false); this.plMain.PerformLayout(); this.ResumeLayout(false); } } }