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

DeleteElept.cs 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 DeleteElept : Form
  14. {
  15. public DeleteElept()
  16. {
  17. InitializeComponent();
  18. }
  19. private void DeleteElept_Load(object sender, EventArgs e)
  20. {
  21. this.comboBox_gcd.DropDownStyle = ComboBoxStyle.DropDownList;
  22. this.comboBox_blc.DropDownStyle = ComboBoxStyle.DropDownList;
  23. //自动填充下拉框
  24. Database database = GrxCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
  25. using (Transaction traction = database.TransactionManager.StartTransaction())
  26. {
  27. //存放所有图层名
  28. List<string> alllayername = new List<string>();
  29. LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
  30. foreach (ObjectId objid in layertable)
  31. {
  32. LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
  33. alllayername.Add(layertablerecord.Name);
  34. }
  35. alllayername.Sort();
  36. for (int i = 0; i < alllayername.Count; i++)
  37. {
  38. this.comboBox_gcd.Items.Add(alllayername[i]);
  39. this.checkedListBox_ly.Items.Add(alllayername[i]);
  40. }
  41. if (alllayername.Contains("8300"))
  42. {
  43. int index = alllayername.IndexOf("8300");
  44. this.comboBox_gcd.SelectedIndex = index;
  45. }
  46. traction.Commit();
  47. }
  48. }
  49. private void button_ok_Click(object sender, EventArgs e)
  50. {
  51. if (comboBox_gcd.Text == "")
  52. {
  53. MessageBox.Show("请选择高程点所在图层!");
  54. return;
  55. }
  56. if (comboBox_blc.Text == "")
  57. {
  58. MessageBox.Show("请选择比例尺!");
  59. return;
  60. }
  61. if (checkedListBox_ly.CheckedItems.Count == 0)
  62. {
  63. MessageBox.Show("请至少选择一个图层!");
  64. return;
  65. }
  66. DeletePts.gcdly = comboBox_gcd.Text;
  67. string blctext = comboBox_blc.Text;
  68. int blcindex = blctext.LastIndexOf(':');
  69. string strblc = blctext.Substring(blcindex + 1);
  70. DeletePts.blc = Convert.ToInt32(strblc);
  71. for (int i = 0; i < checkedListBox_ly.CheckedItems.Count; i++)
  72. {
  73. DeletePts.delely.Add(checkedListBox_ly.CheckedItems[i].ToString());
  74. }
  75. DeletePts delept = new DeletePts();
  76. delept.delept();
  77. this.Close();
  78. }
  79. private void button_cancel_Click(object sender, EventArgs e)
  80. {
  81. this.Close();
  82. }
  83. }
  84. }