123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using GrxCAD.DatabaseServices;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
-
- namespace HCTools
- {
- public partial class DeleteElept : Form
- {
- public DeleteElept()
- {
- InitializeComponent();
- }
-
- private void DeleteElept_Load(object sender, EventArgs e)
- {
- this.comboBox_gcd.DropDownStyle = ComboBoxStyle.DropDownList;
- this.comboBox_blc.DropDownStyle = ComboBoxStyle.DropDownList;
-
- //自动填充下拉框
- Database database = GrxCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
- //存放所有图层名
- List<string> alllayername = new List<string>();
- LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
- foreach (ObjectId objid in layertable)
- {
- LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
- alllayername.Add(layertablerecord.Name);
- }
-
- alllayername.Sort();
-
- for (int i = 0; i < alllayername.Count; i++)
- {
- this.comboBox_gcd.Items.Add(alllayername[i]);
- this.checkedListBox_ly.Items.Add(alllayername[i]);
- }
-
- if (alllayername.Contains("8300"))
- {
- int index = alllayername.IndexOf("8300");
- this.comboBox_gcd.SelectedIndex = index;
- }
- traction.Commit();
- }
- }
-
- private void button_ok_Click(object sender, EventArgs e)
- {
- if (comboBox_gcd.Text == "")
- {
- MessageBox.Show("请选择高程点所在图层!");
- return;
- }
- if (comboBox_blc.Text == "")
- {
- MessageBox.Show("请选择比例尺!");
- return;
- }
- if (checkedListBox_ly.CheckedItems.Count == 0)
- {
- MessageBox.Show("请至少选择一个图层!");
- return;
- }
- DeletePts.gcdly = comboBox_gcd.Text;
- string blctext = comboBox_blc.Text;
- int blcindex = blctext.LastIndexOf(':');
- string strblc = blctext.Substring(blcindex + 1);
- DeletePts.blc = Convert.ToInt32(strblc);
-
- for (int i = 0; i < checkedListBox_ly.CheckedItems.Count; i++)
- {
- DeletePts.delely.Add(checkedListBox_ly.CheckedItems[i].ToString());
- }
- DeletePts delept = new DeletePts();
- delept.delept();
- this.Close();
- }
-
- private void button_cancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|