FormUnitControl.cs 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448
  1. //时间:
  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.Runtime.InteropServices;
  11. using System.Text;
  12. using System.Threading;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using System.IO;
  16. using SmartSEMControl;
  17. using FileManager;
  18. using System.Xml;
  19. using MeasureData;
  20. using WebManager;
  21. namespace HOZProject
  22. {
  23. public partial class FormUnitControl : Form
  24. {
  25. #region 系统参数
  26. //全局只有一个fatorySEM
  27. static FactoryHardware factorySEM = FactoryHardware.Instance;
  28. ISEMControl iSEM = factorySEM.ISEM;
  29. public XmlManager xmg = new XmlManager();
  30. private String path = Directory.GetCurrentDirectory();
  31. private int st_flag = 0;
  32. WebResult wr = new WebResult("127.0.0.1", "18080", "Huawei/WebServerTest");
  33. #endregion
  34. #region 构造函数
  35. public FormUnitControl()
  36. {
  37. InitializeComponent();
  38. Control.CheckForIllegalCrossThreadCalls = false;
  39. if (iSEM.ConnectStatus())
  40. {
  41. float ret = iSEM.GetFIBIMAGING();
  42. if (ret == 0)
  43. {
  44. btnSEM.BackColor = Color.Lime;
  45. }
  46. else if (ret == 1)
  47. {
  48. btnFIB.BackColor = Color.Lime;
  49. panelFIB.Visible = true;
  50. }
  51. else if (ret == 2)
  52. {
  53. btnMILL.BackColor = Color.Lime;
  54. }
  55. }
  56. //Calling Notification for updated status
  57. //CZEMApi.Notify += new _EMApiEvents_NotifyEventHandler(CZEMApi_Notify);
  58. //CZEMApi.NotifyWithCurrentValue += new _EMApiEvents_NotifyWithCurrentValueEventHandler(CZEMApi_NotifyWithCurrentValue);
  59. //加载参数
  60. }
  61. #endregion
  62. #region 缩放Get
  63. private void btnenlargeGet_Click(object sender, EventArgs e)
  64. {
  65. float ret = iSEM.GetMagnification();
  66. if (float.IsNaN(ret))
  67. {
  68. txtenlargeSet.Text = "NaN";
  69. txtenlargeSet.Enabled = false;
  70. btnenlargeSet.Enabled = false;
  71. }
  72. else
  73. {
  74. txtenlargeSet.Text = ret.ToString();
  75. btnenlargeSet.Enabled = true;
  76. }
  77. }
  78. #endregion
  79. #region 缩放Set
  80. private void btnenlargeSet_Click(object sender, EventArgs e)
  81. {
  82. float set = 0;
  83. if (float.TryParse(txtenlargeSet.Text, out set))
  84. {
  85. iSEM.SetMagnification(set);
  86. }
  87. }
  88. #endregion
  89. #region 焦距Get
  90. private void btnWDGet_Click(object sender, EventArgs e)
  91. {
  92. float ret = iSEM.GetWorkingDistance();
  93. if (float.IsNaN(ret))
  94. {
  95. txtWDSet.Text = "NaN";
  96. txtWDSet.Enabled = false;
  97. btnWDSet.Enabled = false;
  98. }
  99. else
  100. {
  101. txtWDSet.Text = ret.ToString();
  102. btnWDSet.Enabled = true;
  103. }
  104. }
  105. #endregion
  106. #region 焦距Set
  107. private void btnWDSet_Click(object sender, EventArgs e)
  108. {
  109. float set = 0;
  110. if (float.TryParse(txtWDSet.Text, out set))
  111. {
  112. iSEM.SetWorkingDistance(set);
  113. }
  114. }
  115. #endregion
  116. #region 亮度Get
  117. private void btnBrightnessGet_Click(object sender, EventArgs e)
  118. {
  119. float ret = iSEM.GetBrightness();
  120. if (float.IsNaN(ret))
  121. {
  122. txtBrightnessSet.Text = "NaN";
  123. txtBrightnessSet.Enabled = false;
  124. btnBrightnessSet.Enabled = false;
  125. }
  126. else
  127. {
  128. txtBrightnessSet.Text = ret.ToString();
  129. btnBrightnessSet.Enabled = true;
  130. }
  131. }
  132. #endregion
  133. #region 亮度Set
  134. private void btnBrightnessSet_Click(object sender, EventArgs e)
  135. {
  136. float set = 0;
  137. if (float.TryParse(txtBrightnessSet.Text, out set))
  138. {
  139. iSEM.SetBrightness(set);
  140. }
  141. }
  142. #endregion
  143. #region 对比度Get
  144. private void btnContrastGet_Click(object sender, EventArgs e)
  145. {
  146. float ret = iSEM.GetContrast();
  147. if (float.IsNaN(ret))
  148. {
  149. txtContrastSet.Text = "NaN";
  150. txtContrastSet.Enabled = false;
  151. btnContrastSet.Enabled = false;
  152. }
  153. else
  154. {
  155. txtContrastSet.Text = ret.ToString();
  156. btnContrastSet.Enabled = true;
  157. }
  158. }
  159. #endregion
  160. #region 对比度Set
  161. private void btnContrastSet_Click(object sender, EventArgs e)
  162. {
  163. float set = 0;
  164. if (float.TryParse(txtContrastSet.Text, out set))
  165. {
  166. iSEM.SetContrast(set);
  167. }
  168. }
  169. #endregion
  170. #region 消像散X Get
  171. private void btnAstigmatismXGet_Click(object sender, EventArgs e)
  172. {
  173. float ret = iSEM.GetAstigmatismX();
  174. if (float.IsNaN(ret))
  175. {
  176. txtAstigmatismXSet.Text = "NaN";
  177. txtAstigmatismXSet.Enabled = false;
  178. btnAstigmatismXSet.Enabled = false;
  179. }
  180. else
  181. {
  182. txtAstigmatismXSet.Text = ret.ToString();
  183. btnAstigmatismXSet.Enabled = true;
  184. }
  185. }
  186. #endregion
  187. #region 消像散X Set
  188. private void btnAstigmatismXSet_Click(object sender, EventArgs e)
  189. {
  190. float set = 0;
  191. if (float.TryParse(txtAstigmatismXSet.Text, out set))
  192. {
  193. iSEM.SetAstigmatismX(set);
  194. }
  195. }
  196. #endregion
  197. #region 消像散Y Get
  198. private void btnAstigmatismYGet_Click(object sender, EventArgs e)
  199. {
  200. float ret = iSEM.GetAstigmatismY();
  201. if (float.IsNaN(ret))
  202. {
  203. txtAstigmatismYSet.Text = "NaN";
  204. txtAstigmatismYSet.Enabled = false;
  205. btnAstigmatismYSet.Enabled = false;
  206. }
  207. else
  208. {
  209. txtAstigmatismYSet.Text = ret.ToString();
  210. btnAstigmatismYSet.Enabled = true;
  211. }
  212. }
  213. #endregion
  214. #region 消像散Y Set
  215. private void btnAstigmatismYSet_Click(object sender, EventArgs e)
  216. {
  217. float set = 0;
  218. if (float.TryParse(txtAstigmatismYSet.Text, out set))
  219. {
  220. iSEM.SetAstigmatismY(set);
  221. }
  222. }
  223. #endregion
  224. #region 角度补偿Get
  225. private void btnTiltAngleGet_Click(object sender, EventArgs e)
  226. {
  227. float ret = iSEM.GetTiltAngle();
  228. if (float.IsNaN(ret))
  229. {
  230. txtTiltAngleSet.Text = "NaN";
  231. txtTiltAngleSet.Enabled = false;
  232. btnTiltAngleSet.Enabled = false;
  233. }
  234. else
  235. {
  236. txtTiltAngleSet.Text = ret.ToString();
  237. btnTiltAngleSet.Enabled = true;
  238. }
  239. }
  240. #endregion
  241. #region 角度补偿Set
  242. private void btnTiltAngleSet_Click(object sender, EventArgs e)
  243. {
  244. float set = 0;
  245. if (float.TryParse(txtTiltAngleSet.Text, out set))
  246. {
  247. iSEM.SetTiltAngle(set);
  248. }
  249. }
  250. #endregion
  251. #region 抓取图像
  252. private void btnGrabImage_Click(object sender, EventArgs e)
  253. {
  254. SaveFileDialog sfd = new SaveFileDialog();
  255. sfd.Title = "图像保存位置:";
  256. sfd.FileName = "test.tif";
  257. sfd.Filter = "TIF文件|*.tif";
  258. if (sfd.ShowDialog() == DialogResult.OK)
  259. {
  260. string fn = sfd.FileName;
  261. iSEM.GrabImage(fn, 0, 0, 1024, 768, 0);
  262. }
  263. }
  264. #endregion
  265. #region ScanRotate Get
  266. private void btnScanRotationGet_Click(object sender, EventArgs e)
  267. {
  268. float ret = iSEM.GetScanRotation();
  269. if (float.IsNaN(ret))
  270. {
  271. txtScanRotationSet.Text = "NaN";
  272. txtScanRotationSet.Enabled = false;
  273. btnScanRotationSet.Enabled = false;
  274. }
  275. else
  276. {
  277. txtScanRotationSet.Text = ret.ToString();
  278. btnScanRotationSet.Enabled = true;
  279. }
  280. }
  281. #endregion
  282. #region ScanRotate Set
  283. private void btnScanRotationSet_Click(object sender, EventArgs e)
  284. {
  285. float set = 0;
  286. if (float.TryParse(txtScanRotationSet.Text, out set))
  287. {
  288. iSEM.SetScanRotation(set);
  289. }
  290. }
  291. #endregion
  292. #region PixelSize Get
  293. private void btnPixelSizeGet_Click(object sender, EventArgs e)
  294. {
  295. float ret = iSEM.GetPixelSize();
  296. if (float.IsNaN(ret))
  297. {
  298. lblPixelSizeGet.Text = "NaN";
  299. }
  300. else
  301. {
  302. lblPixelSizeGet.Text = ret.ToString();
  303. }
  304. }
  305. #endregion
  306. #region 电子束
  307. private void btnTiltCorrXGet_Click(object sender, EventArgs e)
  308. {
  309. float ret = iSEM.GetBeamShiftX();
  310. if (float.IsNaN(ret))
  311. {
  312. txtTiltCorrX.Text = "NaN";
  313. txtTiltCorrX.Enabled = false;
  314. btnTiltCorrXSet.Enabled = false;
  315. }
  316. else
  317. {
  318. txtTiltCorrX.Text = ret.ToString();
  319. btnTiltCorrXSet.Enabled = true;
  320. }
  321. }
  322. private void btnTiltCorrXSet_Click(object sender, EventArgs e)
  323. {
  324. float set = 0;
  325. if (float.TryParse(txtTiltCorrX.Text, out set))
  326. {
  327. iSEM.SetBeamShiftX(set);
  328. }
  329. }
  330. private void btnTiltCorrYGet_Click(object sender, EventArgs e)
  331. {
  332. float ret = iSEM.GetBeamShiftY();
  333. if (float.IsNaN(ret))
  334. {
  335. txtTiltCorrY.Text = "NaN";
  336. txtTiltCorrY.Enabled = false;
  337. btnTiltCorrYSet.Enabled = false;
  338. }
  339. else
  340. {
  341. txtTiltCorrY.Text = ret.ToString();
  342. btnTiltCorrYSet.Enabled = true;
  343. }
  344. }
  345. private void btnTiltCorrYSet_Click(object sender, EventArgs e)
  346. {
  347. float set = 0;
  348. if (float.TryParse(txtTiltCorrY.Text, out set))
  349. {
  350. iSEM.SetBeamShiftY(set);
  351. }
  352. }
  353. #endregion
  354. #region 开启电压
  355. private void btnOpenVoltage_Click(object sender, EventArgs e)
  356. {
  357. iSEM.CmdOpenVoltage();
  358. }
  359. #endregion
  360. #region 关闭电压
  361. private void btnCloseVoltage_Click(object sender, EventArgs e)
  362. {
  363. iSEM.CmdCloseVoltage();
  364. }
  365. #endregion
  366. #region 电子束校正
  367. private void btnTiltCorr_Click(object sender, EventArgs e)
  368. {
  369. float ret = iSEM.GetTiltCorrection();
  370. if (float.IsNaN(ret))
  371. {
  372. btnTiltCorr.BackColor = Color.Red;
  373. }
  374. else
  375. {
  376. if (ret == 0)
  377. {
  378. btnTiltCorr.BackColor = Color.Blue;
  379. iSEM.SetTiltCorrectionOn();
  380. btnTiltCorr.Text = "电子束状态:On";
  381. }
  382. else
  383. {
  384. btnTiltCorr.BackColor = Color.Lime;
  385. iSEM.SetTiltCorrectionOff();
  386. btnTiltCorr.Text = "电子束状态:Off";
  387. }
  388. }
  389. }
  390. #endregion
  391. #region 样品台位置获取
  392. private void btnStageGetX_Click(object sender, EventArgs e)
  393. {
  394. float ret = iSEM.GetStageAtX();
  395. if (float.IsNaN(ret))
  396. {
  397. lblStageX.Text = "NaN";
  398. }
  399. else
  400. {
  401. lblStageX.Text = ret.ToString();
  402. }
  403. }
  404. private void btnStageGetY_Click(object sender, EventArgs e)
  405. {
  406. float ret = iSEM.GetStageAtY();
  407. if (float.IsNaN(ret))
  408. {
  409. lblStageY.Text = "NaN";
  410. }
  411. else
  412. {
  413. lblStageY.Text = ret.ToString();
  414. }
  415. }
  416. private void btnStageGetZ_Click(object sender, EventArgs e)
  417. {
  418. float ret = iSEM.GetStageAtZ();
  419. if (float.IsNaN(ret))
  420. {
  421. lblStageZ.Text = "NaN";
  422. }
  423. else
  424. {
  425. lblStageZ.Text = ret.ToString();
  426. }
  427. }
  428. private void btnStageGetT_Click(object sender, EventArgs e)
  429. {
  430. float ret = iSEM.GetStageAtT();
  431. if (float.IsNaN(ret))
  432. {
  433. lblStageT.Text = "NaN";
  434. }
  435. else
  436. {
  437. lblStageT.Text = ret.ToString();
  438. }
  439. }
  440. private void btnStageGetR_Click(object sender, EventArgs e)
  441. {
  442. float ret = iSEM.GetStageAtR();
  443. if (float.IsNaN(ret))
  444. {
  445. lblStageR.Text = "NaN";
  446. }
  447. else
  448. {
  449. lblStageR.Text = ret.ToString();
  450. }
  451. }
  452. private void btnStageGetM_Click(object sender, EventArgs e)
  453. {
  454. float ret = iSEM.GetStageAtM();
  455. if (float.IsNaN(ret))
  456. {
  457. lblStageM.Text = "NaN";
  458. }
  459. else
  460. {
  461. lblStageM.Text = ret.ToString();
  462. }
  463. }
  464. #endregion
  465. #region 样品台位置设置
  466. private void btnStageSetX_Click(object sender, EventArgs e)
  467. {
  468. float set = 0;
  469. if (float.TryParse(txtStageX.Text, out set))
  470. {
  471. iSEM.SetStageGotoX(set);
  472. }
  473. }
  474. private void btnStageSetY_Click(object sender, EventArgs e)
  475. {
  476. float set = 0;
  477. if (float.TryParse(txtStageY.Text, out set))
  478. {
  479. iSEM.SetStageGotoY(set);
  480. }
  481. }
  482. private void btnStageSetZ_Click(object sender, EventArgs e)
  483. {
  484. float set = 0;
  485. if (float.TryParse(txtStageZ.Text, out set))
  486. {
  487. iSEM.SetStageGotoZ(set);
  488. }
  489. }
  490. private void btnStageSetT_Click(object sender, EventArgs e)
  491. {
  492. float set = 0;
  493. if (float.TryParse(txtStageT.Text, out set))
  494. {
  495. iSEM.SetStageGotoT(set);
  496. }
  497. }
  498. private void btnStageSetR_Click(object sender, EventArgs e)
  499. {
  500. float set = 0;
  501. if (float.TryParse(txtStageR.Text, out set))
  502. {
  503. iSEM.SetStageGotoR(set);
  504. }
  505. }
  506. private void btnStageSetM_Click(object sender, EventArgs e)
  507. {
  508. float set = 0;
  509. if (float.TryParse(txtStageM.Text, out set))
  510. {
  511. iSEM.SetStageGotoM(set);
  512. }
  513. }
  514. #endregion
  515. #region 获取样品台位置数组
  516. private void btnGetStagePosition_Click(object sender, EventArgs e)
  517. {
  518. float[] pt = iSEM.GetStagePosition();
  519. if (!float.IsNaN(pt[0]))
  520. {
  521. lblStageX.Text = pt[0].ToString();
  522. }
  523. if (!float.IsNaN(pt[1]))
  524. {
  525. lblStageY.Text = pt[1].ToString();
  526. }
  527. if (!float.IsNaN(pt[2]))
  528. {
  529. lblStageZ.Text = pt[2].ToString();
  530. }
  531. if (!float.IsNaN(pt[3]))
  532. {
  533. lblStageT.Text = pt[3].ToString();
  534. }
  535. if (!float.IsNaN(pt[4]))
  536. {
  537. lblStageR.Text = pt[4].ToString();
  538. }
  539. if (!float.IsNaN(pt[5]))
  540. {
  541. lblStageM.Text = pt[5].ToString();
  542. }
  543. }
  544. #endregion
  545. #region 窗体关闭
  546. private void FormUnitControl_FormClosing(object sender, FormClosingEventArgs e)
  547. {
  548. if (iSEM != null)
  549. {
  550. iSEM.Dispose();
  551. }
  552. }
  553. #endregion
  554. #region 宏文件
  555. private void btnCMDMCF_Click(object sender, EventArgs e)
  556. {
  557. iSEM.CMDMCFFilename("OPTON");
  558. }
  559. #endregion
  560. #region 读取Xml文件
  561. private void btnReadXml_Click(object sender, EventArgs e)
  562. {
  563. MeasureFile mf = new MeasureFile();
  564. XmlDocument doc = new XmlDocument();
  565. doc.Load("test_opton.msf");//载入xml文件
  566. XmlNode root = doc.SelectSingleNode("XMLData");
  567. mf.Serialize(false, doc, root);
  568. doc.Save("test_opton.msf");
  569. }
  570. #endregion
  571. #region 写入Xml文件
  572. private void btnWriteXml_Click(object sender, EventArgs e)
  573. {
  574. MeasureFile mf = new MeasureFile();
  575. mf.FileName = path + "\\test_opton.msf";
  576. mf.FilePath = path;
  577. CutHole ch = new CutHole();
  578. ch.OPT = Operation.Image;
  579. ch.START = System.DateTime.Now;
  580. ch.END = System.DateTime.Now.AddHours(2);
  581. ch.STATE = State.Success;
  582. ch.SWITCH = true;
  583. SemPosition sp = new SemPosition();
  584. sp.X = 11;
  585. sp.Y = 22;
  586. sp.Z = 33;
  587. sp.T = 44;
  588. sp.R = 55;
  589. sp.M = 66;
  590. ch.Position = sp;
  591. mf.ListCutHole.Add(ch);
  592. ch = new CutHole();
  593. ch.OPT = Operation.Image;
  594. ch.START = System.DateTime.Now;
  595. ch.END = System.DateTime.Now.AddHours(2);
  596. ch.STATE = State.Success;
  597. ch.SWITCH = true;
  598. sp = new SemPosition();
  599. sp.X = 12;
  600. sp.Y = 34;
  601. sp.Z = 56;
  602. sp.T = 78;
  603. sp.R = 90;
  604. sp.M = 55;
  605. ch.Position = sp;
  606. mf.ListCutHole.Add(ch);
  607. MeasureParam md = new MeasureParam();
  608. md.SampleName = "aaaaaa";
  609. md.PT = true;
  610. md.PTTemp = "bbbbb";
  611. md.FIBTemp = "cccc";
  612. md.FocusMode = false;
  613. mf.MParam = md;
  614. mf.New();
  615. //XmlDocument doc = new XmlDocument();
  616. //doc.Load(mf.FilePath+"\\" + mf.FileName);//载入xml文件
  617. //XmlNode root = doc.SelectSingleNode("XMLData");
  618. //mf.Serialize(true, doc, root);
  619. //doc.Save("test.aaa");
  620. }
  621. #endregion
  622. #region SEM模式
  623. private void btnSEM_Click(object sender, EventArgs e)
  624. {
  625. if (iSEM.CmdFIBModeSEM())
  626. {
  627. btnFIB.BackColor = SystemColors.Control;
  628. btnSEM.BackColor = Color.Lime;
  629. btnMILL.BackColor = SystemColors.Control;
  630. panelFIB.Visible = false;
  631. }
  632. }
  633. #endregion
  634. #region FIB模式
  635. private void btnFIB_Click(object sender, EventArgs e)
  636. {
  637. if (iSEM.CmdFIBModeFIB())
  638. {
  639. btnFIB.BackColor = Color.Lime;
  640. btnSEM.BackColor = SystemColors.Control;
  641. btnMILL.BackColor = SystemColors.Control;
  642. panelFIB.Visible = true;
  643. }
  644. }
  645. #endregion
  646. #region MILL模式
  647. private void btnMILL_Click(object sender, EventArgs e)
  648. {
  649. if (iSEM.CmdFIBModeMILL())
  650. {
  651. btnFIB.BackColor = SystemColors.Control;
  652. btnSEM.BackColor = SystemColors.Control;
  653. btnMILL.BackColor = Color.Lime;
  654. }
  655. }
  656. #endregion
  657. #region 自动对焦1
  658. private void btnAutoFocus1_Click(object sender, EventArgs e)
  659. {
  660. //抓图1
  661. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  662. if (File.Exists(path + "\\test1.tif"))
  663. {
  664. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  665. pictureBox1.Image = Image.FromStream(fileStream);
  666. fileStream.Close();
  667. fileStream.Dispose();
  668. }
  669. Thread.Sleep(1000);
  670. iSEM.CmdAutoFocusCoarse();
  671. btnAutoFocus1.BackColor = Color.Red;
  672. st_flag = 1;
  673. Thread.Sleep(1000);
  674. Thread thread = new Thread(AutoFunction);
  675. thread.Start();
  676. }
  677. #endregion
  678. #region 自动函数监测线程
  679. private void AutoFunction()
  680. {
  681. float ret = 111;
  682. Boolean state = false;
  683. while (true)
  684. {
  685. Thread.Sleep(1000);
  686. ret = iSEM.GetAutoFunction();
  687. if (ret == 0)
  688. {
  689. if (st_flag == 1 && state == true)
  690. {
  691. btnAutoFocus1.BackColor = Color.Lime;
  692. Thread.Sleep(1000);
  693. //抓图1
  694. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  695. if (File.Exists(path + "\\test2.tif"))
  696. {
  697. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  698. pictureBox2.Image = Image.FromStream(fileStream);
  699. fileStream.Close();
  700. fileStream.Dispose();
  701. }
  702. break;
  703. }
  704. else if (st_flag == 2 && state)
  705. {
  706. btnAutoFocus2.BackColor = Color.Lime;
  707. Thread.Sleep(1000);
  708. //抓图1
  709. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  710. if (File.Exists(path + "\\test2.tif"))
  711. {
  712. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  713. pictureBox2.Image = Image.FromStream(fileStream);
  714. fileStream.Close();
  715. fileStream.Dispose();
  716. }
  717. break;
  718. }
  719. else if (st_flag == 3)
  720. {
  721. btnAutoBrightness.BackColor = Color.Lime;
  722. Thread.Sleep(1000);
  723. //抓图1
  724. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  725. if (File.Exists(path + "\\test2.tif"))
  726. {
  727. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  728. pictureBox2.Image = Image.FromStream(fileStream);
  729. fileStream.Close();
  730. fileStream.Dispose();
  731. }
  732. break;
  733. }
  734. else if (st_flag == 4)
  735. {
  736. btnAutoContrast.BackColor = Color.Lime;
  737. Thread.Sleep(1000);
  738. //抓图1
  739. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  740. if (File.Exists(path + "\\test2.tif"))
  741. {
  742. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  743. pictureBox2.Image = Image.FromStream(fileStream);
  744. fileStream.Close();
  745. fileStream.Dispose();
  746. }
  747. break;
  748. }
  749. else if (st_flag == 5)
  750. {
  751. btnAutoBrightness.BackColor = Color.Lime;
  752. btnAutoContrast.BackColor = Color.Lime;
  753. btnAutoBC.BackColor = Color.Lime;
  754. Thread.Sleep(1000);
  755. //抓图1
  756. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  757. if (File.Exists(path + "\\test2.tif"))
  758. {
  759. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  760. pictureBox2.Image = Image.FromStream(fileStream);
  761. fileStream.Close();
  762. fileStream.Dispose();
  763. }
  764. break;
  765. }
  766. else if (st_flag == 6 && state)
  767. {
  768. btnAutoBCCancle.BackColor = Color.Lime;
  769. Thread.Sleep(1000);
  770. //抓图1
  771. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  772. if (File.Exists(path + "\\test2.tif"))
  773. {
  774. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  775. pictureBox2.Image = Image.FromStream(fileStream);
  776. fileStream.Close();
  777. fileStream.Dispose();
  778. }
  779. break;
  780. }
  781. else if (st_flag == 7 && state)
  782. {
  783. btnAutoStig.BackColor = Color.Lime;
  784. Thread.Sleep(1000);
  785. //抓图1
  786. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  787. if (File.Exists(path + "\\test2.tif"))
  788. {
  789. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  790. pictureBox2.Image = Image.FromStream(fileStream);
  791. fileStream.Close();
  792. fileStream.Dispose();
  793. }
  794. break;
  795. }
  796. ////抓图1
  797. //iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  798. //if (File.Exists(path + "\\test2.tif"))
  799. //{
  800. // FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  801. // pictureBox2.Image = Image.FromStream(fileStream);
  802. // fileStream.Close();
  803. // fileStream.Dispose();
  804. //}
  805. }
  806. else if (ret > 0 && ret < 12)
  807. {
  808. state = true;
  809. }
  810. }
  811. }
  812. #endregion
  813. #region 自动对焦2
  814. private void btnAutoFocus2_Click(object sender, EventArgs e)
  815. {
  816. //抓图1
  817. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  818. if (File.Exists(path + "\\test1.tif"))
  819. {
  820. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  821. pictureBox1.Image = Image.FromStream(fileStream);
  822. fileStream.Close();
  823. fileStream.Dispose();
  824. }
  825. Thread.Sleep(1000);
  826. iSEM.CmdAutoFocusFine();
  827. btnAutoFocus2.BackColor = Color.Red;
  828. st_flag = 2;
  829. Thread.Sleep(1000);
  830. Thread thread = new Thread(AutoFunction);
  831. thread.Start();
  832. }
  833. #endregion
  834. #region 自动亮度、对比度
  835. private void btnAutoBrightness_Click(object sender, EventArgs e)
  836. {
  837. //抓图1
  838. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  839. if (File.Exists(path + "\\test1.tif"))
  840. {
  841. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  842. pictureBox1.Image = Image.FromStream(fileStream);
  843. fileStream.Close();
  844. fileStream.Dispose();
  845. }
  846. Thread.Sleep(1000);
  847. iSEM.SetAutoVideoBrightness();
  848. btnAutoBrightness.BackColor = Color.Red;
  849. st_flag = 3;
  850. Thread.Sleep(1000);
  851. Thread thread = new Thread(AutoFunction);
  852. thread.Start();
  853. }
  854. private void btnAutoContrast_Click(object sender, EventArgs e)
  855. {
  856. //抓图1
  857. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  858. if (File.Exists(path + "\\test1.tif"))
  859. {
  860. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  861. pictureBox1.Image = Image.FromStream(fileStream);
  862. fileStream.Close();
  863. fileStream.Dispose();
  864. }
  865. Thread.Sleep(1000);
  866. iSEM.SetAutoVideoBrightness();
  867. btnAutoContrast.BackColor = Color.Red;
  868. st_flag = 4;
  869. Thread.Sleep(1000);
  870. Thread thread = new Thread(AutoFunction);
  871. thread.Start();
  872. }
  873. private void btnAutoBC_Click(object sender, EventArgs e)
  874. {
  875. //抓图1
  876. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  877. if (File.Exists(path + "\\test1.tif"))
  878. {
  879. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  880. pictureBox1.Image = Image.FromStream(fileStream);
  881. fileStream.Close();
  882. fileStream.Dispose();
  883. }
  884. Thread.Sleep(1000);
  885. iSEM.SetAutoVideoBrightness();
  886. btnAutoBrightness.BackColor = Color.Red;
  887. btnAutoContrast.BackColor = Color.Red;
  888. btnAutoBC.BackColor = Color.Red;
  889. st_flag = 5;
  890. Thread.Sleep(1000);
  891. Thread thread = new Thread(AutoFunction);
  892. thread.Start();
  893. }
  894. private void btnAutoBCCancle_Click(object sender, EventArgs e)
  895. {
  896. iSEM.SetAutoVideoOff();
  897. btnAutoBCCancle.BackColor = Color.Red;
  898. st_flag = 6;
  899. Thread.Sleep(1000);
  900. Thread thread = new Thread(AutoFunction);
  901. thread.Start();
  902. }
  903. #endregion
  904. #region 自动消像散
  905. private void btnAutoStig_Click(object sender, EventArgs e)
  906. {
  907. //抓图1
  908. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  909. if (File.Exists(path + "\\test1.tif"))
  910. {
  911. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  912. pictureBox1.Image = Image.FromStream(fileStream);
  913. fileStream.Close();
  914. fileStream.Dispose();
  915. }
  916. Thread.Sleep(1000);
  917. iSEM.CmdAutoStig();
  918. btnAutoStig.BackColor = Color.Red;
  919. st_flag = 7;
  920. Thread.Sleep(1000);
  921. Thread thread = new Thread(AutoFunction);
  922. thread.Start();
  923. }
  924. #endregion
  925. #region FIB缩放Get
  926. private void btnFIBMagGet_Click(object sender, EventArgs e)
  927. {
  928. float ret = iSEM.GetFIBMagnification();
  929. if (float.IsNaN(ret))
  930. {
  931. txtFIBMag.Text = "NaN";
  932. txtFIBMag.Enabled = false;
  933. btnFIBMagSet.Enabled = false;
  934. }
  935. else
  936. {
  937. txtFIBMag.Text = ret.ToString();
  938. btnFIBMagSet.Enabled = true;
  939. }
  940. }
  941. #endregion
  942. #region FIB缩放Set
  943. private void btnFIBMagSet_Click(object sender, EventArgs e)
  944. {
  945. float set = 0;
  946. if (float.TryParse(txtFIBMag.Text, out set))
  947. {
  948. iSEM.SetFIBMagnification(set);
  949. }
  950. }
  951. #endregion
  952. #region FIB焦距Get
  953. private void btnFIBWDGet_Click(object sender, EventArgs e)
  954. {
  955. float ret = iSEM.GetFIBObjectivePotential();
  956. if (float.IsNaN(ret))
  957. {
  958. txtFIBWD.Text = "NaN";
  959. txtFIBWD.Enabled = false;
  960. btnFIBWDSet.Enabled = false;
  961. }
  962. else
  963. {
  964. txtFIBWD.Text = ret.ToString();
  965. btnFIBWDSet.Enabled = true;
  966. }
  967. }
  968. #endregion
  969. #region FIB焦距Set
  970. private void btnFIBWDSet_Click(object sender, EventArgs e)
  971. {
  972. float set = 0;
  973. if (float.TryParse(txtFIBWD.Text, out set))
  974. {
  975. iSEM.SetFIBObjectivePotential(set);
  976. }
  977. }
  978. #endregion
  979. #region FIB电子束移动
  980. private void btnFIBBeamShiftXGet_Click(object sender, EventArgs e)
  981. {
  982. float ret = iSEM.GetFIBBeamShiftX();
  983. if (float.IsNaN(ret))
  984. {
  985. txtFIBBeamShiftX.Text = "NaN";
  986. txtFIBBeamShiftX.Enabled = false;
  987. btnFIBBeamShiftXSet.Enabled = false;
  988. }
  989. else
  990. {
  991. txtFIBBeamShiftX.Text = ret.ToString();
  992. btnFIBBeamShiftXSet.Enabled = true;
  993. }
  994. }
  995. private void btnFIBBeamShiftXSet_Click(object sender, EventArgs e)
  996. {
  997. float set = 0;
  998. if (float.TryParse(txtFIBBeamShiftX.Text, out set))
  999. {
  1000. iSEM.SetFIBBeamShiftX(set);
  1001. }
  1002. }
  1003. private void btnFIBBeamShiftYGet_Click(object sender, EventArgs e)
  1004. {
  1005. float ret = iSEM.GetFIBBeamShiftY();
  1006. if (float.IsNaN(ret))
  1007. {
  1008. txtFIBBeamShiftY.Text = "NaN";
  1009. txtFIBBeamShiftY.Enabled = false;
  1010. btnFIBBeamShiftYSet.Enabled = false;
  1011. }
  1012. else
  1013. {
  1014. txtFIBBeamShiftY.Text = ret.ToString();
  1015. btnFIBBeamShiftYSet.Enabled = true;
  1016. }
  1017. }
  1018. private void btnFIBBeamShiftYSet_Click(object sender, EventArgs e)
  1019. {
  1020. float set = 0;
  1021. if (float.TryParse(txtFIBBeamShiftY.Text, out set))
  1022. {
  1023. iSEM.SetFIBBeamShiftY(set);
  1024. }
  1025. }
  1026. #endregion
  1027. #region 执行宏文件
  1028. private void btnMCF_Click(object sender, EventArgs e)
  1029. {
  1030. OpenFileDialog sfd = new OpenFileDialog();
  1031. sfd.Title = "选择宏文件:";
  1032. sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
  1033. sfd.Filter = "MLF文件|*.MLF";
  1034. if (sfd.ShowDialog() == DialogResult.OK)
  1035. {
  1036. string fn = Path.GetFileNameWithoutExtension(sfd.FileName).ToUpper();
  1037. iSEM.CMDMCFFilename(fn);
  1038. }
  1039. }
  1040. #endregion
  1041. #region FIB消像散
  1042. private void btnFIBAstigmatismXGet_Click(object sender, EventArgs e)
  1043. {
  1044. float ret = iSEM.GetFIBAstigmatismX();
  1045. if (float.IsNaN(ret))
  1046. {
  1047. txtFIBAstigmatismX.Text = "NaN";
  1048. txtFIBAstigmatismX.Enabled = false;
  1049. btnFIBAstigmatismXSet.Enabled = false;
  1050. }
  1051. else
  1052. {
  1053. txtFIBAstigmatismX.Text = ret.ToString();
  1054. btnFIBAstigmatismXSet.Enabled = true;
  1055. }
  1056. }
  1057. private void btnFIBAstigmatismXSet_Click(object sender, EventArgs e)
  1058. {
  1059. float set = 0;
  1060. if (float.TryParse(txtFIBAstigmatismX.Text, out set))
  1061. {
  1062. iSEM.SetFIBAstigmatismX(set);
  1063. }
  1064. }
  1065. private void btnFIBAstigmatismYGet_Click(object sender, EventArgs e)
  1066. {
  1067. float ret = iSEM.GetFIBAstigmatismY();
  1068. if (float.IsNaN(ret))
  1069. {
  1070. txtFIBAstigmatismY.Text = "NaN";
  1071. txtFIBAstigmatismY.Enabled = false;
  1072. btnFIBAstigmatismYSet.Enabled = false;
  1073. }
  1074. else
  1075. {
  1076. txtFIBAstigmatismY.Text = ret.ToString();
  1077. btnFIBAstigmatismYSet.Enabled = true;
  1078. }
  1079. }
  1080. private void btnFIBAstigmatismYSet_Click(object sender, EventArgs e)
  1081. {
  1082. float set = 0;
  1083. if (float.TryParse(txtFIBAstigmatismY.Text, out set))
  1084. {
  1085. iSEM.SetFIBAstigmatismY(set);
  1086. }
  1087. }
  1088. #endregion
  1089. #region 移动样品台XY
  1090. private void btnMoveXY_Click(object sender, EventArgs e)
  1091. {
  1092. float setx = 0;
  1093. float sety = 0;
  1094. if (!float.TryParse(txtStageX.Text, out setx))
  1095. {
  1096. return;
  1097. }
  1098. if (!float.TryParse(txtStageY.Text, out sety))
  1099. {
  1100. return;
  1101. }
  1102. btnMoveXY.BackColor = Color.Red;
  1103. iSEM.MoveStageXY(setx, sety);
  1104. Thread.Sleep(500);
  1105. Thread th = new Thread(MoveStagexy);
  1106. th.Start();
  1107. }
  1108. private void MoveStagexy()
  1109. {
  1110. float ret = 111;
  1111. while (true)
  1112. {
  1113. ret = iSEM.GetStageIs();
  1114. if (ret == 0)
  1115. {
  1116. btnMoveXY.BackColor = Color.Lime;
  1117. break;
  1118. }
  1119. }
  1120. }
  1121. #endregion
  1122. #region 获取分辨率
  1123. private void btnImageStoreGet_Click(object sender, EventArgs e)
  1124. {
  1125. int[] ret = iSEM.GetImageStore();
  1126. lblImageStore.Text = ret[0].ToString() + "*" + ret[1].ToString();
  1127. }
  1128. #endregion
  1129. #region 设置分辨率
  1130. private void btnImageStoreSet_Click(object sender, EventArgs e)
  1131. {
  1132. if (cmbImageStore.SelectedIndex > -1 && cmbImageStore.SelectedIndex < 12)
  1133. {
  1134. iSEM.SetImageStore(cmbImageStore.SelectedIndex);
  1135. }
  1136. }
  1137. #endregion
  1138. #region 样品台急停
  1139. private void btnAbort_Click(object sender, EventArgs e)
  1140. {
  1141. iSEM.CmdStageAbort();
  1142. }
  1143. #endregion
  1144. private void btnLive_Click(object sender, EventArgs e)
  1145. {
  1146. iSEM.ImageLive();
  1147. }
  1148. private void btnFrozen_Click(object sender, EventArgs e)
  1149. {
  1150. iSEM.ImageFrozen();
  1151. }
  1152. private void btnExeEly_Click(object sender, EventArgs e)
  1153. {
  1154. iSEM.CmdFIBLoadELY(@"E:\HOZ\MillStep2.ely");
  1155. }
  1156. private void btnExeEly2_Click(object sender, EventArgs e)
  1157. {
  1158. iSEM.CmdFIBLoadELY(@"E:\HOZ\MillStep4.ely");
  1159. }
  1160. private void btnFIBStatus_Click(object sender, EventArgs e)
  1161. {
  1162. btnFIBStatus.Text = iSEM.GetFIBApiStatus().ToString();
  1163. }
  1164. //测量线程测试
  1165. private void button1_Click(object sender, EventArgs e)
  1166. {
  1167. //FormMeasureTest Measure = new FormMeasureTest();
  1168. //Measure.Show();
  1169. }
  1170. private void btnPost1_Click(object sender, EventArgs e)
  1171. {
  1172. double degree = 0;
  1173. int direction = 0;
  1174. int state = 0;
  1175. wr.Img_OffsetAngle_Direction("D:/aaaa.jpg", out degree, out direction, out state);
  1176. lbldegree1.Text = degree.ToString("0.0");
  1177. lbldirection1.Text = direction.ToString();
  1178. lblstate1.Text = state.ToString();
  1179. }
  1180. private void btnPost2_Click(object sender, EventArgs e)
  1181. {
  1182. double offsetx = 0;
  1183. double offsety = 0;
  1184. int state = 0;
  1185. wr.Img_Cut_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
  1186. lbllocationx.Text = offsetx.ToString("0.0");
  1187. lbllocationy.Text = offsety.ToString("0.0");
  1188. lblstate2.Text = state.ToString();
  1189. }
  1190. private void btnPost3_Click(object sender, EventArgs e)
  1191. {
  1192. int state = 0;
  1193. wr.Img_Cut_Success("D:/aaaa.jpg", "D:/bbbb.jpg", out state);
  1194. lblstate3.Text = state.ToString();
  1195. }
  1196. private void btnPost4_Click(object sender, EventArgs e)
  1197. {
  1198. double offsetx = 0;
  1199. double offsety = 0;
  1200. int state = 0;
  1201. wr.Img_Trapezoid_Top_Center_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
  1202. lbltopcx.Text = offsetx.ToString("0.0");
  1203. lbltopcy.Text = offsety.ToString("0.0");
  1204. lblstate4.Text = state.ToString();
  1205. }
  1206. private void btnPost5_Click(object sender, EventArgs e)
  1207. {
  1208. List<string> filenames = new List<string>();
  1209. filenames.Add("1111111");
  1210. filenames.Add("2222222");
  1211. filenames.Add("3333333");
  1212. lblfocuspath.Text = wr.Img_Auto_Focus(filenames);
  1213. }
  1214. private void btnPost6_Click(object sender, EventArgs e)
  1215. {
  1216. List<string> filenames = new List<string>();
  1217. filenames.Add("1111111");
  1218. filenames.Add("2222222");
  1219. filenames.Add("3333333");
  1220. lblstigpath.Text = wr.Img_Auto_Focus(filenames);
  1221. }
  1222. private void btnPost7_Click(object sender, EventArgs e)
  1223. {
  1224. double offsetx = 0;
  1225. double offsety = 0;
  1226. double degree = 0;
  1227. int direction = 0;
  1228. int state = 0;
  1229. wr.Img_Center_Position_OffsetAngle_Direction("D:/aaaa.jpg", out offsetx, out offsety, out degree, out direction, out state);
  1230. lblcenterx.Text = offsetx.ToString("0.0");
  1231. lblcentery.Text = offsety.ToString("0.0");
  1232. lbldegree2.Text = degree.ToString();
  1233. lbldirection2.Text = direction.ToString();
  1234. lblstate5.Text = state.ToString();
  1235. }
  1236. private void btnPost8_Click(object sender, EventArgs e)
  1237. {
  1238. int state = 0;
  1239. wr.Img_Measure_Size("D:/aaaa.jpg", "1000", "0.005", out state);
  1240. lblstate6.Text = state.ToString();
  1241. }
  1242. private void btnPost1_Click(object sender, EventArgs e)
  1243. {
  1244. double degree = 0;
  1245. int direction = 0;
  1246. int state = 0;
  1247. wr.Img_OffsetAngle_Direction("D:/aaaa.jpg", out degree, out direction, out state);
  1248. lbldegree1.Text = degree.ToString("0.0");
  1249. lbldirection1.Text = direction.ToString();
  1250. lblstate1.Text = state.ToString();
  1251. }
  1252. private void btnPost2_Click(object sender, EventArgs e)
  1253. {
  1254. double offsetx = 0;
  1255. double offsety = 0;
  1256. int state = 0;
  1257. wr.Img_Cut_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
  1258. lbllocationx.Text = offsetx.ToString("0.0");
  1259. lbllocationy.Text = offsety.ToString("0.0");
  1260. lblstate2.Text = state.ToString();
  1261. }
  1262. private void btnPost3_Click(object sender, EventArgs e)
  1263. {
  1264. int state = 0;
  1265. wr.Img_Cut_Success("D:/aaaa.jpg", "D:/bbbb.jpg", out state);
  1266. lblstate3.Text = state.ToString();
  1267. }
  1268. private void btnPost4_Click(object sender, EventArgs e)
  1269. {
  1270. double offsetx = 0;
  1271. double offsety = 0;
  1272. int state = 0;
  1273. wr.Img_Trapezoid_Top_Center_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
  1274. lbltopcx.Text = offsetx.ToString("0.0");
  1275. lbltopcy.Text = offsety.ToString("0.0");
  1276. lblstate4.Text = state.ToString();
  1277. }
  1278. private void btnPost5_Click(object sender, EventArgs e)
  1279. {
  1280. List<string> filenames = new List<string>();
  1281. filenames.Add("1111111");
  1282. filenames.Add("2222222");
  1283. filenames.Add("3333333");
  1284. lblfocuspath.Text = wr.Img_Auto_Focus(filenames);
  1285. }
  1286. private void btnPost6_Click(object sender, EventArgs e)
  1287. {
  1288. List<string> filenames = new List<string>();
  1289. filenames.Add("1111111");
  1290. filenames.Add("2222222");
  1291. filenames.Add("3333333");
  1292. lblstigpath.Text = wr.Img_Auto_Focus(filenames);
  1293. }
  1294. private void btnPost7_Click(object sender, EventArgs e)
  1295. {
  1296. double offsetx = 0;
  1297. double offsety = 0;
  1298. double degree = 0;
  1299. int direction = 0;
  1300. int state = 0;
  1301. wr.Img_Center_Position_OffsetAngle_Direction("D:/aaaa.jpg", out offsetx, out offsety, out degree, out direction, out state);
  1302. lblcenterx.Text = offsetx.ToString("0.0");
  1303. lblcentery.Text = offsety.ToString("0.0");
  1304. lbldegree2.Text = degree.ToString();
  1305. lbldirection2.Text = direction.ToString();
  1306. lblstate5.Text = state.ToString();
  1307. }
  1308. private void btnPost8_Click(object sender, EventArgs e)
  1309. {
  1310. int state = 0;
  1311. wr.Img_Measure_Size("D:/aaaa.jpg", "1000", "0.005", out state);
  1312. lblstate6.Text = state.ToString();
  1313. }
  1314. }
  1315. }