FormMeasureTest.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //时间:20200619
  2. //作者:郝爽
  3. //功能:测量线程的测试
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. using MeasureData;
  14. using MeasureThread;
  15. namespace HOZProject
  16. {
  17. public partial class FormMeasureTest : Form
  18. {
  19. public MeasureFile m_MeasureFile;
  20. public Measure m_Ms;
  21. public FormMeasureTest()
  22. {
  23. InitializeComponent();
  24. }
  25. //新建测量文件
  26. private void button1_Click(object sender, EventArgs e)
  27. {
  28. m_MeasureFile = new MeasureFile();
  29. if (!m_MeasureFile.New())
  30. {
  31. return;
  32. }
  33. else
  34. {
  35. this.IsPTcheckBox.Checked = m_MeasureFile.MParam.PT;
  36. MessageBox.Show("新建测量文件成功。");
  37. }
  38. }
  39. //初始化
  40. private void Init_Click(object sender, EventArgs e)
  41. {
  42. }
  43. //导入切孔
  44. private void LoadCutHole_Click(object sender, EventArgs e)
  45. {
  46. if (m_MeasureFile == null)
  47. {
  48. MessageBox.Show("请新建一个测量文件");
  49. }
  50. else
  51. {
  52. if (!m_MeasureFile.GetCutHolesFromFile(""))
  53. {
  54. MessageBox.Show("导入切孔失败");
  55. }
  56. List<CutHole> listHoles = m_MeasureFile.ListCutHole;
  57. foreach (CutHole hole in listHoles)
  58. {
  59. //在CutHoleGridView中,添加切孔信息
  60. int index = this.CutHoleGridView.Rows.Add();
  61. this.CutHoleGridView.Rows[index].Cells[0].Value = hole.HoleName;
  62. SemPosition pos = hole.Position;
  63. this.CutHoleGridView.Rows[index].Cells[1].Value = pos.X;
  64. this.CutHoleGridView.Rows[index].Cells[2].Value = pos.Y;
  65. this.CutHoleGridView.Rows[index].Cells[3].Value = pos.Z;
  66. this.CutHoleGridView.Rows[index].Cells[4].Value = pos.M;
  67. this.CutHoleGridView.Rows[index].Cells[5].Value = pos.R;
  68. this.CutHoleGridView.Rows[index].Cells[6].Value = pos.T;
  69. }
  70. }
  71. }
  72. private void IsPTcheckBox_CheckedChanged(object sender, EventArgs e)
  73. {
  74. }
  75. private void textBox1_TextChanged(object sender, EventArgs e)
  76. {
  77. }
  78. //测量参数
  79. private void button1_Click_1(object sender, EventArgs e)
  80. {
  81. if (m_MeasureFile == null)
  82. {
  83. MessageBox.Show("请新建一个测量文件");
  84. }
  85. else
  86. {
  87. m_MeasureFile.MParam.PT = this.IsPTcheckBox.Checked;
  88. m_MeasureFile.MParam.SampleName = this.SampleNametextBox.Text;
  89. m_MeasureFile.MParam.FIBTemp = this.FIBTemptextBox.Text;
  90. m_MeasureFile.MParam.FocusMode = this.ManualFocuscheckBox.Checked;
  91. MessageBox.Show("参数设置成功");
  92. }
  93. }
  94. private void ManualFocuscheckBox_CheckedChanged(object sender, EventArgs e)
  95. {
  96. }
  97. //选择一个模板文件
  98. private void button2_Click(object sender, EventArgs e)
  99. {
  100. string FilePathName;
  101. string fileNameWithoutExtension;
  102. //新建一个文件对话框
  103. OpenFileDialog pOpenFileDialog = new OpenFileDialog();
  104. //设置对话框标题
  105. pOpenFileDialog.Title = "选择模板文件";
  106. //设置打开文件类型
  107. pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
  108. //监测文件是否存在
  109. pOpenFileDialog.CheckFileExists = true;
  110. //文件打开后执行以下程序
  111. if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
  112. {
  113. FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
  114. fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
  115. this.FIBTemptextBox.Text = fileNameWithoutExtension;
  116. }
  117. }
  118. //启动测量
  119. private void button3_Click(object sender, EventArgs e)
  120. {
  121. if (m_MeasureFile == null)
  122. {
  123. MessageBox.Show("请新建一个测量文件");
  124. }
  125. else
  126. {
  127. m_Ms = new Measure();
  128. m_Ms.InitMeas(m_MeasureFile);
  129. m_Ms.DoMeasure();
  130. }
  131. }
  132. private void button5_Click(object sender, EventArgs e)
  133. {
  134. if (m_MeasureFile == null)
  135. {
  136. MessageBox.Show("请新建一个测量文件");
  137. }
  138. else
  139. {
  140. m_MeasureFile.Save();
  141. }
  142. }
  143. }
  144. }