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 UIButton uibtnLianjie; private UIButton uiButton2; private UILabel uilbStart; private GeoLine _geoLine = null; private Point2Ds _goeLinePoints = new Point2Ds(); private string _qsdh = "未确认"; private string _zddh = "未确认"; private UILabel uilbEnd; public GuanDianLianJie() : base() { this.ConditionPanelName = "连接管点信息"; this.SetSize(500, 185); InitializeComponent(); this.IsShowResultWindow = false; } protected override void OnLoad(EventArgs e) { ComsStatic.SetLayersIsSelectableFalse(ComsStatic.dvJSJDPT.Name, true); MapControl.MouseDoubleClick += MapControl_MouseDoubleClick; } private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e) { Point2D point = 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 = null; 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(); } _rdPoint.Style = ComsStatic.geoStyle_Red_Mark5mm; if (_goeLinePoints.Count == 2) _goeLinePoints.Remove(1); _goeLinePoints.Add(new Point2D(_rdPoint.X, _rdPoint.Y)); if (_goeLinePoints.Count == 1) { _qsdh = bsm; MapControl.Map.TrackingLayer.Add(_rdPoint, "GuanDianLianJie_Start"); MapControl.Map.Refresh(); uilbStart.Text = string.Format("起点坐标({0:F2},{1:F2}) 标识码:{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("终点坐标({0:F2},{1:F2}) 标识码:{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 = ComsStatic.geoStyle_Red_1mm_OpaqueRate; 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; } Recordset _rd = ComsStatic.dvJSLK.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 = ComsStatic.GetMaxValueInt(ComsStatic.dvJSLK, "OBJECTID") + 1; _rd.SetFieldValue("objectid", objID); _rd.SetFieldValue("fldm", "供水管线"); _rd.SetFieldValue("bsm", "JSLK" + objID); _rd.SetFieldValue("cqbh", "管点连接"); if (_rd.Update()) { _rd.Close(); _rd.Dispose(); ComsStatic.ShowOKLog("管点连接操作成功!"); MapControl.Map.TrackingLayer.Clear(); _geoLine = null; return true; } else { ComsStatic.ShowErrorLog("管点连接更新失败!"); MapControl.Map.TrackingLayer.Clear(); _geoLine = null; return false; } } private void uiButton2_Click(object sender, EventArgs e) { _goeLinePoints.Clear(); MapControl.Map.TrackingLayer.Clear(); base.AfterClose(); } public override void AfterClose() { MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick; base.AfterClose(); } private void InitializeComponent() { 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.SuspendLayout(); // // uilbEnd // this.uilbEnd.AutoSize = true; this.uilbEnd.Font = new System.Drawing.Font("微软雅黑", 12F); this.uilbEnd.Location = new System.Drawing.Point(4, 36); this.uilbEnd.Name = "uilbEnd"; this.uilbEnd.Size = new System.Drawing.Size(90, 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(4, 8); this.uilbStart.Name = "uilbStart"; this.uilbStart.Size = new System.Drawing.Size(90, 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(279, 62); 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(113, 30); 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(125, 62); 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(124, 30); this.uibtnLianjie.Style = Sunny.UI.UIStyle.Gray; this.uibtnLianjie.TabIndex = 1; this.uibtnLianjie.Text = "预览连接管线"; this.uibtnLianjie.Click += new System.EventHandler(this.uibtnLianjie_Click); // // GuanDianLianJie // this.Controls.Add(this.uilbEnd); this.Controls.Add(this.uilbStart); this.Controls.Add(this.uiButton2); this.Controls.Add(this.uibtnLianjie); 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(500, 100); this.Style = Sunny.UI.UIStyle.Gray; this.ResumeLayout(false); this.PerformLayout(); } } }