| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- using Sunny.UI;
- using SuperMap.Data;
- using SuperMap.Mapping;
- using System;
- using System.Drawing;
- using WeifenLuo.WinFormsUI.Docking;
- using WWPipeLine.MapBasic.Conditions;
- using System.Windows.Forms;
- using WWPipeLine.MapBasic;
- namespace WWPipeLine.MapTools.Conditions.EditGuanWang
- {
- public class GuanDianXinZeng : ConditionPanel
- {
- private GeoPoint _geoPoint = null;
- private GroupBox groupBoxLayer;
- private UICheckBox uiCBpol;
- private UICheckBox uiCheckBox1;
- private LayerWithDataListPanel LayerPanel;
- public GuanDianXinZeng() : base()
- {
- this.ConditionPanelName = "新增管点信息";
- InitializeComponent();
- LayerPanel = new LayerWithDataListPanel();
- LayerPanel.LoadToVector(false, false);
- groupBoxLayer.Controls.Add(LayerPanel);
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.MouseDoubleClick += MapControl_MouseDoubleClick;
- }
- private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (LayerPanel.SelectLayers.Count != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("请选择需要编辑的图层"); return;
- }
- Point2D pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y));
- if (uiCBpol.Checked)//限制线上点
- {
- GeoPoint pointClick = new GeoPoint(pClick);
- Recordset rdJSLK = ComsStatic.dvJSLK.Query(pointClick, 3, CursorType.Static);
- if (rdJSLK.RecordCount == 0)
- {
- Sunny.UI.UIMessageTip.ShowError("当前鼠标双击点附近没有找到管线信息"); return;
- }
- double distance_temp = 0.0D;
- double distance = 0.0D;
- GeoLine _rd_temp;
- GeoLine _rd_line = new GeoLine();
- rdJSLK.MoveFirst();
- while (!rdJSLK.IsEOF)
- {
- _rd_temp = rdJSLK.GetGeometry() as GeoLine;
- distance_temp = Geometrist.Distance(pointClick, _rd_temp);
- if (distance_temp <= distance || distance == 0.0D)
- {
- distance = distance_temp;
- _rd_line = _rd_temp;
- }
- rdJSLK.MoveNext();
- }
- pClick = Geometrist.NearestPointToVertex(pClick, _rd_line);
- //bool PointOnLine = Geometrist.HasCommonPoint(new GeoPoint(pClick), _rd_line);
- }
- if (uiCheckBox1.Checked)//限制于节点重合
- {
- GeoPoint pointClick = new GeoPoint(pClick);
- Recordset rdJSJDPT = ComsStatic.dvJSJDPT.Query(pointClick, 3, CursorType.Static);
- if (rdJSJDPT.RecordCount == 0)
- {
- Sunny.UI.UIMessageTip.ShowError("当前鼠标双击点附近没有找到节点信息"); return;
- }
- double distance_temp = 0.0D;
- double distance = 0.0D;
- GeoPoint p_temp;
- rdJSJDPT.MoveFirst();
- while (!rdJSJDPT.IsEOF)
- {
- p_temp = rdJSJDPT.GetGeometry() as GeoPoint;
- distance_temp = Geometrist.Distance(pointClick, p_temp);
- if (distance_temp <= distance || distance == 0.0D)
- {
- distance = distance_temp;
- pClick = p_temp.InnerPoint;
- }
- rdJSJDPT.MoveNext();
- }
- }
- _geoPoint = new GeoPoint(pClick);
- _geoPoint.Style = new GeoStyle { MarkerSize = new Size2D(5, 5), LineColor = Color.Red };
- MapControl.Map.TrackingLayer.Clear();
- MapControl.Map.TrackingLayer.Add(_geoPoint, "jiedian");
- MapControl.Map.RefreshEx(MapControl.Map.ViewBounds);
- }
- public override object Do(DockPanel dockPanel = null)
- {
- this.IsShowResultWindow = false;
- if (LayerPanel.SelectLayers.Count != 1 || _geoPoint is null)
- {
- Sunny.UI.UIMessageTip.ShowError("请选择需要编辑的图层,并在界面中点选节点位置"); return false;
- }
- DatasetVector _dv = LayerPanel.SelectLayers[0].Dataset as DatasetVector;
- Recordset _rd = _dv.GetRecordset(true, CursorType.Dynamic);
- Int32 objID = ComsStatic.GetMaxValueInt(_dv, "OBJECTID") + 1;
- _rd.AddNew(_geoPoint);
- _rd.SetFieldValue("x", _geoPoint.X);
- _rd.SetFieldValue("y", _geoPoint.Y);
- _rd.SetFieldValue("ms", 0);
- _rd.SetFieldValue("lrrq", DateTime.Now.ToLocalTime());
- _rd.SetFieldValue("enabled", 1);
- _rd.SetFieldValue("bsm", _dv.Name + objID);
- _rd.SetFieldValue("fldm", LayerPanel.SelectLayers[0].Caption);
- _rd.SetFieldValue("objectid", objID);
- _rd.SetFieldValue("cqbh", "管点新增");
- if (_rd.Update())
- {
- ComsStatic.ShowOKLog(LayerPanel.SelectLayers[0].Caption + "新增成功");
- MapControl.Map.TrackingLayer.Clear();
- //Int32 smid = _dvEx.QueryGetSMID(string.Format(" objectid={0}", objID - 1));
- //Selection selection = new Selection() { Dataset = _layer.Dataset as DatasetVector };
- //selection.Add(smid);
- //_layer.Selection = selection;
- //MapControl.Map.Refresh();
- //if (selection.Count == 1)
- //{
- // this.ParentForm.Close();
- // XiuGai xiugaiForm = new XiuGai();
- // xiugaiForm.Show();
- //}
- }
- else
- {
- ComsStatic.ShowErrorLog(LayerPanel.SelectLayers[0].Caption + "新增失败");
- }
- return null;
- }
- public override void AfterClose()
- {
- MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick;
- base.AfterClose();
- }
- private void InitializeComponent()
- {
- this.groupBoxLayer = new System.Windows.Forms.GroupBox();
- this.uiCBpol = new Sunny.UI.UICheckBox();
- this.uiCheckBox1 = new Sunny.UI.UICheckBox();
- this.SuspendLayout();
- //
- // groupBoxLayer
- //
- this.groupBoxLayer.Dock = System.Windows.Forms.DockStyle.Top;
- this.groupBoxLayer.Location = new System.Drawing.Point(0, 0);
- this.groupBoxLayer.Name = "groupBoxLayer";
- this.groupBoxLayer.Size = new System.Drawing.Size(500, 236);
- this.groupBoxLayer.TabIndex = 26;
- this.groupBoxLayer.TabStop = false;
- this.groupBoxLayer.Text = "管点图层";
- //
- // uiCBpol
- //
- this.uiCBpol.CheckBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
- this.uiCBpol.Cursor = System.Windows.Forms.Cursors.Hand;
- this.uiCBpol.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiCBpol.Location = new System.Drawing.Point(26, 242);
- this.uiCBpol.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiCBpol.Name = "uiCBpol";
- this.uiCBpol.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
- this.uiCBpol.Size = new System.Drawing.Size(178, 29);
- this.uiCBpol.Style = Sunny.UI.UIStyle.Gray;
- this.uiCBpol.TabIndex = 0;
- this.uiCBpol.Text = "限制线上点";
- //
- // uiCheckBox1
- //
- this.uiCheckBox1.CheckBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
- this.uiCheckBox1.Cursor = System.Windows.Forms.Cursors.Hand;
- this.uiCheckBox1.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiCheckBox1.Location = new System.Drawing.Point(238, 242);
- this.uiCheckBox1.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiCheckBox1.Name = "uiCheckBox1";
- this.uiCheckBox1.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
- this.uiCheckBox1.Size = new System.Drawing.Size(178, 29);
- this.uiCheckBox1.Style = Sunny.UI.UIStyle.Gray;
- this.uiCheckBox1.TabIndex = 27;
- this.uiCheckBox1.Text = "限制与节点重合";
- //
- // GuanDianXinZeng
- //
- this.Controls.Add(this.uiCheckBox1);
- this.Controls.Add(this.uiCBpol);
- this.Controls.Add(this.groupBoxLayer);
- this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
- this.Name = "GuanDianXinZeng";
- this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
- this.Size = new System.Drawing.Size(500, 315);
- this.Style = Sunny.UI.UIStyle.Gray;
- this.ResumeLayout(false);
- }
- }
- }
|