GuanXianShanChu.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using Sunny.UI;
  2. using SuperMap.Data;
  3. using SuperMap.Mapping;
  4. using SuperMap.UI;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Drawing;
  8. using System.Windows.Forms;
  9. using WeifenLuo.WinFormsUI.Docking;
  10. using WWPipeLine.MapBasic;
  11. using WWPipeLine.MapBasic.Conditions;
  12. namespace WWPipeLine.MapTools.Conditions.EditGuanWang
  13. {
  14. public class GuanXianShanChu : ConditionPanel
  15. {
  16. private UILabel labName;
  17. private UILabel tbValue;
  18. private Recordset _recordset = null;
  19. public GuanXianShanChu() : base()
  20. {
  21. this.ConditionPanelName = "删除管线信息";
  22. this.SetSize(500, 800);
  23. InitializeComponent();
  24. }
  25. protected override void OnLoad(EventArgs e)
  26. {
  27. ComsStatic.SetLayersIsSelectableFalse(ComsStatic.dvJSLK.Name, true);
  28. MapControl.GeometrySelected += MapControl_GeometrySelected;
  29. }
  30. private void MapControl_GeometrySelected(object sender, GeometrySelectedEventArgs e)
  31. {
  32. this.Controls.Clear();
  33. Selection[] _selection = base.MapControl.Map.FindSelection(true);
  34. if (_selection.Length != 1 || _selection[0].Count != 1)
  35. {
  36. Sunny.UI.UIMessageTip.ShowError("仅可以选择一个需要删除的管线信息", 2000); return;
  37. }
  38. _recordset = _selection[0].ToRecordset();
  39. DatasetVector _dv = _recordset.Dataset as DatasetVector;
  40. if (_dv.Name != ComsStatic.dvJSLK.Name)
  41. {
  42. Sunny.UI.UIMessageTip.ShowError("仅可以选择供水管线图层!", 2000); return;
  43. }
  44. FieldInfos infos = _recordset.GetFieldInfos();
  45. foreach (FieldInfo info in infos)
  46. {
  47. //不显示的字段
  48. string HideTag = ",SmID,SmX,SmY,SmLibTileID,SmLength,SmTopoError,SmUserID,SmGeometry,OBJECTID,WTH,TFH,DMT,TSDH,SSBH,ROTATEANGLE,ENABLED,ANCILLARYROLE,X,Y,SHAPE_Length,ANCILLARYROLE,tzbm,zcbh,qdms,zdms,CQBH,LRRQ,".ToLower();
  49. if (HideTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
  50. labName = new UILabel()
  51. {
  52. Name = info.Name,
  53. Text = info.Caption,
  54. TextAlign = ContentAlignment.BottomCenter,
  55. Location = new System.Drawing.Point(20, 20 + this.Controls.Count * 16),
  56. Style = UIStyle.Gray,
  57. Width = 100
  58. };
  59. this.Controls.Add(labName);
  60. tbValue = new UILabel()
  61. {
  62. Name = "tbValue",
  63. Text = _recordset.GetFieldValue(info.Name)?.ToString(),
  64. Location = new System.Drawing.Point(140, this.Controls.Count * 16),
  65. Style = UIStyle.Gray,
  66. Width = 250
  67. };
  68. this.Controls.Add(tbValue);
  69. }
  70. }
  71. public override object Do(DockPanel dockPanel = null)
  72. {
  73. if (_recordset is null) { UIMessageTip.ShowError("请先选择需要删除的元素"); return false; }
  74. this.IsShowResultWindow = false;
  75. ComsStatic.ShowUIMessageTipOKorError(_recordset.DeleteAll());
  76. MapControl.Map.Refresh();
  77. return null;
  78. }
  79. public override void AfterClose()
  80. {
  81. MapControl.GeometrySelected -= MapControl_GeometrySelected;
  82. ComsStatic.RecordsetDispose(_recordset);
  83. base.AfterClose();
  84. }
  85. private void InitializeComponent()
  86. {
  87. this.SuspendLayout();
  88. //
  89. // GuanXianShanChu
  90. //
  91. this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
  92. this.Name = "GuanXianShanChu";
  93. this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  94. this.Style = Sunny.UI.UIStyle.Gray;
  95. this.ResumeLayout(false);
  96. }
  97. }
  98. }