PengZhuang.cs 10 KB

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