//停止按键,停止作业 private void btnStop_Click(object sender, EventArgs e) { try { if ((!chkCalibration.Checked && Parameter.GetInstance().IsControlMotor)) { } CAM_StopGrab(); if (Parameter.GetInstance().IsSaveExcel&& !chkCalibration.Checked) { try { mAccessExcel.SetExcelVisible(); //mAccessExcel.AddChipStatus(i, mChipDetection.mresultlist[i].status);//excel保存数据 } catch { MessageBox.Show("Excel关闭失败,请手动关闭。"); } } btnStart.Enabled = true; btnTest.Enabled = true; btnStop.Enabled = false; grpMotor.Enabled = true; mnuMain.Enabled = true; btnStartCalibration.Enabled = true; btnSaveCalibration.Enabled = false; btnStopCalibration.Enabled = false; lblStatusIndicator.Text = "停止运行"; lblStatusIndicator.BackColor = Color.Red; } catch (System.Exception ex) { //MessageBox.Show(ex.ToString()); } }
//button1,Excel测试按键 private void button1_Click(object sender, EventArgs e) { try { //Excel测试 mAccessExcel = AccessExcel.CreateInstance(); mDestinationExcelFile = MiscFunction.GetInstance().GetAssemblyPath() + Parameter.GetInstance().ReportDirectory + "\\" + "temp.xlsx"; File.Copy(mExcelModalFileName, mDestinationExcelFile, true); Application.DoEvents(); string ret = mAccessExcel.OpenExcelFile(mDestinationExcelFile); mAccessExcel.SetExcelVisible(); for (int i = 0; i < 1500; i++) { mAccessExcel.AddChipStatus(i, 1); } SaveResultToExcelFile(); } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } }