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 DgxAnno : Form { public DgxAnno() { InitializeComponent(); } private void DgxAnno_Load(object sender, EventArgs e) { this.comboBox_ptLayer.DropDownStyle = ComboBoxStyle.DropDownList; this.comboBox_gw.DropDownStyle = ComboBoxStyle.DropDownList; this.MaximizeBox = false; this.StartPosition = FormStartPosition.CenterScreen; //自动填充下拉框 Database database = GrxCAD.DatabaseServices.HostApplicationServices.WorkingDatabase; using (Transaction traction = database.TransactionManager.StartTransaction()) { //存放所有图层名 List alllayername = new List(); 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_ptLayer.Items.Add(alllayername[i]); this.comboBox_gw.Items.Add(alllayername[i]); } if (alllayername.Contains("8121")) { int index = alllayername.IndexOf("8121"); this.comboBox_ptLayer.SelectedIndex = index; } traction.Commit(); } } private void button_ok_Click(object sender, EventArgs e) { if (comboBox_ptLayer.Text == "") { MessageBox.Show("请选择等高线注记所在图层!"); return; } if (comboBox_gw.Text == "") { MessageBox.Show("请选择格网所在图层!"); return; } if (textBox_density.Text == "") { MessageBox.Show("请输入密度!"); return; } DgxAnnck.ptlayer = comboBox_ptLayer.Text; DgxAnnck.tklayer = comboBox_gw.Text; DgxAnnck.density = Convert.ToDouble(textBox_density.Text); if (checkBox_below.Checked && !checkBox_upon.Checked) DgxAnnck.flag = 1; else if (!checkBox_below.Checked && checkBox_upon.Checked) DgxAnnck.flag = 2; else if (checkBox_below.Checked && checkBox_upon.Checked) DgxAnnck.flag = 3; else if (!checkBox_below.Checked && !checkBox_upon.Checked) { MessageBox.Show("请选择“大于密度”/“小于密度”!"); return; } DgxAnnck dgx = new DgxAnnck(); dgx.check(); this.Close(); } private void button_cancel_Click(object sender, EventArgs e) { this.Close(); } } }