GuanXianHuiFu.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.Conditions;
  11. using WWPipeLine.MapBasic;
  12. namespace WWPipeLine.MapTools.Conditions.EditGuanWang
  13. {
  14. public class GuanXianHuiFu : ConditionPanel
  15. {
  16. private UILabel labName;
  17. private UILabel tbValue;
  18. private Recordset _recordset = null;
  19. public GuanXianHuiFu() : base()
  20. {
  21. this.ConditionPanelName = "废弃管线、节点信息";
  22. this.SetSize(500, 800);
  23. InitializeComponent();
  24. }
  25. protected override void OnLoad(EventArgs e)
  26. {
  27. MapControl.GeometrySelectChanged += MapControl_GeometrySelectChanged;
  28. }
  29. private void MapControl_GeometrySelectChanged(object sender, GeometrySelectChangedEventArgs e)
  30. {
  31. this.Controls.Clear();
  32. Selection[] _selection = base.MapControl.Map.FindSelection(true);
  33. if (_selection.Length != 1 || _selection[0].Count != 1)
  34. {
  35. Sunny.UI.UIMessageTip.ShowError("仅可以选择一个需要恢复的信息!", 2000); return;
  36. }
  37. _recordset = _selection[0].ToRecordset();
  38. FieldInfos infos = _recordset.GetFieldInfos();
  39. foreach (FieldInfo info in infos)
  40. {
  41. //不显示的字段
  42. 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();
  43. if (HideTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
  44. labName = new UILabel()
  45. {
  46. Name = info.Name,
  47. Text = info.Caption,
  48. TextAlign = ContentAlignment.BottomCenter,
  49. Location = new System.Drawing.Point(20, 20 + this.Controls.Count * 16),
  50. Style = UIStyle.Gray,
  51. Width = 100
  52. };
  53. this.Controls.Add(labName);
  54. tbValue = new UILabel()
  55. {
  56. Name = "tbValue",
  57. Text = _recordset.GetFieldValue(info.Name)?.ToString(),
  58. Location = new System.Drawing.Point(140, this.Controls.Count * 16),
  59. Style = UIStyle.Gray,
  60. Width = 250
  61. };
  62. this.Controls.Add(tbValue);
  63. }
  64. }
  65. public override object Do(DockPanel dockPanel = null)
  66. {
  67. if (_recordset is null) { UIMessageTip.ShowError("请先选择需要操作的元素"); return false; }
  68. this.IsShowResultWindow = false;
  69. _recordset.Edit();
  70. _recordset.SetFieldValue("enabled", 1);
  71. ComsStatic.ShowUIMessageTipOKorError(_recordset.Update());
  72. return null;
  73. }
  74. public override void AfterClose()
  75. {
  76. MapControl.GeometrySelectChanged -= MapControl_GeometrySelectChanged;
  77. ComsStatic.RecordsetDispose(_recordset);
  78. base.AfterClose();
  79. }
  80. private void InitializeComponent()
  81. {
  82. this.SuspendLayout();
  83. //
  84. // GuanXianHuiFu
  85. //
  86. this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
  87. this.Name = "GuanXianHuiFu";
  88. this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  89. this.Style = Sunny.UI.UIStyle.Gray;
  90. this.ResumeLayout(false);
  91. }
  92. }
  93. }