GDfenlei.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using SuperMap.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using WeifenLuo.WinFormsUI.Docking;
  5. using WWPipeLine.MapBasic.Conditions;
  6. using WWPipeLine.MapBasic;
  7. using System.Windows.Forms;
  8. using Sunny.UI;
  9. using System.Data;
  10. using SuperMap.Mapping;
  11. using System.Drawing;
  12. namespace WWPipeLine.MapTools.Conditions.Statistics
  13. {
  14. public class GDfenlei : ConditionPanel
  15. {
  16. private GroupBox groupBox1;
  17. private GroupBox groupBox2;
  18. private LayerWithDataListPanel LayerPanel;
  19. public GDfenlei() : base()
  20. {
  21. this.ConditionPanelName = "管点分类统计";
  22. InitializeComponent();
  23. }
  24. protected override void OnLoad(EventArgs e)
  25. {
  26. LayerPanel = new LayerWithDataListPanel();
  27. LayerPanel.LoadToVector(false, false);
  28. groupBox1.Controls.Add(LayerPanel);
  29. Dictionary<string, string> dic = new Dictionary<string, string>();
  30. dic.Add("gg", "规格"); dic.Add("cz", "材质"); dic.Add("gj", "管径"); dic.Add("dzms", "地址描述"); dic.Add("qsdw", "权属单位");
  31. foreach (string key in dic.Keys)
  32. {
  33. UICheckBox uiCheckBox = new UICheckBox() { Name = key, Text = dic[key], Location = new Point(20, 20 + groupBox2.Controls.Count * 28), Style = Sunny.UI.UIStyle.Gray };
  34. groupBox2.Controls.Add(uiCheckBox);
  35. }
  36. }
  37. public override object Do(DockPanel dockPanel = null)
  38. {
  39. if (LayerPanel.SelectLayers.Count != 1)
  40. {
  41. Sunny.UI.UIMessageTip.ShowError("请先选择需要统计的图层"); return false;
  42. }
  43. List<string> strField = new List<string>();
  44. foreach (Control ct in groupBox2.Controls)
  45. {
  46. UICheckBox ck = ct as UICheckBox;
  47. if (ck.Checked) strField.Add(ck.Name);
  48. }
  49. if (strField.Count == 0)
  50. {
  51. Sunny.UI.UIMessageTip.ShowError("请先选择需要统计的字段"); return false;
  52. }
  53. DatasetVector dv = LayerPanel.SelectLayers[0].Dataset as DatasetVector;
  54. return ComsStatic.TongJiFieldGroupCount(dv, strField.ToArray());
  55. }
  56. private void InitializeComponent()
  57. {
  58. this.groupBox1 = new System.Windows.Forms.GroupBox();
  59. this.groupBox2 = new System.Windows.Forms.GroupBox();
  60. this.SuspendLayout();
  61. //
  62. // groupBox1
  63. //
  64. this.groupBox1.Dock = System.Windows.Forms.DockStyle.Left;
  65. this.groupBox1.Location = new System.Drawing.Point(0, 0);
  66. this.groupBox1.Name = "groupBox1";
  67. this.groupBox1.Size = new System.Drawing.Size(200, 315);
  68. this.groupBox1.TabIndex = 0;
  69. this.groupBox1.TabStop = false;
  70. this.groupBox1.Text = "管点类型";
  71. //
  72. // groupBox2
  73. //
  74. this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
  75. this.groupBox2.Location = new System.Drawing.Point(200, 0);
  76. this.groupBox2.Name = "groupBox2";
  77. this.groupBox2.Size = new System.Drawing.Size(300, 315);
  78. this.groupBox2.TabIndex = 1;
  79. this.groupBox2.TabStop = false;
  80. this.groupBox2.Text = "分类字段";
  81. //
  82. // GDfenlei
  83. //
  84. this.Controls.Add(this.groupBox2);
  85. this.Controls.Add(this.groupBox1);
  86. this.Name = "GDfenlei";
  87. this.Size = new System.Drawing.Size(500, 315);
  88. this.ResumeLayout(false);
  89. }
  90. }
  91. }