123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- using System;
- using System.Collections.Generic;
- using WeifenLuo.WinFormsUI.Docking;
- using WWPipeLine.MapBasic.Conditions;
- using WWPipeLine.MapBasic;
- using SuperMap.Data;
- using SuperMap.Mapping;
- using System.Data;
- using System.Windows.Forms;
- using Sunny.UI;
- using System.Drawing;
- using System.Text;
- namespace WWPipeLine.MapTools.Conditions.AnalystToolBar
- {
- public class PengZhuang : ConditionPanel
- {
- private UIRadioButton uiRBpz;
- private UIRadioButton uiRBsp;
- private UIRadioButton uiRBcz;
- private UIPanel uiPanelgx;
- private UIPanel uiPanel1;
- private UILabel uiLabel1;
- private UITextBox uitbBanjing;
- private UIRadioButtonGroup uiubg;
- private Label lbGxxinxi;
- Selection[] _selection;
- Recordset _rdSelect = null;
- DatasetVector _dv;
- public PengZhuang() : base()
- {
- this.ConditionPanelName = "碰撞分析";
- this.SetSize(500, 600);
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- ComsStatic.SetLayersIsSelectableFalse(ComsStatic.dvJSLK.Name, true);
- MapControl.GeometrySelected += MapControl_GeometrySelected;
- }
- private void MapControl_GeometrySelected(object sender, SuperMap.UI.GeometrySelectedEventArgs e)
- {
- MapControl.Map.TrackingLayer.Clear();
- _selection = base.MapControl.Map.FindSelection(true);
- _rdSelect = _selection[0].ToRecordset();
- _dv = _rdSelect.Dataset as DatasetVector;
- if (_dv.Name != ComsStatic.dvJSLK.Name || _selection[0].Count != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("仅可以选择管线图层,仅可以选择一条管线"); return;
- }
- DataTable dtSelectJSLK = ComsStatic.GetJSLKbyJSJDPT(ComsStatic.RecordsetToDataTable(_rdSelect));
- if (dtSelectJSLK.Rows.Count == 1)
- {
- StringBuilder jslk = new StringBuilder();
- foreach (DataColumn dc in dtSelectJSLK.Columns)
- {
- if ((" smid qsdh zddh qdsmid qdsmx qdsmy qddmgc qdgdms qdgc zdsmid zdsmx zdsmy zddmgc zdgdms zdgc").Contains(dc.ColumnName))
- jslk.Append(dc.Caption + ": " + dtSelectJSLK.Rows[0][dc.ColumnName] + " \r\n ");
- }
- lbGxxinxi.Text = jslk.ToString();
- }
- }
- private double[] getJingJu()
- {
- QueryParameter queryParameter = new QueryParameter
- {
- AttributeFilter = " gxpzlx='净距配置' ",
- ResultFields = new string[] { "smid", "gxlx", "gxpzlx", "gxcz", "gxspjj", "gxczjj" },
- OrderBy = new string[] { "smid" },
- CursorType = CursorType.Dynamic,
- HasGeometry = true
- };
- Recordset _rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
- if (_rd is null) return new double[] { 0, 0 };
- _rd.MoveLast();
- return new double[] { ComsStatic.StringToDouble(_rd.GetFieldValue("gxspjj")), MapBasic.ComsStatic.StringToDouble(_rd.GetFieldValue("gxczjj")) };
- }
- public override object Do(DockPanel dockPanel = null)
- {
- if (_selection == null)
- {
- Sunny.UI.UIMessageTip.ShowError("请先选择需要分析的管线信息!", 2000); return false;
- }
- if (_dv == null || _dv.Name != ComsStatic.dvJSLK.Name || _selection[0].Count != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("仅可以选择管线图层,仅可以选择一条管线", 2000); return false;
- }
- double[] jingju = getJingJu();
- if (jingju.Length != 2)
- {
- Sunny.UI.UIMessageTip.ShowError("系统未配置水平净距和垂直净距,无法分析", 2000); return false;
- }
- this.IsShowResultWindow = false;
- double banjing = ComsStatic.StringToDouble(uitbBanjing.Text);
- if (banjing == 0.0)
- {
- Sunny.UI.UIMessageTip.ShowError("请输入正确的分析半径", 4000); return false;
- }
- _rdSelect.MoveFirst();
- Geometry geometry = _rdSelect.GetGeometry();
- int selectSMID = geometry.ID;
- //查询 当前选择的管线 半径内的管线
- Recordset rd = dvJSLK_cp.Query(geometry, banjing, CursorType.Static);
- GeoStyle geoStyle = new GeoStyle { LineColor = Color.Red, LineWidth = 1.2 };
- rd.MoveFirst();
- while (!rd.IsEOF)
- {
- geometry = rd.GetGeometry();
- geometry.Style = geoStyle;
- MapControl.Map.TrackingLayer.Add(geometry, "StartDraw" + rd.GetCurrentIndex());
- rd.MoveNext();
- }
- MapControl.Map.Refresh();
- string fenxileixing = "碰撞";
- if (uiRBpz.Checked) fenxileixing = "碰撞";
- if (uiRBsp.Checked) fenxileixing = "水平";
- if (uiRBcz.Checked) fenxileixing = "垂直";
- DataTable dtFinal = ComsStatic.GetJSLKbyJSJDPT(ComsStatic.RecordsetToDataTable(rd));
- PengZhuangAnalystResult form = new PengZhuangAnalystResult(dtFinal, banjing, fenxileixing, selectSMID, jingju);
- //pengZhuangAnalystResult.ShowDialog();
- this.Invoke((MethodInvoker)delegate () { form.ShowDialog(); });
- return null;
- }
- public override void AfterClose()
- {
- if (!(_rdSelect is null)) { _rdSelect.Close(); _rdSelect.Dispose(); }
- MapControl.GeometrySelected -= MapControl_GeometrySelected;
- base.AfterClose();
- }
- private void uitbBanjing_KeyPress(object sender, KeyPressEventArgs e)
- {
- if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar < 96 || e.KeyChar > 105) && (e.KeyChar != 8))
- e.Handled = true;
- }
- private void InitializeComponent()
- {
- this.uiubg = new Sunny.UI.UIRadioButtonGroup();
- this.uiRBcz = new Sunny.UI.UIRadioButton();
- this.uiRBsp = new Sunny.UI.UIRadioButton();
- this.uiRBpz = new Sunny.UI.UIRadioButton();
- this.uiPanelgx = new Sunny.UI.UIPanel();
- this.lbGxxinxi = new System.Windows.Forms.Label();
- this.uiPanel1 = new Sunny.UI.UIPanel();
- this.uitbBanjing = new Sunny.UI.UITextBox();
- this.uiLabel1 = new Sunny.UI.UILabel();
- this.uiubg.SuspendLayout();
- this.uiPanelgx.SuspendLayout();
- this.uiPanel1.SuspendLayout();
- this.SuspendLayout();
- //
- // uiubg
- //
- this.uiubg.ColumnCount = 3;
- this.uiubg.Controls.Add(this.uiRBcz);
- this.uiubg.Controls.Add(this.uiRBsp);
- this.uiubg.Controls.Add(this.uiRBpz);
- this.uiubg.Dock = System.Windows.Forms.DockStyle.Top;
- this.uiubg.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiubg.Location = new System.Drawing.Point(0, 0);
- this.uiubg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.uiubg.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiubg.Name = "uiubg";
- this.uiubg.Padding = new System.Windows.Forms.Padding(0, 32, 0, 0);
- this.uiubg.Size = new System.Drawing.Size(500, 67);
- this.uiubg.TabIndex = 0;
- this.uiubg.Text = "分析类型";
- this.uiubg.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // uiRBcz
- //
- this.uiRBcz.Cursor = System.Windows.Forms.Cursors.Hand;
- this.uiRBcz.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiRBcz.Location = new System.Drawing.Point(331, 30);
- this.uiRBcz.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiRBcz.Name = "uiRBcz";
- this.uiRBcz.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
- this.uiRBcz.Size = new System.Drawing.Size(123, 29);
- this.uiRBcz.TabIndex = 2;
- this.uiRBcz.Text = "垂直净距分析";
- //
- // uiRBsp
- //
- this.uiRBsp.Cursor = System.Windows.Forms.Cursors.Hand;
- this.uiRBsp.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiRBsp.Location = new System.Drawing.Point(176, 30);
- this.uiRBsp.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiRBsp.Name = "uiRBsp";
- this.uiRBsp.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
- this.uiRBsp.Size = new System.Drawing.Size(123, 29);
- this.uiRBsp.TabIndex = 1;
- this.uiRBsp.Text = "水平净距分析";
- //
- // uiRBpz
- //
- this.uiRBpz.Checked = true;
- this.uiRBpz.Cursor = System.Windows.Forms.Cursors.Hand;
- this.uiRBpz.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiRBpz.Location = new System.Drawing.Point(21, 30);
- this.uiRBpz.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiRBpz.Name = "uiRBpz";
- this.uiRBpz.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
- this.uiRBpz.Size = new System.Drawing.Size(123, 29);
- this.uiRBpz.TabIndex = 0;
- this.uiRBpz.Text = "碰撞分析";
- //
- // uiPanelgx
- //
- this.uiPanelgx.Controls.Add(this.lbGxxinxi);
- this.uiPanelgx.Dock = System.Windows.Forms.DockStyle.Fill;
- this.uiPanelgx.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiPanelgx.Location = new System.Drawing.Point(0, 67);
- this.uiPanelgx.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.uiPanelgx.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiPanelgx.Name = "uiPanelgx";
- this.uiPanelgx.Size = new System.Drawing.Size(500, 448);
- this.uiPanelgx.TabIndex = 1;
- this.uiPanelgx.Text = null;
- this.uiPanelgx.TextAlignment = System.Drawing.ContentAlignment.TopLeft;
- //
- // lbGxxinxi
- //
- this.lbGxxinxi.AutoSize = true;
- this.lbGxxinxi.Location = new System.Drawing.Point(3, 5);
- this.lbGxxinxi.Name = "lbGxxinxi";
- this.lbGxxinxi.Size = new System.Drawing.Size(154, 21);
- this.lbGxxinxi.TabIndex = 0;
- this.lbGxxinxi.Text = "当前选择管线的信息";
- //
- // uiPanel1
- //
- this.uiPanel1.Controls.Add(this.uitbBanjing);
- this.uiPanel1.Controls.Add(this.uiLabel1);
- this.uiPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.uiPanel1.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiPanel1.Location = new System.Drawing.Point(0, 471);
- this.uiPanel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.uiPanel1.MinimumSize = new System.Drawing.Size(1, 1);
- this.uiPanel1.Name = "uiPanel1";
- this.uiPanel1.Size = new System.Drawing.Size(500, 44);
- this.uiPanel1.TabIndex = 2;
- this.uiPanel1.Text = null;
- this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // uitbBanjing
- //
- this.uitbBanjing.Cursor = System.Windows.Forms.Cursors.IBeam;
- this.uitbBanjing.DoubleValue = 2D;
- this.uitbBanjing.FillColor = System.Drawing.Color.White;
- this.uitbBanjing.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uitbBanjing.IntValue = 2;
- this.uitbBanjing.Location = new System.Drawing.Point(124, 5);
- this.uitbBanjing.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.uitbBanjing.Maximum = 2147483647D;
- this.uitbBanjing.Minimum = -2147483648D;
- this.uitbBanjing.MinimumSize = new System.Drawing.Size(1, 1);
- this.uitbBanjing.Name = "uitbBanjing";
- this.uitbBanjing.Size = new System.Drawing.Size(76, 29);
- this.uitbBanjing.TabIndex = 1;
- this.uitbBanjing.Text = "2";
- this.uitbBanjing.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
- this.uitbBanjing.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.uitbBanjing_KeyPress);
- //
- // uiLabel1
- //
- this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiLabel1.Location = new System.Drawing.Point(17, 9);
- this.uiLabel1.Name = "uiLabel1";
- this.uiLabel1.Size = new System.Drawing.Size(100, 23);
- this.uiLabel1.TabIndex = 0;
- this.uiLabel1.Text = "分析半径(M):";
- this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // PengZhuang
- //
- this.Controls.Add(this.uiPanel1);
- this.Controls.Add(this.uiPanelgx);
- this.Controls.Add(this.uiubg);
- this.Name = "PengZhuang";
- this.Size = new System.Drawing.Size(500, 515);
- this.uiubg.ResumeLayout(false);
- this.uiPanelgx.ResumeLayout(false);
- this.uiPanelgx.PerformLayout();
- this.uiPanel1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- }
- }
|