工具箱相关
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.

DgxAnno.cs 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 DgxAnno : Form
  14. {
  15. public DgxAnno()
  16. {
  17. InitializeComponent();
  18. }
  19. private void DgxAnno_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("8121"))
  44. {
  45. int index = alllayername.IndexOf("8121");
  46. this.comboBox_ptLayer.SelectedIndex = index;
  47. }
  48. traction.Commit();
  49. }
  50. }
  51. private void button_ok_Click(object sender, EventArgs e)
  52. {
  53. if (comboBox_ptLayer.Text == "")
  54. {
  55. MessageBox.Show("请选择等高线注记所在图层!");
  56. return;
  57. }
  58. if (comboBox_gw.Text == "")
  59. {
  60. MessageBox.Show("请选择格网所在图层!");
  61. return;
  62. }
  63. if (textBox_density.Text == "")
  64. {
  65. MessageBox.Show("请输入密度!");
  66. return;
  67. }
  68. DgxAnnck.ptlayer = comboBox_ptLayer.Text;
  69. DgxAnnck.tklayer = comboBox_gw.Text;
  70. DgxAnnck.density = Convert.ToDouble(textBox_density.Text);
  71. if (checkBox_below.Checked && !checkBox_upon.Checked)
  72. DgxAnnck.flag = 1;
  73. else if (!checkBox_below.Checked && checkBox_upon.Checked)
  74. DgxAnnck.flag = 2;
  75. else if (checkBox_below.Checked && checkBox_upon.Checked)
  76. DgxAnnck.flag = 3;
  77. else if (!checkBox_below.Checked && !checkBox_upon.Checked)
  78. {
  79. MessageBox.Show("请选择“大于密度”/“小于密度”!");
  80. return;
  81. }
  82. DgxAnnck dgx = new DgxAnnck();
  83. dgx.check();
  84. this.Close();
  85. }
  86. private void button_cancel_Click(object sender, EventArgs e)
  87. {
  88. this.Close();
  89. }
  90. }
  91. }