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 CutCountL : Form { public CutCountL() { InitializeComponent(); } private void CutCountL_Load(object sender, EventArgs e) { this.dgxCJ_blc_co.DropDownStyle = ComboBoxStyle.DropDownList; this.dgxCJ_jqx_co.DropDownStyle = ComboBoxStyle.DropDownList; this.dgxCJ_sqx_co.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.dgxCJ_jqx_co.Items.Add(alllayername[i]); this.dgxCJ_sqx_co.Items.Add(alllayername[i]); } if (alllayername.Contains("8300")) { int index = alllayername.IndexOf("8300"); } if (alllayername.Contains("8110")) { int index = alllayername.IndexOf("8110"); this.dgxCJ_sqx_co.SelectedIndex = index; } if (alllayername.Contains("8120")) { int index = alllayername.IndexOf("8120"); this.dgxCJ_jqx_co.SelectedIndex = index; } traction.Commit(); } } private void OK_Click(object sender, EventArgs e) { if (dgxCJ_blc_co.Text == "") { GrxCAD.ApplicationServices.Application.ShowAlertDialog("请选择比例尺"); return; } if (dgxCJ_sqx_co.Text == "") { GrxCAD.ApplicationServices.Application.ShowAlertDialog("请选择首曲线图层"); return; } if (dgxCJ_jqx_co.Text == "") { GrxCAD.ApplicationServices.Application.ShowAlertDialog("请选择计曲线图层"); return; } if (dgxCJ_gcc_te.Text == "") { GrxCAD.ApplicationServices.Application.ShowAlertDialog("请输入计曲线高程差"); return; } if (dgxCJ_hlcd_te.Text == "") { GrxCAD.ApplicationServices.Application.ShowAlertDialog("请输入可忽略的裁剪长度"); return; } if (dgxCJ_cjjl_te.Text == "") { GrxCAD.ApplicationServices.Application.ShowAlertDialog("请输入裁剪距离"); return; } CutContourLine.sqxlayer = dgxCJ_sqx_co.Text; CutContourLine.jqxlayer = dgxCJ_jqx_co.Text; CutContourLine.eledvalue = double.Parse(dgxCJ_gcc_te.Text); CutContourLine.lenIgnore = double.Parse(dgxCJ_hlcd_te.Text); CutContourLine.scalelen = double.Parse(dgxCJ_cjjl_te.Text); //比例尺 string blctext = dgxCJ_blc_co.Text; int blcindex = blctext.LastIndexOf(':'); string strblc = blctext.Substring(blcindex + 1); CutContourLine.mapscale = Convert.ToInt32(strblc); this.Close(); CutContourLine chfeature = new CutContourLine(); chfeature.ccls(); } private void Cancel_Click(object sender, EventArgs e) { this.Close(); } } }