工具箱相关
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EleptDensity.cs 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using GrxCAD.DatabaseServices;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace HCTools
  12. {
  13. public partial class EleptDensity : Form
  14. {
  15. public EleptDensity()
  16. {
  17. InitializeComponent();
  18. }
  19. private void EleptDensity_Load(object sender, EventArgs e)
  20. {
  21. this.comboBox_ptLayer.DropDownStyle = ComboBoxStyle.DropDownList;
  22. this.comboBox_gw.DropDownStyle = ComboBoxStyle.DropDownList;
  23. this.MaximizeBox = false;
  24. this.StartPosition = FormStartPosition.CenterScreen;
  25. //自动填充下拉框
  26. Database database = GrxCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
  27. using (Transaction traction = database.TransactionManager.StartTransaction())
  28. {
  29. //存放所有图层名
  30. List<string> alllayername = new List<string>();
  31. LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
  32. foreach (ObjectId objid in layertable)
  33. {
  34. LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
  35. alllayername.Add(layertablerecord.Name);
  36. }
  37. alllayername.Sort();
  38. for (int i = 0; i < alllayername.Count; i++)
  39. {
  40. this.comboBox_ptLayer.Items.Add(alllayername[i]);
  41. this.comboBox_gw.Items.Add(alllayername[i]);
  42. }
  43. if (alllayername.Contains("8300"))
  44. {
  45. int index = alllayername.IndexOf("8300");
  46. this.comboBox_ptLayer.SelectedIndex = index;
  47. }
  48. traction.Commit();
  49. }
  50. }
  51. private void button_cancel_Click(object sender, EventArgs e)
  52. {
  53. this.Close();
  54. }
  55. private void button_ok_Click(object sender, EventArgs e)
  56. {
  57. if(comboBox_ptLayer.Text == "")
  58. {
  59. MessageBox.Show("请选择高程点所在图层!");
  60. return;
  61. }
  62. if (comboBox_gw.Text == "")
  63. {
  64. MessageBox.Show("请选择格网所在图层!");
  65. return;
  66. }
  67. if (textBox_density.Text == "")
  68. {
  69. MessageBox.Show("请输入密度!");
  70. return;
  71. }
  72. EleptDenck.ptlayer = comboBox_ptLayer.Text;
  73. EleptDenck.tklayer = comboBox_gw.Text;
  74. EleptDenck.density = Convert.ToDouble(textBox_density.Text);
  75. if(checkBox_below.Checked && !checkBox_upon.Checked)
  76. EleptDenck.flag = 1;
  77. else if (!checkBox_below.Checked && checkBox_upon.Checked)
  78. EleptDenck.flag = 2;
  79. else if(checkBox_below.Checked && checkBox_upon.Checked)
  80. EleptDenck.flag = 3;
  81. else if(!checkBox_below.Checked && !checkBox_upon.Checked)
  82. {
  83. MessageBox.Show("请选择“大于密度”/“小于密度”!");
  84. return;
  85. }
  86. EleptDenck denck = new EleptDenck();
  87. denck.Ptdensity();
  88. this.Close();
  89. }
  90. }
  91. }