PengZhuang.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System;
  2. using System.Collections.Generic;
  3. using WeifenLuo.WinFormsUI.Docking;
  4. using WWPipeLine.MapBasic.Conditions;
  5. using WWPipeLine.MapBasic;
  6. using SuperMap.Data;
  7. using SuperMap.Mapping;
  8. using System.Data;
  9. using System.Windows.Forms;
  10. using Sunny.UI;
  11. using System.Drawing;
  12. using System.Text;
  13. namespace WWPipeLine.MapTools.Conditions.AnalystToolBar
  14. {
  15. public class PengZhuang : ConditionPanel
  16. {
  17. private UIRadioButton uiRBpz;
  18. private UIRadioButton uiRBsp;
  19. private UIRadioButton uiRBcz;
  20. private UIPanel uiPanelgx;
  21. private UIPanel uiPanel1;
  22. private UILabel uiLabel1;
  23. private UITextBox uitbBanjing;
  24. private UIRadioButtonGroup uiubg;
  25. private Label lbGxxinxi;
  26. Selection[] _selection;
  27. Recordset _rdSelect = null;
  28. DatasetVector _dv;
  29. public PengZhuang() : base()
  30. {
  31. this.ConditionPanelName = "碰撞分析";
  32. this.SetSize(500, 600);
  33. InitializeComponent();
  34. }
  35. protected override void OnLoad(EventArgs e)
  36. {
  37. ComsStatic.SetLayersIsSelectableFalse(ComsStatic.dvJSLK.Name, true);
  38. MapControl.GeometrySelected += MapControl_GeometrySelected;
  39. }
  40. private void MapControl_GeometrySelected(object sender, SuperMap.UI.GeometrySelectedEventArgs e)
  41. {
  42. MapControl.Map.TrackingLayer.Clear();
  43. _selection = base.MapControl.Map.FindSelection(true);
  44. _rdSelect = _selection[0].ToRecordset();
  45. _dv = _rdSelect.Dataset as DatasetVector;
  46. if (_dv.Name != ComsStatic.dvJSLK.Name || _selection[0].Count != 1)
  47. {
  48. Sunny.UI.UIMessageTip.ShowError("仅可以选择管线图层,仅可以选择一条管线"); return;
  49. }
  50. DataTable dtSelectJSLK = ComsStatic.GetJSLKbyJSJDPT(ComsStatic.RecordsetToDataTable(_rdSelect));
  51. if (dtSelectJSLK.Rows.Count == 1)
  52. {
  53. StringBuilder jslk = new StringBuilder();
  54. foreach (DataColumn dc in dtSelectJSLK.Columns)
  55. {
  56. if ((" smid qsdh zddh qdsmid qdsmx qdsmy qddmgc qdgdms qdgc zdsmid zdsmx zdsmy zddmgc zdgdms zdgc").Contains(dc.ColumnName))
  57. jslk.Append(dc.Caption + ": " + dtSelectJSLK.Rows[0][dc.ColumnName] + " \r\n ");
  58. }
  59. lbGxxinxi.Text = jslk.ToString();
  60. }
  61. }
  62. private double[] getJingJu()
  63. {
  64. QueryParameter queryParameter = new QueryParameter
  65. {
  66. AttributeFilter = " gxpzlx='净距配置' ",
  67. ResultFields = new string[] { "smid", "gxlx", "gxpzlx", "gxcz", "gxspjj", "gxczjj" },
  68. OrderBy = new string[] { "smid" },
  69. CursorType = CursorType.Dynamic,
  70. HasGeometry = true
  71. };
  72. Recordset _rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  73. if (_rd is null) return new double[] { 0, 0 };
  74. _rd.MoveLast();
  75. return new double[] { ComsStatic.StringToDouble(_rd.GetFieldValue("gxspjj")), MapBasic.ComsStatic.StringToDouble(_rd.GetFieldValue("gxczjj")) };
  76. }
  77. public override object Do(DockPanel dockPanel = null)
  78. {
  79. if (_selection == null)
  80. {
  81. Sunny.UI.UIMessageTip.ShowError("请先选择需要分析的管线信息!", 2000); return false;
  82. }
  83. if (_dv == null || _dv.Name != ComsStatic.dvJSLK.Name || _selection[0].Count != 1)
  84. {
  85. Sunny.UI.UIMessageTip.ShowError("仅可以选择管线图层,仅可以选择一条管线", 2000); return false;
  86. }
  87. double[] jingju = getJingJu();
  88. if (jingju.Length != 2)
  89. {
  90. Sunny.UI.UIMessageTip.ShowError("系统未配置水平净距和垂直净距,无法分析", 2000); return false;
  91. }
  92. this.IsShowResultWindow = false;
  93. double banjing = ComsStatic.StringToDouble(uitbBanjing.Text);
  94. if (banjing == 0.0)
  95. {
  96. Sunny.UI.UIMessageTip.ShowError("请输入正确的分析半径", 4000); return false;
  97. }
  98. _rdSelect.MoveFirst();
  99. Geometry geometry = _rdSelect.GetGeometry();
  100. int selectSMID = geometry.ID;
  101. //查询 当前选择的管线 半径内的管线
  102. Recordset rd = dvJSLK_cp.Query(geometry, banjing, CursorType.Static);
  103. GeoStyle geoStyle = new GeoStyle { LineColor = Color.Red, LineWidth = 1.2 };
  104. rd.MoveFirst();
  105. while (!rd.IsEOF)
  106. {
  107. geometry = rd.GetGeometry();
  108. geometry.Style = geoStyle;
  109. MapControl.Map.TrackingLayer.Add(geometry, "StartDraw" + rd.GetCurrentIndex());
  110. rd.MoveNext();
  111. }
  112. MapControl.Map.Refresh();
  113. string fenxileixing = "碰撞";
  114. if (uiRBpz.Checked) fenxileixing = "碰撞";
  115. if (uiRBsp.Checked) fenxileixing = "水平";
  116. if (uiRBcz.Checked) fenxileixing = "垂直";
  117. DataTable dtFinal = ComsStatic.GetJSLKbyJSJDPT(ComsStatic.RecordsetToDataTable(rd));
  118. PengZhuangAnalystResult form = new PengZhuangAnalystResult(dtFinal, banjing, fenxileixing, selectSMID, jingju);
  119. //pengZhuangAnalystResult.ShowDialog();
  120. this.Invoke((MethodInvoker)delegate () { form.ShowDialog(); });
  121. return null;
  122. }
  123. public override void AfterClose()
  124. {
  125. if (!(_rdSelect is null)) { _rdSelect.Close(); _rdSelect.Dispose(); }
  126. MapControl.GeometrySelected -= MapControl_GeometrySelected;
  127. base.AfterClose();
  128. }
  129. private void uitbBanjing_KeyPress(object sender, KeyPressEventArgs e)
  130. {
  131. if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar < 96 || e.KeyChar > 105) && (e.KeyChar != 8))
  132. e.Handled = true;
  133. }
  134. private void InitializeComponent()
  135. {
  136. this.uiubg = new Sunny.UI.UIRadioButtonGroup();
  137. this.uiRBcz = new Sunny.UI.UIRadioButton();
  138. this.uiRBsp = new Sunny.UI.UIRadioButton();
  139. this.uiRBpz = new Sunny.UI.UIRadioButton();
  140. this.uiPanelgx = new Sunny.UI.UIPanel();
  141. this.lbGxxinxi = new System.Windows.Forms.Label();
  142. this.uiPanel1 = new Sunny.UI.UIPanel();
  143. this.uitbBanjing = new Sunny.UI.UITextBox();
  144. this.uiLabel1 = new Sunny.UI.UILabel();
  145. this.uiubg.SuspendLayout();
  146. this.uiPanelgx.SuspendLayout();
  147. this.uiPanel1.SuspendLayout();
  148. this.SuspendLayout();
  149. //
  150. // uiubg
  151. //
  152. this.uiubg.ColumnCount = 3;
  153. this.uiubg.Controls.Add(this.uiRBcz);
  154. this.uiubg.Controls.Add(this.uiRBsp);
  155. this.uiubg.Controls.Add(this.uiRBpz);
  156. this.uiubg.Dock = System.Windows.Forms.DockStyle.Top;
  157. this.uiubg.Font = new System.Drawing.Font("微软雅黑", 12F);
  158. this.uiubg.Location = new System.Drawing.Point(0, 0);
  159. this.uiubg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  160. this.uiubg.MinimumSize = new System.Drawing.Size(1, 1);
  161. this.uiubg.Name = "uiubg";
  162. this.uiubg.Padding = new System.Windows.Forms.Padding(0, 32, 0, 0);
  163. this.uiubg.Size = new System.Drawing.Size(500, 67);
  164. this.uiubg.TabIndex = 0;
  165. this.uiubg.Text = "分析类型";
  166. this.uiubg.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  167. //
  168. // uiRBcz
  169. //
  170. this.uiRBcz.Cursor = System.Windows.Forms.Cursors.Hand;
  171. this.uiRBcz.Font = new System.Drawing.Font("微软雅黑", 12F);
  172. this.uiRBcz.Location = new System.Drawing.Point(331, 30);
  173. this.uiRBcz.MinimumSize = new System.Drawing.Size(1, 1);
  174. this.uiRBcz.Name = "uiRBcz";
  175. this.uiRBcz.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
  176. this.uiRBcz.Size = new System.Drawing.Size(123, 29);
  177. this.uiRBcz.TabIndex = 2;
  178. this.uiRBcz.Text = "垂直净距分析";
  179. //
  180. // uiRBsp
  181. //
  182. this.uiRBsp.Cursor = System.Windows.Forms.Cursors.Hand;
  183. this.uiRBsp.Font = new System.Drawing.Font("微软雅黑", 12F);
  184. this.uiRBsp.Location = new System.Drawing.Point(176, 30);
  185. this.uiRBsp.MinimumSize = new System.Drawing.Size(1, 1);
  186. this.uiRBsp.Name = "uiRBsp";
  187. this.uiRBsp.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
  188. this.uiRBsp.Size = new System.Drawing.Size(123, 29);
  189. this.uiRBsp.TabIndex = 1;
  190. this.uiRBsp.Text = "水平净距分析";
  191. //
  192. // uiRBpz
  193. //
  194. this.uiRBpz.Checked = true;
  195. this.uiRBpz.Cursor = System.Windows.Forms.Cursors.Hand;
  196. this.uiRBpz.Font = new System.Drawing.Font("微软雅黑", 12F);
  197. this.uiRBpz.Location = new System.Drawing.Point(21, 30);
  198. this.uiRBpz.MinimumSize = new System.Drawing.Size(1, 1);
  199. this.uiRBpz.Name = "uiRBpz";
  200. this.uiRBpz.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
  201. this.uiRBpz.Size = new System.Drawing.Size(123, 29);
  202. this.uiRBpz.TabIndex = 0;
  203. this.uiRBpz.Text = "碰撞分析";
  204. //
  205. // uiPanelgx
  206. //
  207. this.uiPanelgx.Controls.Add(this.lbGxxinxi);
  208. this.uiPanelgx.Dock = System.Windows.Forms.DockStyle.Fill;
  209. this.uiPanelgx.Font = new System.Drawing.Font("微软雅黑", 12F);
  210. this.uiPanelgx.Location = new System.Drawing.Point(0, 67);
  211. this.uiPanelgx.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  212. this.uiPanelgx.MinimumSize = new System.Drawing.Size(1, 1);
  213. this.uiPanelgx.Name = "uiPanelgx";
  214. this.uiPanelgx.Size = new System.Drawing.Size(500, 448);
  215. this.uiPanelgx.TabIndex = 1;
  216. this.uiPanelgx.Text = null;
  217. this.uiPanelgx.TextAlignment = System.Drawing.ContentAlignment.TopLeft;
  218. //
  219. // lbGxxinxi
  220. //
  221. this.lbGxxinxi.AutoSize = true;
  222. this.lbGxxinxi.Location = new System.Drawing.Point(3, 5);
  223. this.lbGxxinxi.Name = "lbGxxinxi";
  224. this.lbGxxinxi.Size = new System.Drawing.Size(154, 21);
  225. this.lbGxxinxi.TabIndex = 0;
  226. this.lbGxxinxi.Text = "当前选择管线的信息";
  227. //
  228. // uiPanel1
  229. //
  230. this.uiPanel1.Controls.Add(this.uitbBanjing);
  231. this.uiPanel1.Controls.Add(this.uiLabel1);
  232. this.uiPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
  233. this.uiPanel1.Font = new System.Drawing.Font("微软雅黑", 12F);
  234. this.uiPanel1.Location = new System.Drawing.Point(0, 471);
  235. this.uiPanel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  236. this.uiPanel1.MinimumSize = new System.Drawing.Size(1, 1);
  237. this.uiPanel1.Name = "uiPanel1";
  238. this.uiPanel1.Size = new System.Drawing.Size(500, 44);
  239. this.uiPanel1.TabIndex = 2;
  240. this.uiPanel1.Text = null;
  241. this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  242. //
  243. // uitbBanjing
  244. //
  245. this.uitbBanjing.Cursor = System.Windows.Forms.Cursors.IBeam;
  246. this.uitbBanjing.DoubleValue = 2D;
  247. this.uitbBanjing.FillColor = System.Drawing.Color.White;
  248. this.uitbBanjing.Font = new System.Drawing.Font("微软雅黑", 12F);
  249. this.uitbBanjing.IntValue = 2;
  250. this.uitbBanjing.Location = new System.Drawing.Point(124, 5);
  251. this.uitbBanjing.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  252. this.uitbBanjing.Maximum = 2147483647D;
  253. this.uitbBanjing.Minimum = -2147483648D;
  254. this.uitbBanjing.MinimumSize = new System.Drawing.Size(1, 1);
  255. this.uitbBanjing.Name = "uitbBanjing";
  256. this.uitbBanjing.Size = new System.Drawing.Size(76, 29);
  257. this.uitbBanjing.TabIndex = 1;
  258. this.uitbBanjing.Text = "2";
  259. this.uitbBanjing.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  260. this.uitbBanjing.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.uitbBanjing_KeyPress);
  261. //
  262. // uiLabel1
  263. //
  264. this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
  265. this.uiLabel1.Location = new System.Drawing.Point(17, 9);
  266. this.uiLabel1.Name = "uiLabel1";
  267. this.uiLabel1.Size = new System.Drawing.Size(100, 23);
  268. this.uiLabel1.TabIndex = 0;
  269. this.uiLabel1.Text = "分析半径(M):";
  270. this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  271. //
  272. // PengZhuang
  273. //
  274. this.Controls.Add(this.uiPanel1);
  275. this.Controls.Add(this.uiPanelgx);
  276. this.Controls.Add(this.uiubg);
  277. this.Name = "PengZhuang";
  278. this.Size = new System.Drawing.Size(500, 515);
  279. this.uiubg.ResumeLayout(false);
  280. this.uiPanelgx.ResumeLayout(false);
  281. this.uiPanelgx.PerformLayout();
  282. this.uiPanel1.ResumeLayout(false);
  283. this.ResumeLayout(false);
  284. }
  285. }
  286. }