using GrxCAD.DatabaseServices; using System; using System.Collections; 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 DGXGeneral : Form { public DGXGeneral() { InitializeComponent(); } private void DGXGeneral_Load(object sender, EventArgs e) { this.comboBox_dgj.DropDownStyle = ComboBoxStyle.DropDownList; 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.checkedListBox_dgxtc.Items.Add(alllayername[i]); } traction.Commit(); } } private void butn_ok_Click(object sender, EventArgs e) { ArrayList eplayerlist = new ArrayList(); if (checkedListBox_dgxtc.CheckedItems.Count > 0) { int count = checkedListBox_dgxtc.CheckedItems.Count; for (int i = 0; i < count; i++) { eplayerlist.Add(checkedListBox_dgxtc.CheckedItems[i].ToString()); } } else { MessageBox.Show("请选择处理等高线图层!", "警告"); return; } if (comboBox_dgj.Text == "") { GrxCAD.ApplicationServices.Application.ShowAlertDialog("请选择等高距"); return; } DGXGeneralization.dgxlayerlist = eplayerlist; DGXGeneralization.dgj = double.Parse(comboBox_dgj.Text); DGXGeneralization.dgxGeneralization(); this.Close(); } } }