UControl_Init.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MeasureData;
  11. namespace HOZProject
  12. {
  13. public partial class UControl_Init : UserControl
  14. {
  15. private FormHOZMain formHOZMain;
  16. public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
  17. public UControl_Init(FormHOZMain formHOZ)
  18. {
  19. InitializeComponent();
  20. FormHOZMainObject = formHOZ;
  21. }
  22. private void btnClose_Click(object sender, EventArgs e)
  23. {
  24. Form fParent = this.ParentForm;
  25. fParent.Close();
  26. }
  27. private void pbCutHoleFile_Click(object sender, EventArgs e)
  28. {
  29. if (FormHOZMainObject.m_MeasureFile == null)
  30. {
  31. MessageBox.Show("请新建一个测量文件");
  32. }
  33. else
  34. {
  35. if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
  36. {
  37. MessageBox.Show("导入切孔失败");
  38. }
  39. else
  40. {
  41. List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
  42. FormHOZMainObject.CreateCutHoleList(ListCutHole);
  43. //显示导入的切孔数量
  44. lblCutHoleCount.Text = string.Format("成功导入{0}个切孔",ListCutHole.Count);
  45. }
  46. //this.CutHoleGridView.Rows.Clear();
  47. //List<CutHole> listHoles = m_MeasureFile.ListCutHole;
  48. //foreach (CutHole hole in listHoles)
  49. //{
  50. // //在CutHoleGridView中,添加切孔信息
  51. // int index = this.CutHoleGridView.Rows.Add();
  52. // this.CutHoleGridView.Rows[index].Cells[0].Value = hole.HoleName;
  53. // SemPosition pos = hole.Position;
  54. // this.CutHoleGridView.Rows[index].Cells[1].Value = pos.X;
  55. // this.CutHoleGridView.Rows[index].Cells[2].Value = pos.Y;
  56. // this.CutHoleGridView.Rows[index].Cells[3].Value = pos.Z;
  57. // this.CutHoleGridView.Rows[index].Cells[4].Value = pos.M;
  58. // this.CutHoleGridView.Rows[index].Cells[5].Value = pos.R;
  59. // this.CutHoleGridView.Rows[index].Cells[6].Value = pos.T;
  60. //}
  61. }
  62. }
  63. private void button1_Click(object sender, EventArgs e)
  64. {
  65. if (FormHOZMainObject.m_MeasureFile == null)
  66. {
  67. MessageBox.Show("请新建一个测量文件");
  68. //this.listmsg.Items.Add("请新建一个测量文件");
  69. }
  70. else
  71. {
  72. FormHOZMainObject.m_MeasureFile.MParam.PT = this.cBIsPT.Checked;
  73. FormHOZMainObject.m_MeasureFile.MParam.SampleName = this.tBSampleName.Text;
  74. FormHOZMainObject.m_MeasureFile.MParam.FIBTemp = this.tBFIBTemp.Text;
  75. FormHOZMainObject.m_MeasureFile.MParam.FocusMode = this.cBIsManul.Checked;
  76. MessageBox.Show("参数设置成功");
  77. }
  78. }
  79. private void pbTemplateFile_Click(object sender, EventArgs e)
  80. {
  81. string FilePathName;
  82. string fileNameWithoutExtension;
  83. //新建一个文件对话框
  84. OpenFileDialog pOpenFileDialog = new OpenFileDialog();
  85. //设置对话框标题
  86. pOpenFileDialog.Title = "选择模板文件";
  87. //设置打开文件类型
  88. pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
  89. //监测文件是否存在
  90. pOpenFileDialog.CheckFileExists = true;
  91. //文件打开后执行以下程序
  92. if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
  93. {
  94. FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
  95. fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
  96. this.tBFIBTemp.Text = fileNameWithoutExtension;
  97. }
  98. }
  99. }
  100. }