工具箱相关
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

PtLinecontradiction.cs 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using Autodesk.AutoCAD.DatabaseServices;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace CADTools
  12. {
  13. public partial class PtLinecontradiction : Form
  14. {
  15. public PtLinecontradiction()
  16. {
  17. InitializeComponent();
  18. }
  19. private void PtLinecontradiction_Load(object sender, EventArgs e)
  20. {
  21. //自动填充下拉框
  22. Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
  23. using (Transaction traction = database.TransactionManager.StartTransaction())
  24. {
  25. //存放所有图层名
  26. List<string> alllayername = new List<string>();
  27. LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
  28. foreach (ObjectId objid in layertable)
  29. {
  30. LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
  31. alllayername.Add(layertablerecord.Name);
  32. }
  33. alllayername.Sort();
  34. for (int i = 0; i < alllayername.Count; i++)
  35. {
  36. this.comboBox_ElePoint.Items.Add(alllayername[i]);
  37. this.comboBox_sqx.Items.Add(alllayername[i]);
  38. this.comboBox_jqx.Items.Add(alllayername[i]);
  39. }
  40. if (alllayername.Contains("8300"))
  41. {
  42. int index = alllayername.IndexOf("8300");
  43. this.comboBox_ElePoint.SelectedIndex = index;
  44. }
  45. if (alllayername.Contains("8110"))
  46. {
  47. int index = alllayername.IndexOf("8110");
  48. this.comboBox_sqx.SelectedIndex = index;
  49. }
  50. if (alllayername.Contains("8120"))
  51. {
  52. int index = alllayername.IndexOf("8120");
  53. this.comboBox_jqx.SelectedIndex = index;
  54. }
  55. traction.Commit();
  56. }
  57. }
  58. private void btn_OK_Click(object sender, EventArgs e)
  59. {
  60. if (comboBox_ElePoint.Text == "")
  61. {
  62. Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择高程点图层");
  63. return;
  64. }
  65. if (comboBox_blc.Text == "")
  66. {
  67. Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择比例尺");
  68. return;
  69. }
  70. if (comboBox_sqx.Text == "")
  71. {
  72. Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择首曲线图层");
  73. return;
  74. }
  75. if (comboBox_jqx.Text == "")
  76. {
  77. Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择计曲线图层");
  78. return;
  79. }
  80. if (string.IsNullOrWhiteSpace(textBox_dgj.Text))
  81. {
  82. Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请输入等高距");
  83. return;
  84. }
  85. double.TryParse(textBox_dgj.Text, out double number);
  86. if (number <= 0)
  87. {
  88. Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("等高距不能为0或负数");
  89. return;
  90. }
  91. ChPLContradiction1.elevationLayer = comboBox_ElePoint.Text;
  92. ChPLContradiction1.sqx = comboBox_sqx.Text;
  93. ChPLContradiction1.jqx = comboBox_jqx.Text;
  94. ChPLContradiction1.dgj = Convert.ToDouble(textBox_dgj.Text.Trim());
  95. //比例尺
  96. string blctext = comboBox_blc.Text;
  97. int blcindex = blctext.LastIndexOf(':');
  98. string strblc = blctext.Substring(blcindex + 1);
  99. int intblc = Convert.ToInt32(strblc);
  100. ChPLContradiction1.blc = intblc;
  101. ChPLContradiction1 chplc = new ChPLContradiction1();
  102. chplc.Check();
  103. this.Close();
  104. MessageBox.Show("点线矛盾检查完成。\n共有"+ ChPLContradiction1.num + "个异常点。");
  105. }
  106. private void btn_Cancel_Click(object sender, EventArgs e)
  107. {
  108. this.Close();
  109. }
  110. }
  111. }