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 EleptDensity : Form { public EleptDensity() { InitializeComponent(); } private void EleptDensity_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("8300")) { int index = alllayername.IndexOf("8300"); this.comboBox_ptLayer.SelectedIndex = index; } traction.Commit(); } } private void button_cancel_Click(object sender, EventArgs e) { this.Close(); } 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; } EleptDenck.ptlayer = comboBox_ptLayer.Text; EleptDenck.tklayer = comboBox_gw.Text; EleptDenck.density = Convert.ToDouble(textBox_density.Text); if(checkBox_below.Checked && !checkBox_upon.Checked) EleptDenck.flag = 1; else if (!checkBox_below.Checked && checkBox_upon.Checked) EleptDenck.flag = 2; else if(checkBox_below.Checked && checkBox_upon.Checked) EleptDenck.flag = 3; else if(!checkBox_below.Checked && !checkBox_upon.Checked) { MessageBox.Show("请选择“大于密度”/“小于密度”!"); return; } EleptDenck denck = new EleptDenck(); denck.Ptdensity(); this.Close(); } } }