using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using SmartSEMControl; namespace HOZProject { public partial class FormUnitControl : Form { #region 系统参数 private String path= Directory.GetCurrentDirectory(); private SmartSEM sem = new SmartSEM(); #endregion #region 远程处理服务器可能发送给您的通知代码。 // Notification codes that the Remoting server may send to you. public enum ZeissNotificationCode { PARAMETER_CHANGE = 0, PARAMETER_XY_CHANGE = 6, EMSERVER_HAS_LOADED = 1111111, EMSERVER_HAS_EXITED = 2222222, EMSERVER_USER_LOGGED_ON = 3333333, EMSERVER_USER_LOGGED_OFF = 4444444, REMOTING_SERVER_EXITED = 5555555, EMSERVER_FIBUI_HAS_LOADED = 6666666 } #endregion #region 返回错误代码 public enum ZeissErrorCode { // Failed to translate parameter into an id API_E_GET_TRANSLATE_FAIL = 1000, // Failed to get analogue value API_E_GET_AP_FAIL = 1001, // Failed to get digital value API_E_GET_DP_FAIL = 1002, // Parameter supplied is not analogue nor digital API_E_GET_BAD_PARAMETER = 1003, // Failed to translate parameter into an id API_E_SET_TRANSLATE_FAIL = 1004, // Failed to set a digital state API_E_SET_STATE_FAIL = 1005, // Failed to set a float value API_E_SET_FLOAT_FAIL = 1006, // Value supplied is too low API_E_SET_FLOAT_LIMIT_LOW = 1007, // Value supplied is too high API_E_SET_FLOAT_LIMIT_HIGH = 1008, // Value supplied is is of wrong type API_E_SET_BAD_VALUE = 1009, // Parameter supplied is not analogue nor digital API_E_SET_BAD_PARAMETER = 1010, // Failed to translate command into an id API_E_EXEC_TRANSLATE_FAIL = 1011, // Failed to execute command= API_E_EXEC_CMD_FAIL = 1012, // Failed to execute file macro API_E_EXEC_MCF_FAIL = 1013, // Failed to execute library macro API_E_EXEC_MCL_FAIL = 1014, // Command supplied is not implemented API_E_EXEC_BAD_COMMAND = 1015, // Grab command failed API_E_GRAB_FAIL = 1016, // Get Stage position failed API_E_GET_STAGE_FAIL = 1017, // Move Stage position failed API_E_MOVE_STAGE_FAIL = 1018, // API not initialised API_E_NOT_INITIALISED = 1019, // Failed to translate parameter to an id API_E_NOTIFY_TRANSLATE_FAIL = 1020, // Set notification failed API_E_NOTIFY_SET_FAIL = 1021, // Get limits failed API_E_GET_LIMITS_FAIL = 1022, // Get multiple parameters failed API_E_GET_MULTI_FAIL = 1023, // Set multiple parameters failed API_E_SET_MULTI_FAIL = 1024, // Missing API license API_E_NOT_LICENSED = 1025, // Reserved or not implemented API_E_NOT_IMPLEMENTED = 1026, // Failed to get user name (Remoting Interface only) API_E_GET_USER_NAME_FAIL = 1027, // Failed to get user idle state (Remoting Interface only) API_E_GET_USER_IDLE_FAIL = 1028, // Failed to get the last remoting connection error string (Remoting Interface Only) API_E_GET_LAST_REMOTING_CONNECT_ERROR_FAIL = 1029, // Failed to remotely logon to the EM Server (username and password may be incorrect or EM Server is not running or User is already logged on API_E_EMSERVER_LOGON_FAILED = 1030, // Failed to start the EM Server - this may be because the Server is already running or has an internal error. API_E_EMSERVER_START_FAILED = 1031, // The command or parameter is currently disabled (you cannot execute or set it). API_E_PARAMETER_IS_DISABLED = 1032, // Remoting incorrectly configured, use RConfigure to correct API_E_REMOTING_NOT_CONFIGURED = 2027, // Remoting did not connect to the server API_E_REMOTING_FAILED_TO_CONNECT = 2028, // Remoting could not start (unknown reason) API_E_REMOTING_COULD_NOT_CREATE_INTERFACE = 2029, // Remoting: Remote server is not running currently. API_E_REMOTING_EMSERVER_NOT_RUNNING = 2030, // Remoting: Remote server has no user logged in API_E_REMOTING_NO_USER_LOGGED_IN = 2031, // Internal Defines, although they may be useful in your own program. TRS. API_FIRST_REMOTING_ERROR_CODE = API_E_REMOTING_NOT_CONFIGURED, API_LAST_REMOTING_ERROR_CODE = API_E_REMOTING_NO_USER_LOGGED_IN, API_FIRST_ERROR_CODE = API_E_GET_TRANSLATE_FAIL, API_LAST_ERROR_CODE = API_E_REMOTING_NO_USER_LOGGED_IN } #endregion #region 构造函数 public FormUnitControl() { InitializeComponent(); //Calling Notification for updated status //CZEMApi.Notify += new _EMApiEvents_NotifyEventHandler(CZEMApi_Notify); //CZEMApi.NotifyWithCurrentValue += new _EMApiEvents_NotifyWithCurrentValueEventHandler(CZEMApi_NotifyWithCurrentValue); //加载参数 } #endregion #region 控件加载事件1 public void CZEMApi_Notify(string strParameter, int reason) { Notify(strParameter, reason); } #endregion #region 控件加载事件2 public void CZEMApi_NotifyWithCurrentValue(string strParameter, int reason, int paramid, double dLastKnownValue) { Notify(strParameter, reason); } #endregion #region 加载事件调用函数 public void Notify(string strParameter, int reason) { //string strGetEMSERVERMsg = ""; //switch ((ZeissNotificationCode)reason) //{ // case ZeissNotificationCode.PARAMETER_CHANGE: // Parameter Change // if (strParameter == "DP_VACSTATUS" || strParameter == "DP_RUNUPSTATE" || strParameter == "DP_COLUMN_TYPE" || strParameter == "DP_OPERATING_MODE" // || strParameter == "DP_SCANRATE" || strParameter == "DP_AUTO_FUNCTION" || strParameter == "DP_DETECTOR_TYPE" || strParameter == "DP_STAGE_INIT" // || strParameter == "DP_STAGE_IS" || strParameter == "DP_FIB_MODE" || strParameter == "DP_FIB_GUN_STATE" || strParameter == "AP_ACTUALKV" // || strParameter == "AP_ACTUALCURRENT" || strParameter == "AP_MAG" || strParameter == "AP_WD" || strParameter == "AP_IPROBE" || strParameter== "AP_CONTRAST") // { // UpdateStatus(strParameter); // } // break; // case ZeissNotificationCode.REMOTING_SERVER_EXITED: // //listServerMsg.Items.Add("Remote Server Exited"); // strGetEMSERVERMsg = "Remote Server Exited"; // DisplayError("Remote Server closed", ""); // m_bInitialised = false; // //txtEditInit.Text = "Not Initialised"; // //txtEditNotify.Text = "No Notification"; // //txtEditInit.BackColor = Color.Red; // //txtEditNotify.BackColor = Color.Red; // break; // default: // strGetEMSERVERMsg = strParameter; // break; //} //if (strGetEMSERVERMsg.Length > 0) //{ // //if (txtNotifyEdit.Text.Length > 0) // //{ // // txtNotifyEdit.Text += "\r\n" + strGetEMSERVERMsg; // // txtNotifyEdit.SelectionStart = txtNotifyEdit.Text.Length; // // txtNotifyEdit.SelectionLength = 0; // //} // //else // //{ // // txtNotifyEdit.Text = strGetEMSERVERMsg; // //} //} } #endregion #region 更新状态 public void UpdateStatus(string szParam) { //object varStr = new VariantWrapper(""); //object varfloat = new VariantWrapper((float)0.0f); //if(szParam.IndexOf("AP")==0) //{ // lrt = CZEMApi.Get(szParam, ref varfloat); // if (lrt != 0) // { // ReportError(lrt, "Update Status", szParam); // return; // } // lblgetValue.Text = Convert.ToDecimal(varfloat).ToString(); //} //else //{ // lrt = CZEMApi.Get(szParam, ref varStr); // if (lrt != 0) // { // ReportError(lrt, "Update Status", szParam); // return; // } // lblgetValue.Text = varStr.ToString(); //} //if (szParam == "DP_VACSTATUS") //{ // txtEditVacStatus.Text = "VAC status = " + varStr; //} //else if (szParam == "DP_RUNUPSTATE") //{ // txtEditRunupstate.Text = "Beam Status = " + varStr; //} //else if (szParam == "DP_COLUMN_TYPE") //{ // txtEditColumnType.Text = "Column Type = " + varStr; //} //else if (szParam == "DP_STAGE_INIT") //{ // txtEditStageInit.Text = "Stage Initialised = " + varStr; //} //else if (szParam == "DP_STAGE_IS") //{ // txtEditStageIs.Text = "Stage = " + varStr; //} //else if (szParam == "DP_OPERATING_MODE") //{ // txtEditOperatingMode.Text = "Operating Mode = " + varStr; //} //else if (szParam == "DP_SCANRATE") //{ // txtEditScanrate.Text = "Scan Rate = " + varStr; //} //else if (szParam == "DP_AUTO_FUNCTION") //{ // txtEditAutoFunction.Text = "Auto Function = " + varStr; //} //else if (szParam == "DP_DETECTOR_TYPE") //{ // txtEditDetectorType.Text = "Detector = " + varStr; //} //else if (szParam == "DP_FIB_MODE") //{ // txtEditFibMode.Text = "FIB Mode = " + varStr; //} //else if (szParam == "DP_FIB_GUN_STATE") //{ // txtEditFibGunState.Text = "FIB Gun = " + varStr; //} //else if (szParam == "AP_ACTUALKV") //{ // txtEditActualkv.Text = "EHT " + varStr; //} //else if (szParam == "AP_ACTUALCURRENT") //{ // txtEditActualcurrent.Text = "I " + varStr; //} //else if (szParam == "AP_MAG") //{ // txtEditMag.Text = "Mag " + varStr; //} //else if (szParam == "AP_WD") //{ // txtEditWd.Text = "WD " + varStr; //} //else if (szParam == "AP_IPROBE") //{ // txtEditIprobe.Text = "Probe I " + varStr; //} } #endregion #region 显示错误代码 internal void DisplayError(string strCaller, string strComment) { //if (m_bInitialised) //{ // object objError = new VariantWrapper(""); // long lResult = CZEMApi.GetLastError(ref objError); // if (lResult == 0) // { // if (objError != null) // { // ReportError(objError.ToString(), strCaller, strComment); // } // else // { // ReportError("No error occured", strCaller, strComment); // } // } // else // { // ReportError("Cannot get last error", strCaller, strComment); // } //} } #endregion #region 输出错误号1 internal void ReportError(string strError, string strCaller, string strComment) { if (strCaller.Length != 0 || strComment.Length != 0) { // listmsg.Items.Add(string.Format("{0}\r\nCaller: {1}\r\nComment: {2}", strError, strCaller, strComment)); } else { //listmsg.Items.Add(strError); } } #endregion #region 输出错误2 internal void ReportError(long lReturn, string strCaller, string strComment) { ReportError(ErrorToString(lReturn), strCaller, strComment); } #endregion #region 错误代码转换 string ErrorToString(long lError) { string strError; switch ((ZeissErrorCode)lError) { case 0: strError = "OK"; break; case ZeissErrorCode.API_E_GET_TRANSLATE_FAIL: strError = "Failed to translate parameter into an ID"; break; case ZeissErrorCode.API_E_GET_AP_FAIL: strError = "Failed to get analogue value"; break; case ZeissErrorCode.API_E_GET_DP_FAIL: strError = "Failed to get digital value"; break; case ZeissErrorCode.API_E_GET_BAD_PARAMETER: strError = "Parameter supplied is neither analogue nor digital"; break; case ZeissErrorCode.API_E_SET_TRANSLATE_FAIL: strError = "Failed to translate parameter into an ID"; break; case ZeissErrorCode.API_E_SET_STATE_FAIL: strError = "Failed to set a digital state"; break; case ZeissErrorCode.API_E_SET_FLOAT_FAIL: strError = "Failed to set a float value"; break; case ZeissErrorCode.API_E_SET_FLOAT_LIMIT_LOW: strError = "Value supplied is too low"; break; case ZeissErrorCode.API_E_SET_FLOAT_LIMIT_HIGH: strError = "Value supplied is too high"; break; case ZeissErrorCode.API_E_SET_BAD_VALUE: strError = "Value supplied is of wrong type"; break; case ZeissErrorCode.API_E_SET_BAD_PARAMETER: strError = "Parameter supplied is not analogue nor digital"; break; case ZeissErrorCode.API_E_EXEC_TRANSLATE_FAIL: strError = "Failed to translate command into an ID"; break; case ZeissErrorCode.API_E_EXEC_CMD_FAIL: strError = "Failed to execute command"; break; case ZeissErrorCode.API_E_EXEC_MCF_FAIL: strError = "Failed to execute file macro"; break; case ZeissErrorCode.API_E_EXEC_MCL_FAIL: strError = "Failed to execute library macro"; break; case ZeissErrorCode.API_E_EXEC_BAD_COMMAND: strError = "Command supplied is not implemented"; break; case ZeissErrorCode.API_E_GRAB_FAIL: strError = "Grab command failed"; break; case ZeissErrorCode.API_E_GET_STAGE_FAIL: strError = "Get Stage position failed"; break; case ZeissErrorCode.API_E_MOVE_STAGE_FAIL: strError = "Move Stage position failed"; break; case ZeissErrorCode.API_E_NOT_INITIALISED: strError = "API not initialised"; break; case ZeissErrorCode.API_E_NOTIFY_TRANSLATE_FAIL: // 1020L strError = "Failed to translate parameter to an ID"; break; case ZeissErrorCode.API_E_NOTIFY_SET_FAIL: strError = "Set notification failed"; break; case ZeissErrorCode.API_E_GET_LIMITS_FAIL: strError = "Get limits failed"; break; case ZeissErrorCode.API_E_GET_MULTI_FAIL: strError = "Get multiple parameters failed"; break; case ZeissErrorCode.API_E_SET_MULTI_FAIL: strError = "Set multiple parameters failed"; break; case ZeissErrorCode.API_E_NOT_LICENSED: strError = "Missing API license"; break; case ZeissErrorCode.API_E_NOT_IMPLEMENTED: strError = "Reserved or not implemented"; break; case ZeissErrorCode.API_E_GET_USER_NAME_FAIL: strError = "Failed to get user name"; break; case ZeissErrorCode.API_E_GET_USER_IDLE_FAIL: strError = "Failed to get user idle state"; break; case ZeissErrorCode.API_E_GET_LAST_REMOTING_CONNECT_ERROR_FAIL: strError = "Failed to get the last remoting connection error string"; break; case ZeissErrorCode.API_E_EMSERVER_LOGON_FAILED: strError = "Failed to remotely logon to the EM Server. Username and password may be incorrect or EM Server is not running or User is already logged on"; break; case ZeissErrorCode.API_E_EMSERVER_START_FAILED: strError = "Failed to start the EM Server. This may be because the Server is already running or has an internal error."; break; case ZeissErrorCode.API_E_REMOTING_NOT_CONFIGURED: strError = "Remoting incorrectly configured, use RConfigure to correct"; break; case ZeissErrorCode.API_E_REMOTING_FAILED_TO_CONNECT: strError = "Remoting did not connect to the server"; break; case ZeissErrorCode.API_E_REMOTING_COULD_NOT_CREATE_INTERFACE: strError = "Remoting could not start (unknown reason)"; break; case ZeissErrorCode.API_E_REMOTING_EMSERVER_NOT_RUNNING: strError = "EMServer is not running on the remote machine"; break; case ZeissErrorCode.API_E_REMOTING_NO_USER_LOGGED_IN: strError = "No user is logged into EM Server on the remote machine"; break; default: strError = string.Format("Unknown error code {0}", lError); break; } return strError; } #endregion #region 设备初始化按键 private void btnInit_Click(object sender, EventArgs e) { if(sem.Init()) { btnInit.BackColor = Color.Lime; } else { btnInit.BackColor = Color.Red; } } #endregion #region 设备关闭按键 private void btnCloseCtrl_Click(object sender, EventArgs e) { if (sem.UnInit()) { btnInit.BackColor = Control.DefaultBackColor; } } #endregion #region 设置参数更新通知 private void btnSetNotify_Click(object sender, EventArgs e) { //if (m_bInitialised) //{ // // Magnification // if (CZEMApi.SetNotify("AP_MAG", 1) != 0) // { // DisplayError("SetNotify", "AP_MAG"); // return; // } // // Working distance // if (CZEMApi.SetNotify("AP_WD", 1) != 0) // { // DisplayError("SetNotify", "AP_WD"); // return; // } // // BRIGHTNESS 亮度 // if (CZEMApi.SetNotify("AP_BRIGHTNESS", 1) != 0) // { // DisplayError("SetNotify", "AP_BRIGHTNESS"); // return; // } // // AP_CONTRAST,对比度 // if (CZEMApi.SetNotify("AP_CONTRAST", 1) != 0) // { // DisplayError("SetNotify", "AP_CONTRAST"); // return; // } // // Vacuum // if (CZEMApi.SetNotify("DP_VACSTATUS", 1) != 0) // { // DisplayError("SetNotify", "DP_VACSTATUS"); // return; // } // // Gun / EHT state // if (CZEMApi.SetNotify("DP_RUNUPSTATE", 1) != 0) // { // DisplayError("SetNotify", "DP_RUNUPSTATE"); // return; // } // // actual KV / EHT // if (CZEMApi.SetNotify("AP_ACTUALKV", 1) != 0) // { // DisplayError("SetNotify", "AP_ACTUALKV"); // return; // } // // actual current // if (CZEMApi.SetNotify("AP_ACTUALCURRENT", 1) != 0) // { // DisplayError("SetNotify", "AP_ACTUALCURRENT"); // return; // } // // column type // if (CZEMApi.SetNotify("DP_COLUMN_TYPE", 1) != 0) // { // DisplayError("SetNotify", "DP_COLUMN_TYPE"); // return; // } // // mode // if (CZEMApi.SetNotify("DP_OPERATING_MODE", 1) != 0) // { // DisplayError("SetNotify", "DP_OPERATING_MODE"); // return; // } // // scan rate // if (CZEMApi.SetNotify("DP_SCANRATE", 1) != 0) // { // DisplayError("SetNotify", "DP_SCANRATE"); // return; // } // // auto function active // if (CZEMApi.SetNotify("DP_AUTO_FUNCTION", 1) != 0) // { // DisplayError("SetNotify", "DP_AUTO_FUNCTION"); // return; // } // // probe current // if (CZEMApi.SetNotify("AP_IPROBE", 1) != 0) // { // DisplayError("SetNotify", "AP_IPROBE"); // return; // } // // detector // if (CZEMApi.SetNotify("DP_DETECTOR_TYPE", 1) != 0) // { // DisplayError("SetNotify", "DP_DETECTOR_TYPE"); // return; // } // // stage initialised // if (CZEMApi.SetNotify("DP_STAGE_INIT", 1) != 0) // { // DisplayError("SetNotify", "DP_STAGE_INIT"); // return; // } // // stage busy? // if (CZEMApi.SetNotify("DP_STAGE_IS", 1) != 0) // { // DisplayError("SetNotify", "DP_STAGE_IS"); // return; // } // // fib mode // if (CZEMApi.SetNotify("DP_FIB_MODE", 1) != 0) // { // DisplayError("SetNotify", "DP_FIB_MODE"); // return; // } // // fib gun state // if (CZEMApi.SetNotify("DP_FIB_GUN_STATE", 1) != 0) // { // DisplayError("SetNotify", "DP_FIB_GUN_STATE"); // return; // } //listmsg.Items.Add("Notification enabled"); // } } #endregion #region 缩放Get private void btnenlargeGet_Click(object sender, EventArgs e) { float ret = sem.GetMagnification(); if(float.IsNaN(ret)) { lblenlargeGet.Text = "NaN"; txtenlargeSet.Enabled = false; btnenlargeSet.Enabled = false; } else { lblenlargeGet.Text = ret.ToString(); txtenlargeSet.Text = ret.ToString(); btnenlargeSet.Enabled = true; } } #endregion #region 缩放Set private void btnenlargeSet_Click(object sender, EventArgs e) { float set = 0; if(float.TryParse(txtenlargeSet.Text, out set)) { sem.SetMagnification(set); } } #endregion #region 焦距Get private void btnWDGet_Click(object sender, EventArgs e) { float ret = sem.GetWorkingDistance(); if (float.IsNaN(ret)) { lblWDGet.Text = "NaN"; txtWDSet.Enabled = false; btnWDSet.Enabled = false; } else { lblWDGet.Text = ret.ToString(); txtWDSet.Text = ret.ToString(); btnWDSet.Enabled = true; } } #endregion #region 焦距Set private void btnWDSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtWDSet.Text, out set)) { sem.SetWorkingDistance(set); } } #endregion #region 亮度Get private void btnBrightnessGet_Click(object sender, EventArgs e) { float ret = sem.GetBrightness(); if (float.IsNaN(ret)) { lblBrightnessGet.Text = "NaN"; txtBrightnessSet.Enabled = false; btnBrightnessSet.Enabled = false; } else { lblBrightnessGet.Text = ret.ToString(); txtBrightnessSet.Text = ret.ToString(); btnBrightnessSet.Enabled = true; } } #endregion #region 亮度Set private void btnBrightnessSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtBrightnessSet.Text, out set)) { sem.SetBrightness(set); } } #endregion #region 对比度Get private void btnContrastGet_Click(object sender, EventArgs e) { float ret = sem.GetContrast(); if (float.IsNaN(ret)) { lblContrastGet.Text = "NaN"; txtContrastSet.Enabled = false; btnContrastSet.Enabled = false; } else { lblContrastGet.Text = ret.ToString(); txtContrastSet.Text = ret.ToString(); btnContrastSet.Enabled = true; } } #endregion #region 对比度Set private void btnContrastSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtContrastSet.Text, out set)) { sem.SetContrast(set); } } #endregion #region 消像散X Get private void btnAstigmatismXGet_Click(object sender, EventArgs e) { float ret = sem.GetAstigmatismX(); if (float.IsNaN(ret)) { lblAstigmatismXGet.Text = "NaN"; txtAstigmatismXSet.Enabled = false; btnAstigmatismXSet.Enabled = false; } else { lblAstigmatismXGet.Text = ret.ToString(); txtAstigmatismXSet.Text = ret.ToString(); btnAstigmatismXSet.Enabled = true; } } #endregion #region 消像散X Set private void btnAstigmatismXSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtAstigmatismXSet.Text, out set)) { sem.SetAstigmatismX(set); } } #endregion #region 消像散Y Get private void btnAstigmatismYGet_Click(object sender, EventArgs e) { float ret = sem.GetAstigmatismY(); if (float.IsNaN(ret)) { lblAstigmatismYGet.Text = "NaN"; txtAstigmatismYSet.Enabled = false; btnAstigmatismYSet.Enabled = false; } else { lblAstigmatismYGet.Text = ret.ToString(); txtAstigmatismYSet.Text = ret.ToString(); btnAstigmatismYSet.Enabled = true; } } #endregion #region 消像散Y Set private void btnAstigmatismYSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtAstigmatismYSet.Text, out set)) { sem.SetAstigmatismY(set); } } #endregion #region 角度补偿Get private void btnTiltAngleGet_Click(object sender, EventArgs e) { float ret = sem.GetTiltAngle(); if (float.IsNaN(ret)) { lblTiltAngleGet.Text = "NaN"; txtTiltAngleSet.Enabled = false; btnTiltAngleSet.Enabled = false; } else { lblTiltAngleGet.Text = ret.ToString(); txtTiltAngleSet.Text = ret.ToString(); btnTiltAngleSet.Enabled = true; } } #endregion #region 角度补偿Set private void btnTiltAngleSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtTiltAngleSet.Text, out set)) { sem.SetTiltAngle(set); } } #endregion #region 抓取图像 private void btnGrabImage_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "图像保存位置:"; sfd.FileName = "test.tif"; sfd.Filter = "TIF文件|*.tif"; if (sfd.ShowDialog() == DialogResult.OK) { string fn = sfd.FileName; sem.GrabImage(fn, 0); } } #endregion #region ScanRotate Get private void btnScanRotationGet_Click(object sender, EventArgs e) { float ret = sem.GetScanRotation(); if (float.IsNaN(ret)) { lblScanRotationGet.Text = "NaN"; txtScanRotationSet.Enabled = false; btnScanRotationSet.Enabled = false; } else { lblScanRotationGet.Text = ret.ToString(); txtScanRotationSet.Text = ret.ToString(); btnScanRotationSet.Enabled = true; } } #endregion #region ScanRotate Set private void btnScanRotationSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtScanRotationSet.Text, out set)) { sem.SetScanRotation(set); } } #endregion #region PixelSize Get private void btnPixelSizeGet_Click(object sender, EventArgs e) { float ret = sem.GetScanRotation(); if (float.IsNaN(ret)) { lblScanRotationGet.Text = "NaN"; txtScanRotationSet.Enabled = false; btnScanRotationSet.Enabled = false; } else { lblScanRotationGet.Text = ret.ToString(); txtScanRotationSet.Text = ret.ToString(); btnScanRotationSet.Enabled = true; } } #endregion #region PixelSize Set private void btnPixelSizeSet_Click(object sender, EventArgs e) { float set = 0; if (float.TryParse(txtScanRotationSet.Text, out set)) { sem.SetScanRotation(set); } } #endregion #region 开启电压 private void btnOpenVoltage_Click(object sender, EventArgs e) { sem.CmdOpenVoltage(); } #endregion #region 关闭电压 private void btnCloseVoltage_Click(object sender, EventArgs e) { sem.CmdCloseVoltage(); } #endregion } }