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(300, 200); InitializeComponent(); this.IsShowResultWindow = false; } protected override void OnLoad(EventArgs e) { ComsStatic.SetLayersIsSelectableFalse(ComsStatic.gsGuanXian.Name, false); 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.gsGuanDian.Query(_clickPoint, 10, 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; int smid = 0; rdJSJDPT.MoveFirst(); while (!rdJSJDPT.IsEOF) { _rdPoint_temp = new GeoPoint( rdJSJDPT.GetDouble("x"), rdJSJDPT.GetDouble("y")); distance_temp = Geometrist.Distance(_clickPoint, _rdPoint_temp); if (distance_temp <= distance || distance == 0.0D) { distance = distance_temp; _rdPoint = _rdPoint_temp; smid = rdJSJDPT.GetID(); } rdJSJDPT.MoveNext(); } rdJSJDPT.SeekID(smid); string bsm = rdJSJDPT.GetFieldValue("bsm").ToString(); _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.RefreshTrackingLayer(); uilbStart.Text = string.Format("起点{0} 附属物:{1}", rdJSJDPT.GetString("fldm"), rdJSJDPT.GetString("fsw")); } 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.RefreshTrackingLayer(); uilbEnd.Text = string.Format("终点{0} 附属物:{1}", rdJSJDPT.GetString("fldm"), rdJSJDPT.GetString("fsw")); } } 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.RefreshTrackingLayer(); } public override object Do(DockPanel dockPanel = null) { if (_qsdh == _zddh) { Sunny.UI.UIMessageTip.ShowError("起始点号和终点点号不能相同"); return false; } int index = MapControl.Map.TrackingLayer.IndexOf("GuanDianLianJie_geoLine"); if (_geoLine is null || index != 0) { Sunny.UI.UIMessageTip.ShowError("请先确认预览连接管线"); return false; } Recordset _rd = ComsStatic.gsGuanXian.GetRecordset(false, CursorType.Dynamic); _rd.AddNew(_geoLine); _rd.SetFieldValue("qsdh", _qsdh); _rd.SetFieldValue("zddh", _zddh); _rd.SetFieldValue("lrrq", DateTime.Now.ToLocalTime()); _rd.SetFieldValue("shape_length", _geoLine.Length); _rd.SetFieldValue("cd", ComsStatic.StringToDouble(_geoLine.Length, 2)); Int32 objID = ComsStatic.GetMaxValueInt(ComsStatic.gsGuanXian, "objectid") + 1; _rd.SetFieldValue("objectid", objID); _rd.SetFieldValue("fldm", ComsStatic.dvGXCaption); _rd.SetFieldValue("bsm", ComsStatic.dvGXDatasetName + objID); _rd.SetFieldValue("cqbh", "管点连接"); if (_rd.Update()) { ComsStatic.RecordsetDispose(_rd); ComsStatic.ShowOKLog("管点连接操作成功!", objID.ToString()); } else { ComsStatic.ShowErrorLog("管点连接操作失败!"); } MapControl.Map.TrackingLayer.Clear(); MapControl.Map.RefreshEx(MapControl.Map.ViewBounds); _geoLine = null; _goeLinePoints.Clear(); uilbStart.Text = "起点信息:"; uilbEnd.Text = "终点信息:"; return null; } private void uiButton2_Click(object sender, EventArgs e) { MapControl.Map.TrackingLayer.Clear(); MapControl.Map.RefreshTrackingLayer(); _geoLine = null; _goeLinePoints.Clear(); uilbStart.Text = "起点信息:"; uilbEnd.Text = "终点信息:"; } 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, 46); 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, 6); 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(162, 82); 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(8, 82); 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(113, 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(300, 115); this.Style = Sunny.UI.UIStyle.Gray; this.ResumeLayout(false); this.PerformLayout(); } } }