FormUnitControl.cs 47 KB

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