FormUnitControl.cs 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  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. using Extender;
  23. namespace HOZProject
  24. {
  25. public partial class FormUnitControl : Form
  26. {
  27. #region 系统参数
  28. //全局只有一个fatorySEM
  29. static FactoryHardware factorySEM = FactoryHardware.Instance;
  30. ISEMControl iSEM = factorySEM.ISEM;
  31. //static FactoryHardware factorySEM = null;
  32. //ISEMControl iSEM = null;
  33. public XmlManager xmg = new XmlManager();
  34. private String path = Directory.GetCurrentDirectory();
  35. private int st_flag = 0;
  36. WebResult wr = new WebResult(ConfigurationManager.AppSettings["WebServerIP"].ToString(),
  37. ConfigurationManager.AppSettings["WebServerPort"].ToString(),
  38. ConfigurationManager.AppSettings["WebServerUrl"].ToString());
  39. String[] sT;
  40. String[] firms;
  41. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  42. #endregion
  43. #region 构造函数
  44. public FormUnitControl()
  45. {
  46. InitializeComponent();
  47. Control.CheckForIllegalCrossThreadCalls = false;
  48. //if(iSEM.ConnectStatus())
  49. //{
  50. // float ret = iSEM.GetFIBIMAGING();
  51. // if(ret==0)
  52. // {
  53. // btnSEM.BackColor = Color.Lime;
  54. // }
  55. // else if(ret==1)
  56. // {
  57. // btnFIB.BackColor = Color.Lime;
  58. // panelFIB.Visible = true;
  59. // }
  60. // else if(ret==2)
  61. // {
  62. // btnMILL.BackColor = Color.Lime;
  63. // }
  64. //}
  65. ////Calling Notification for updated status
  66. //CZEMApi.Notify += new _EMApiEvents_NotifyEventHandler(CZEMApi_Notify);
  67. //CZEMApi.NotifyWithCurrentValue += new _EMApiEvents_NotifyWithCurrentValueEventHandler(CZEMApi_NotifyWithCurrentValue);
  68. //加载参数
  69. }
  70. #endregion
  71. #region 缩放Get
  72. private void btnenlargeGet_Click(object sender, EventArgs e)
  73. {
  74. float ret = iSEM.GetMagnification();
  75. if (float.IsNaN(ret))
  76. {
  77. txtenlargeSet.Text = "NaN";
  78. txtenlargeSet.Enabled = false;
  79. btnenlargeSet.Enabled = false;
  80. }
  81. else
  82. {
  83. txtenlargeSet.Text = ret.ToString();
  84. btnenlargeSet.Enabled = true;
  85. }
  86. }
  87. #endregion
  88. #region 缩放Set
  89. private void btnenlargeSet_Click(object sender, EventArgs e)
  90. {
  91. float set = 0;
  92. if (float.TryParse(txtenlargeSet.Text, out set))
  93. {
  94. iSEM.SetMagnification(set);
  95. }
  96. }
  97. #endregion
  98. #region 焦距Get
  99. private void btnWDGet_Click(object sender, EventArgs e)
  100. {
  101. float ret = iSEM.GetWorkingDistance();
  102. if (float.IsNaN(ret))
  103. {
  104. txtWDSet.Text = "NaN";
  105. txtWDSet.Enabled = false;
  106. btnWDSet.Enabled = false;
  107. }
  108. else
  109. {
  110. txtWDSet.Text = ret.ToString();
  111. btnWDSet.Enabled = true;
  112. }
  113. }
  114. #endregion
  115. #region 焦距Set
  116. private void btnWDSet_Click(object sender, EventArgs e)
  117. {
  118. float set = 0;
  119. if (float.TryParse(txtWDSet.Text, out set))
  120. {
  121. iSEM.SetWorkingDistance(set);
  122. }
  123. }
  124. #endregion
  125. #region 亮度Get
  126. private void btnBrightnessGet_Click(object sender, EventArgs e)
  127. {
  128. float ret = iSEM.GetBrightness();
  129. if (float.IsNaN(ret))
  130. {
  131. txtBrightnessSet.Text = "NaN";
  132. txtBrightnessSet.Enabled = false;
  133. btnBrightnessSet.Enabled = false;
  134. }
  135. else
  136. {
  137. txtBrightnessSet.Text = ret.ToString();
  138. btnBrightnessSet.Enabled = true;
  139. }
  140. }
  141. #endregion
  142. #region 亮度Set
  143. private void btnBrightnessSet_Click(object sender, EventArgs e)
  144. {
  145. float set = 0;
  146. if (float.TryParse(txtBrightnessSet.Text, out set))
  147. {
  148. iSEM.SetBrightness(set);
  149. }
  150. }
  151. #endregion
  152. #region 对比度Get
  153. private void btnContrastGet_Click(object sender, EventArgs e)
  154. {
  155. float ret = iSEM.GetContrast();
  156. if (float.IsNaN(ret))
  157. {
  158. txtContrastSet.Text = "NaN";
  159. txtContrastSet.Enabled = false;
  160. btnContrastSet.Enabled = false;
  161. }
  162. else
  163. {
  164. txtContrastSet.Text = ret.ToString();
  165. btnContrastSet.Enabled = true;
  166. }
  167. }
  168. #endregion
  169. #region 对比度Set
  170. private void btnContrastSet_Click(object sender, EventArgs e)
  171. {
  172. float set = 0;
  173. if (float.TryParse(txtContrastSet.Text, out set))
  174. {
  175. iSEM.SetContrast(set);
  176. }
  177. }
  178. #endregion
  179. #region 消像散X Get
  180. private void btnAstigmatismXGet_Click(object sender, EventArgs e)
  181. {
  182. float ret = iSEM.GetAstigmatismX();
  183. if (float.IsNaN(ret))
  184. {
  185. txtAstigmatismXSet.Text = "NaN";
  186. txtAstigmatismXSet.Enabled = false;
  187. btnAstigmatismXSet.Enabled = false;
  188. }
  189. else
  190. {
  191. txtAstigmatismXSet.Text = ret.ToString();
  192. btnAstigmatismXSet.Enabled = true;
  193. }
  194. }
  195. #endregion
  196. #region 消像散X Set
  197. private void btnAstigmatismXSet_Click(object sender, EventArgs e)
  198. {
  199. float set = 0;
  200. if (float.TryParse(txtAstigmatismXSet.Text, out set))
  201. {
  202. iSEM.SetAstigmatismX(set);
  203. }
  204. }
  205. #endregion
  206. #region 消像散Y Get
  207. private void btnAstigmatismYGet_Click(object sender, EventArgs e)
  208. {
  209. float ret = iSEM.GetAstigmatismY();
  210. if (float.IsNaN(ret))
  211. {
  212. txtAstigmatismYSet.Text = "NaN";
  213. txtAstigmatismYSet.Enabled = false;
  214. btnAstigmatismYSet.Enabled = false;
  215. }
  216. else
  217. {
  218. txtAstigmatismYSet.Text = ret.ToString();
  219. btnAstigmatismYSet.Enabled = true;
  220. }
  221. }
  222. #endregion
  223. #region 消像散Y Set
  224. private void btnAstigmatismYSet_Click(object sender, EventArgs e)
  225. {
  226. float set = 0;
  227. if (float.TryParse(txtAstigmatismYSet.Text, out set))
  228. {
  229. iSEM.SetAstigmatismY(set);
  230. }
  231. }
  232. #endregion
  233. #region 角度补偿Get
  234. private void btnTiltAngleGet_Click(object sender, EventArgs e)
  235. {
  236. float ret = iSEM.GetTiltAngle();
  237. if (float.IsNaN(ret))
  238. {
  239. txtTiltAngleSet.Text = "NaN";
  240. txtTiltAngleSet.Enabled = false;
  241. btnTiltAngleSet.Enabled = false;
  242. }
  243. else
  244. {
  245. txtTiltAngleSet.Text = ret.ToString();
  246. btnTiltAngleSet.Enabled = true;
  247. }
  248. }
  249. #endregion
  250. #region 角度补偿Set
  251. private void btnTiltAngleSet_Click(object sender, EventArgs e)
  252. {
  253. float set = 0;
  254. if (float.TryParse(txtTiltAngleSet.Text, out set))
  255. {
  256. //iSEM.SetTiltAngleOn();
  257. iSEM.SetTiltAngle(set);
  258. }
  259. }
  260. #endregion
  261. #region 抓取图像
  262. private void btnGrabImage_Click(object sender, EventArgs e)
  263. {
  264. SaveFileDialog sfd = new SaveFileDialog();
  265. sfd.Title = "图像保存位置:";
  266. sfd.FileName = "test.tif";
  267. sfd.Filter = "TIF文件|*.tif";
  268. if (sfd.ShowDialog() == DialogResult.OK)
  269. {
  270. string fn = sfd.FileName;
  271. iSEM.GrabImage(fn, 0, 0, 1024, 768, 0);
  272. }
  273. }
  274. #endregion
  275. #region ScanRotate Get
  276. private void btnScanRotationGet_Click(object sender, EventArgs e)
  277. {
  278. float ret = iSEM.GetScanRotation();
  279. if (float.IsNaN(ret))
  280. {
  281. txtScanRotationSet.Text = "NaN";
  282. txtScanRotationSet.Enabled = false;
  283. btnScanRotationSet.Enabled = false;
  284. }
  285. else
  286. {
  287. txtScanRotationSet.Text = ret.ToString();
  288. btnScanRotationSet.Enabled = true;
  289. }
  290. }
  291. #endregion
  292. #region ScanRotate Set
  293. private void btnScanRotationSet_Click(object sender, EventArgs e)
  294. {
  295. float set = 0;
  296. if (float.TryParse(txtScanRotationSet.Text, out set))
  297. {
  298. //iSEM.SetScanRotationOn();
  299. iSEM.SetScanRotation(set);
  300. }
  301. }
  302. #endregion
  303. #region PixelSize Get
  304. private void btnPixelSizeGet_Click(object sender, EventArgs e)
  305. {
  306. float ret = iSEM.GetPixelSize();
  307. if (float.IsNaN(ret))
  308. {
  309. lblPixelSizeGet.Text = "NaN";
  310. }
  311. else
  312. {
  313. lblPixelSizeGet.Text = ret.ToString();
  314. }
  315. }
  316. #endregion
  317. #region 电子束
  318. private void btnTiltCorrXGet_Click(object sender, EventArgs e)
  319. {
  320. float ret = iSEM.GetBeamShiftX();
  321. if (float.IsNaN(ret))
  322. {
  323. txtTiltCorrX.Text = "NaN";
  324. txtTiltCorrX.Enabled = false;
  325. btnTiltCorrXSet.Enabled = false;
  326. }
  327. else
  328. {
  329. txtTiltCorrX.Text = ret.ToString();
  330. btnTiltCorrXSet.Enabled = true;
  331. }
  332. }
  333. private void btnTiltCorrXSet_Click(object sender, EventArgs e)
  334. {
  335. float set = 0;
  336. if (float.TryParse(txtTiltCorrX.Text, out set))
  337. {
  338. iSEM.SetBeamShiftX(set);
  339. }
  340. }
  341. private void btnTiltCorrYGet_Click(object sender, EventArgs e)
  342. {
  343. float ret = iSEM.GetBeamShiftY();
  344. if (float.IsNaN(ret))
  345. {
  346. txtTiltCorrY.Text = "NaN";
  347. txtTiltCorrY.Enabled = false;
  348. btnTiltCorrYSet.Enabled = false;
  349. }
  350. else
  351. {
  352. txtTiltCorrY.Text = ret.ToString();
  353. btnTiltCorrYSet.Enabled = true;
  354. }
  355. }
  356. private void btnTiltCorrYSet_Click(object sender, EventArgs e)
  357. {
  358. float set = 0;
  359. if (float.TryParse(txtTiltCorrY.Text, out set))
  360. {
  361. iSEM.SetBeamShiftY(set);
  362. }
  363. }
  364. #endregion
  365. #region 开启电压
  366. private void btnOpenVoltage_Click(object sender, EventArgs e)
  367. {
  368. iSEM.CmdOpenVoltage();
  369. }
  370. #endregion
  371. #region 关闭电压
  372. private void btnCloseVoltage_Click(object sender, EventArgs e)
  373. {
  374. iSEM.CmdCloseVoltage();
  375. }
  376. #endregion
  377. #region 电子束校正
  378. private void btnTiltCorr_Click(object sender, EventArgs e)
  379. {
  380. float ret = iSEM.GetTiltCorrection();
  381. if (float.IsNaN(ret))
  382. {
  383. btnTiltCorr.BackColor = Color.Red;
  384. }
  385. else
  386. {
  387. if(ret==0)
  388. {
  389. btnTiltCorr.BackColor = Color.Blue;
  390. iSEM.SetTiltCorrectionOn();
  391. btnTiltCorr.Text = "电子束状态:On";
  392. }
  393. else
  394. {
  395. btnTiltCorr.BackColor = Color.Lime;
  396. iSEM.SetTiltCorrectionOff();
  397. btnTiltCorr.Text = "电子束状态:Off";
  398. }
  399. }
  400. }
  401. #endregion
  402. #region 样品台位置获取
  403. private void btnStageGetX_Click(object sender, EventArgs e)
  404. {
  405. float ret = iSEM.GetStageAtX();
  406. if (float.IsNaN(ret))
  407. {
  408. lblStageX.Text = "NaN";
  409. }
  410. else
  411. {
  412. lblStageX.Text = ret.ToString();
  413. }
  414. }
  415. private void btnStageGetY_Click(object sender, EventArgs e)
  416. {
  417. float ret = iSEM.GetStageAtY();
  418. if (float.IsNaN(ret))
  419. {
  420. lblStageY.Text = "NaN";
  421. }
  422. else
  423. {
  424. lblStageY.Text = ret.ToString();
  425. }
  426. }
  427. private void btnStageGetZ_Click(object sender, EventArgs e)
  428. {
  429. float ret = iSEM.GetStageAtZ();
  430. if (float.IsNaN(ret))
  431. {
  432. lblStageZ.Text = "NaN";
  433. }
  434. else
  435. {
  436. lblStageZ.Text = ret.ToString();
  437. }
  438. }
  439. private void btnStageGetT_Click(object sender, EventArgs e)
  440. {
  441. float ret = iSEM.GetStageAtT();
  442. if (float.IsNaN(ret))
  443. {
  444. lblStageT.Text = "NaN";
  445. }
  446. else
  447. {
  448. lblStageT.Text = ret.ToString();
  449. }
  450. }
  451. private void btnStageGetR_Click(object sender, EventArgs e)
  452. {
  453. float ret = iSEM.GetStageAtR();
  454. if (float.IsNaN(ret))
  455. {
  456. lblStageR.Text = "NaN";
  457. }
  458. else
  459. {
  460. lblStageR.Text = ret.ToString();
  461. }
  462. }
  463. private void btnStageGetM_Click(object sender, EventArgs e)
  464. {
  465. float ret = iSEM.GetStageAtM();
  466. if (float.IsNaN(ret))
  467. {
  468. lblStageM.Text = "NaN";
  469. }
  470. else
  471. {
  472. lblStageM.Text = ret.ToString();
  473. }
  474. }
  475. #endregion
  476. #region 样品台位置设置
  477. private void btnStageSetX_Click(object sender, EventArgs e)
  478. {
  479. float set = 0;
  480. if (float.TryParse(txtStageX.Text, out set))
  481. {
  482. iSEM.SetStageGotoX(set);
  483. }
  484. }
  485. private void btnStageSetY_Click(object sender, EventArgs e)
  486. {
  487. float set = 0;
  488. if (float.TryParse(txtStageY.Text, out set))
  489. {
  490. iSEM.SetStageGotoY(set);
  491. }
  492. }
  493. private void btnStageSetZ_Click(object sender, EventArgs e)
  494. {
  495. float set = 0;
  496. if (float.TryParse(txtStageZ.Text, out set))
  497. {
  498. iSEM.SetStageGotoZ(set);
  499. }
  500. }
  501. private void btnStageSetT_Click(object sender, EventArgs e)
  502. {
  503. float set = 0;
  504. if (float.TryParse(txtStageT.Text, out set))
  505. {
  506. iSEM.SetStageGotoT(set);
  507. }
  508. }
  509. private void btnStageSetR_Click(object sender, EventArgs e)
  510. {
  511. float set = 0;
  512. if (float.TryParse(txtStageR.Text, out set))
  513. {
  514. iSEM.SetStageGotoR(set);
  515. }
  516. }
  517. private void btnStageSetM_Click(object sender, EventArgs e)
  518. {
  519. float set = 0;
  520. if (float.TryParse(txtStageM.Text, out set))
  521. {
  522. iSEM.SetStageGotoM(set);
  523. }
  524. }
  525. #endregion
  526. #region 获取样品台位置数组
  527. private void btnGetStagePosition_Click(object sender, EventArgs e)
  528. {
  529. float[] pt = iSEM.GetStagePosition();
  530. if (!float.IsNaN(pt[0]))
  531. {
  532. lblStageX.Text = pt[0].ToString();
  533. }
  534. if (!float.IsNaN(pt[1]))
  535. {
  536. lblStageY.Text = pt[1].ToString();
  537. }
  538. if (!float.IsNaN(pt[2]))
  539. {
  540. lblStageZ.Text = pt[2].ToString();
  541. }
  542. if (!float.IsNaN(pt[3]))
  543. {
  544. lblStageT.Text = pt[3].ToString();
  545. }
  546. if (!float.IsNaN(pt[4]))
  547. {
  548. lblStageR.Text = pt[4].ToString();
  549. }
  550. if (!float.IsNaN(pt[5]))
  551. {
  552. lblStageM.Text = pt[5].ToString();
  553. }
  554. }
  555. #endregion
  556. #region 窗体关闭
  557. private void FormUnitControl_FormClosing(object sender, FormClosingEventArgs e)
  558. {
  559. if(iSEM!=null)
  560. {
  561. iSEM.Dispose();
  562. }
  563. }
  564. #endregion
  565. #region 宏文件
  566. private void btnCMDMCF_Click(object sender, EventArgs e)
  567. {
  568. iSEM.CMDMCFFilename("OPTON");
  569. }
  570. #endregion
  571. #region 读取Xml文件
  572. private void btnReadXml_Click(object sender, EventArgs e)
  573. {
  574. MeasureFile mf = new MeasureFile();
  575. XmlDocument doc = new XmlDocument();
  576. doc.Load("test_opton.msf");//载入xml文件
  577. XmlNode root = doc.SelectSingleNode("XMLData");
  578. mf.Serialize(false, doc, root);
  579. doc.Save("test_opton.msf");
  580. }
  581. #endregion
  582. #region 写入Xml文件
  583. private void btnWriteXml_Click(object sender, EventArgs e)
  584. {
  585. MeasureFile mf = new MeasureFile();
  586. mf.FileName = path + "\\test_opton.msf";
  587. mf.FilePath = path;
  588. CutHole ch = new CutHole();
  589. //ch.OPT = Operation.Image;
  590. ch.START = System.DateTime.Now;
  591. ch.END = System.DateTime.Now.AddHours(2);
  592. ch.STATE = State.Success;
  593. ch.SWITCH = true;
  594. SemPosition sp = new SemPosition();
  595. sp.X = 11;
  596. sp.Y = 22;
  597. sp.Z = 33;
  598. sp.T = 44;
  599. sp.R = 55;
  600. sp.M = 66;
  601. ch.Position = sp;
  602. mf.ListCutHole.Add(ch);
  603. ch = new CutHole();
  604. //ch.OPT = Operation.Image;
  605. ch.START = System.DateTime.Now;
  606. ch.END = System.DateTime.Now.AddHours(2);
  607. ch.STATE = State.Success;
  608. ch.SWITCH = true;
  609. sp = new SemPosition();
  610. sp.X = 12;
  611. sp.Y = 34;
  612. sp.Z = 56;
  613. sp.T = 78;
  614. sp.R = 90;
  615. sp.M = 55;
  616. ch.Position = sp;
  617. mf.ListCutHole.Add(ch);
  618. MeasureParam md = new MeasureParam();
  619. md.SampleName = "aaaaaa";
  620. md.PT = true;
  621. md.PTTemp = "bbbbb";
  622. md.FIBTemp = "cccc";
  623. md.FocusMode = 2;
  624. mf.MParam = md;
  625. mf.New();
  626. //XmlDocument doc = new XmlDocument();
  627. //doc.Load(mf.FilePath+"\\" + mf.FileName);//载入xml文件
  628. //XmlNode root = doc.SelectSingleNode("XMLData");
  629. //mf.Serialize(true, doc, root);
  630. //doc.Save("test.aaa");
  631. }
  632. #endregion
  633. #region SEM模式
  634. private void btnSEM_Click(object sender, EventArgs e)
  635. {
  636. if(iSEM.CmdFIBModeSEM())
  637. {
  638. btnFIB.BackColor = SystemColors.Control;
  639. btnSEM.BackColor = Color.Lime;
  640. btnMILL.BackColor = SystemColors.Control;
  641. panelFIB.Visible = false;
  642. }
  643. }
  644. #endregion
  645. #region FIB模式
  646. private void btnFIB_Click(object sender, EventArgs e)
  647. {
  648. if(iSEM.CmdFIBModeFIB())
  649. {
  650. btnFIB.BackColor = Color.Lime;
  651. btnSEM.BackColor = SystemColors.Control;
  652. btnMILL.BackColor = SystemColors.Control;
  653. panelFIB.Visible = true;
  654. }
  655. }
  656. #endregion
  657. #region MILL模式
  658. private void btnMILL_Click(object sender, EventArgs e)
  659. {
  660. if(iSEM.CmdFIBModeMILL())
  661. {
  662. btnFIB.BackColor = SystemColors.Control;
  663. btnSEM.BackColor = SystemColors.Control;
  664. btnMILL.BackColor = Color.Lime;
  665. }
  666. }
  667. #endregion
  668. #region 自动对焦1
  669. private void btnAutoFocus1_Click(object sender, EventArgs e)
  670. {
  671. //抓图1
  672. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  673. if (File.Exists(path + "\\test1.tif"))
  674. {
  675. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  676. pictureBox1.Image = Image.FromStream(fileStream);
  677. fileStream.Close();
  678. fileStream.Dispose();
  679. }
  680. Thread.Sleep(1000);
  681. iSEM.CmdAutoFocusCoarse();
  682. btnAutoFocus1.BackColor = Color.Red;
  683. st_flag = 1;
  684. Thread.Sleep(1000);
  685. Thread thread = new Thread(AutoFunction);
  686. thread.Start();
  687. }
  688. #endregion
  689. #region 自动函数监测线程
  690. private void AutoFunction()
  691. {
  692. float ret = 111;
  693. Boolean state = false;
  694. while(true)
  695. {
  696. Thread.Sleep(1000);
  697. ret = iSEM.GetAutoFunction();
  698. if(ret==0)
  699. {
  700. if (st_flag == 1 && state == true)
  701. {
  702. btnAutoFocus1.BackColor = Color.Lime;
  703. Thread.Sleep(1000);
  704. //抓图1
  705. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  706. if (File.Exists(path + "\\test2.tif"))
  707. {
  708. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  709. pictureBox2.Image = Image.FromStream(fileStream);
  710. fileStream.Close();
  711. fileStream.Dispose();
  712. }
  713. break;
  714. }
  715. else if(st_flag==2 && state)
  716. {
  717. btnAutoFocus2.BackColor = Color.Lime;
  718. Thread.Sleep(1000);
  719. //抓图1
  720. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  721. if (File.Exists(path + "\\test2.tif"))
  722. {
  723. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  724. pictureBox2.Image = Image.FromStream(fileStream);
  725. fileStream.Close();
  726. fileStream.Dispose();
  727. }
  728. break;
  729. }
  730. else if (st_flag == 3)
  731. {
  732. btnAutoBrightness.BackColor = Color.Lime;
  733. Thread.Sleep(1000);
  734. //抓图1
  735. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  736. if (File.Exists(path + "\\test2.tif"))
  737. {
  738. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  739. pictureBox2.Image = Image.FromStream(fileStream);
  740. fileStream.Close();
  741. fileStream.Dispose();
  742. }
  743. break;
  744. }
  745. else if (st_flag == 4)
  746. {
  747. btnAutoContrast.BackColor = Color.Lime;
  748. Thread.Sleep(1000);
  749. //抓图1
  750. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  751. if (File.Exists(path + "\\test2.tif"))
  752. {
  753. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  754. pictureBox2.Image = Image.FromStream(fileStream);
  755. fileStream.Close();
  756. fileStream.Dispose();
  757. }
  758. break;
  759. }
  760. else if (st_flag == 5)
  761. {
  762. btnAutoBrightness.BackColor = Color.Lime;
  763. btnAutoContrast.BackColor = Color.Lime;
  764. btnAutoBC.BackColor = Color.Lime;
  765. Thread.Sleep(1000);
  766. //抓图1
  767. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  768. if (File.Exists(path + "\\test2.tif"))
  769. {
  770. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  771. pictureBox2.Image = Image.FromStream(fileStream);
  772. fileStream.Close();
  773. fileStream.Dispose();
  774. }
  775. break;
  776. }
  777. else if (st_flag == 6 && state)
  778. {
  779. btnAutoBCCancle.BackColor = Color.Lime;
  780. Thread.Sleep(1000);
  781. //抓图1
  782. iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  783. if (File.Exists(path + "\\test2.tif"))
  784. {
  785. FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  786. pictureBox2.Image = Image.FromStream(fileStream);
  787. fileStream.Close();
  788. fileStream.Dispose();
  789. }
  790. break;
  791. }
  792. else if (st_flag == 7 && state)
  793. {
  794. btnAutoStig.BackColor = Color.Lime;
  795. Thread.Sleep(1000);
  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. break;
  806. }
  807. ////抓图1
  808. //iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
  809. //if (File.Exists(path + "\\test2.tif"))
  810. //{
  811. // FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
  812. // pictureBox2.Image = Image.FromStream(fileStream);
  813. // fileStream.Close();
  814. // fileStream.Dispose();
  815. //}
  816. }
  817. else if(ret>0 && ret<12)
  818. {
  819. state = true;
  820. }
  821. }
  822. }
  823. #endregion
  824. #region 自动对焦2
  825. private void btnAutoFocus2_Click(object sender, EventArgs e)
  826. {
  827. //抓图1
  828. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  829. if (File.Exists(path + "\\test1.tif"))
  830. {
  831. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  832. pictureBox1.Image = Image.FromStream(fileStream);
  833. fileStream.Close();
  834. fileStream.Dispose();
  835. }
  836. Thread.Sleep(1000);
  837. iSEM.CmdAutoFocusFine();
  838. btnAutoFocus2.BackColor = Color.Red;
  839. st_flag = 2;
  840. Thread.Sleep(1000);
  841. Thread thread = new Thread(AutoFunction);
  842. thread.Start();
  843. }
  844. #endregion
  845. #region 自动亮度、对比度
  846. private void btnAutoBrightness_Click(object sender, EventArgs e)
  847. {
  848. //抓图1
  849. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  850. if (File.Exists(path + "\\test1.tif"))
  851. {
  852. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  853. pictureBox1.Image = Image.FromStream(fileStream);
  854. fileStream.Close();
  855. fileStream.Dispose();
  856. }
  857. Thread.Sleep(1000);
  858. iSEM.SetAutoVideoBrightness();
  859. btnAutoBrightness.BackColor = Color.Red;
  860. st_flag = 3;
  861. Thread.Sleep(1000);
  862. Thread thread = new Thread(AutoFunction);
  863. thread.Start();
  864. }
  865. private void btnAutoContrast_Click(object sender, EventArgs e)
  866. {
  867. //抓图1
  868. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  869. if (File.Exists(path + "\\test1.tif"))
  870. {
  871. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  872. pictureBox1.Image = Image.FromStream(fileStream);
  873. fileStream.Close();
  874. fileStream.Dispose();
  875. }
  876. Thread.Sleep(1000);
  877. iSEM.SetAutoVideoContrast();
  878. btnAutoContrast.BackColor = Color.Red;
  879. st_flag = 4;
  880. Thread.Sleep(1000);
  881. Thread thread = new Thread(AutoFunction);
  882. thread.Start();
  883. }
  884. private void btnAutoBC_Click(object sender, EventArgs e)
  885. {
  886. //抓图1
  887. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  888. if (File.Exists(path + "\\test1.tif"))
  889. {
  890. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  891. pictureBox1.Image = Image.FromStream(fileStream);
  892. fileStream.Close();
  893. fileStream.Dispose();
  894. }
  895. Thread.Sleep(1000);
  896. iSEM.SetAutoVideoBrightnessAndContrast();
  897. btnAutoBrightness.BackColor = Color.Red;
  898. btnAutoContrast.BackColor = Color.Red;
  899. btnAutoBC.BackColor = Color.Red;
  900. st_flag = 5;
  901. Thread.Sleep(1000);
  902. Thread thread = new Thread(AutoFunction);
  903. thread.Start();
  904. }
  905. private void btnAutoBCCancle_Click(object sender, EventArgs e)
  906. {
  907. iSEM.SetAutoVideoOff();
  908. btnAutoBCCancle.BackColor = Color.Red;
  909. st_flag = 6;
  910. Thread.Sleep(1000);
  911. Thread thread = new Thread(AutoFunction);
  912. thread.Start();
  913. }
  914. #endregion
  915. #region 自动消像散
  916. private void btnAutoStig_Click(object sender, EventArgs e)
  917. {
  918. //抓图1
  919. iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
  920. if (File.Exists(path + "\\test1.tif"))
  921. {
  922. FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
  923. pictureBox1.Image = Image.FromStream(fileStream);
  924. fileStream.Close();
  925. fileStream.Dispose();
  926. }
  927. Thread.Sleep(1000);
  928. iSEM.CmdAutoStig();
  929. btnAutoStig.BackColor = Color.Red;
  930. st_flag = 7;
  931. Thread.Sleep(1000);
  932. Thread thread = new Thread(AutoFunction);
  933. thread.Start();
  934. }
  935. #endregion
  936. #region FIB缩放Get
  937. private void btnFIBMagGet_Click(object sender, EventArgs e)
  938. {
  939. float ret = iSEM.GetFIBMagnification();
  940. if (float.IsNaN(ret))
  941. {
  942. txtFIBMag.Text = "NaN";
  943. txtFIBMag.Enabled = false;
  944. btnFIBMagSet.Enabled = false;
  945. }
  946. else
  947. {
  948. txtFIBMag.Text = ret.ToString();
  949. btnFIBMagSet.Enabled = true;
  950. }
  951. }
  952. #endregion
  953. #region FIB缩放Set
  954. private void btnFIBMagSet_Click(object sender, EventArgs e)
  955. {
  956. float set = 0;
  957. if (float.TryParse(txtFIBMag.Text, out set))
  958. {
  959. iSEM.SetFIBMagnification(set);
  960. }
  961. }
  962. #endregion
  963. #region FIB焦距Get
  964. private void btnFIBWDGet_Click(object sender, EventArgs e)
  965. {
  966. float ret = iSEM.GetFIBObjectivePotential();
  967. if (float.IsNaN(ret))
  968. {
  969. txtFIBWD.Text = "NaN";
  970. txtFIBWD.Enabled = false;
  971. btnFIBWDSet.Enabled = false;
  972. }
  973. else
  974. {
  975. txtFIBWD.Text = ret.ToString();
  976. btnFIBWDSet.Enabled = true;
  977. }
  978. }
  979. #endregion
  980. #region FIB焦距Set
  981. private void btnFIBWDSet_Click(object sender, EventArgs e)
  982. {
  983. float set = 0;
  984. if (float.TryParse(txtFIBWD.Text, out set))
  985. {
  986. iSEM.SetFIBObjectivePotential(set);
  987. }
  988. }
  989. #endregion
  990. #region FIB电子束移动
  991. private void btnFIBBeamShiftXGet_Click(object sender, EventArgs e)
  992. {
  993. float ret = iSEM.GetFIBBeamShiftX();
  994. if (float.IsNaN(ret))
  995. {
  996. txtFIBBeamShiftX.Text = "NaN";
  997. txtFIBBeamShiftX.Enabled = false;
  998. btnFIBBeamShiftXSet.Enabled = false;
  999. }
  1000. else
  1001. {
  1002. txtFIBBeamShiftX.Text = ret.ToString();
  1003. btnFIBBeamShiftXSet.Enabled = true;
  1004. }
  1005. }
  1006. private void btnFIBBeamShiftXSet_Click(object sender, EventArgs e)
  1007. {
  1008. float set = 0;
  1009. if (float.TryParse(txtFIBBeamShiftX.Text, out set))
  1010. {
  1011. iSEM.SetFIBBeamShiftX(set);
  1012. }
  1013. }
  1014. private void btnFIBBeamShiftYGet_Click(object sender, EventArgs e)
  1015. {
  1016. float ret = iSEM.GetFIBBeamShiftY();
  1017. if (float.IsNaN(ret))
  1018. {
  1019. txtFIBBeamShiftY.Text = "NaN";
  1020. txtFIBBeamShiftY.Enabled = false;
  1021. btnFIBBeamShiftYSet.Enabled = false;
  1022. }
  1023. else
  1024. {
  1025. txtFIBBeamShiftY.Text = ret.ToString();
  1026. btnFIBBeamShiftYSet.Enabled = true;
  1027. }
  1028. }
  1029. private void btnFIBBeamShiftYSet_Click(object sender, EventArgs e)
  1030. {
  1031. float set = 0;
  1032. if (float.TryParse(txtFIBBeamShiftY.Text, out set))
  1033. {
  1034. iSEM.SetFIBBeamShiftY(set);
  1035. }
  1036. }
  1037. #endregion
  1038. #region 执行宏文件
  1039. private void btnMCF_Click(object sender, EventArgs e)
  1040. {
  1041. OpenFileDialog sfd = new OpenFileDialog();
  1042. sfd.Title = "选择宏文件:";
  1043. sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
  1044. sfd.Filter = "MLF文件|*.MLF";
  1045. if (sfd.ShowDialog() == DialogResult.OK)
  1046. {
  1047. //string fn = Path.GetFileNameWithoutExtension(sfd.FileName).ToUpper();
  1048. iSEM.SetRemoteMLFPath(@"\\192.168.1.197\wq\");
  1049. iSEM.CMDMCFFilename(sfd.FileName);
  1050. }
  1051. }
  1052. #endregion
  1053. #region FIB消像散
  1054. private void btnFIBAstigmatismXGet_Click(object sender, EventArgs e)
  1055. {
  1056. float ret = iSEM.GetFIBAstigmatismX();
  1057. if (float.IsNaN(ret))
  1058. {
  1059. txtFIBAstigmatismX.Text = "NaN";
  1060. txtFIBAstigmatismX.Enabled = false;
  1061. btnFIBAstigmatismXSet.Enabled = false;
  1062. }
  1063. else
  1064. {
  1065. txtFIBAstigmatismX.Text = ret.ToString();
  1066. btnFIBAstigmatismXSet.Enabled = true;
  1067. }
  1068. }
  1069. private void btnFIBAstigmatismXSet_Click(object sender, EventArgs e)
  1070. {
  1071. float set = 0;
  1072. if (float.TryParse(txtFIBAstigmatismX.Text, out set))
  1073. {
  1074. iSEM.SetFIBAstigmatismX(set);
  1075. }
  1076. }
  1077. private void btnFIBAstigmatismYGet_Click(object sender, EventArgs e)
  1078. {
  1079. float ret = iSEM.GetFIBAstigmatismY();
  1080. if (float.IsNaN(ret))
  1081. {
  1082. txtFIBAstigmatismY.Text = "NaN";
  1083. txtFIBAstigmatismY.Enabled = false;
  1084. btnFIBAstigmatismYSet.Enabled = false;
  1085. }
  1086. else
  1087. {
  1088. txtFIBAstigmatismY.Text = ret.ToString();
  1089. btnFIBAstigmatismYSet.Enabled = true;
  1090. }
  1091. }
  1092. private void btnFIBAstigmatismYSet_Click(object sender, EventArgs e)
  1093. {
  1094. float set = 0;
  1095. if (float.TryParse(txtFIBAstigmatismY.Text, out set))
  1096. {
  1097. iSEM.SetFIBAstigmatismY(set);
  1098. }
  1099. }
  1100. #endregion
  1101. #region 移动样品台XY
  1102. private void btnMoveXY_Click(object sender, EventArgs e)
  1103. {
  1104. float setx = 0;
  1105. float sety = 0;
  1106. if (!float.TryParse(txtStageX.Text, out setx))
  1107. {
  1108. return;
  1109. }
  1110. if(!float.TryParse(txtStageY.Text,out sety))
  1111. {
  1112. return;
  1113. }
  1114. btnMoveXY.BackColor = Color.Red;
  1115. iSEM.MoveStageXY(setx, sety);
  1116. Thread.Sleep(500);
  1117. Thread th = new Thread(MoveStagexy);
  1118. th.Start();
  1119. }
  1120. private void MoveStagexy()
  1121. {
  1122. float ret = 111;
  1123. while(true)
  1124. {
  1125. ret = iSEM.GetStageIs();
  1126. if(ret==0)
  1127. {
  1128. btnMoveXY.BackColor = Color.Lime;
  1129. break;
  1130. }
  1131. }
  1132. }
  1133. #endregion
  1134. #region 获取分辨率
  1135. private void btnImageStoreGet_Click(object sender, EventArgs e)
  1136. {
  1137. int[] ret = iSEM.GetImageStore();
  1138. lblImageStore.Text = ret[0].ToString() + "*" + ret[1].ToString();
  1139. }
  1140. #endregion
  1141. #region 设置分辨率
  1142. private void btnImageStoreSet_Click(object sender, EventArgs e)
  1143. {
  1144. if (cmbImageStore.SelectedIndex > -1 && cmbImageStore.SelectedIndex < 12)
  1145. {
  1146. iSEM.SetImageStore(cmbImageStore.SelectedIndex);
  1147. }
  1148. }
  1149. #endregion
  1150. #region 样品台急停
  1151. private void btnAbort_Click(object sender, EventArgs e)
  1152. {
  1153. iSEM.CmdStageAbort();
  1154. }
  1155. #endregion
  1156. private void btnLive_Click(object sender, EventArgs e)
  1157. {
  1158. iSEM.ImageLive();
  1159. }
  1160. private void btnFrozen_Click(object sender, EventArgs e)
  1161. {
  1162. iSEM.ImageFrozen();
  1163. }
  1164. private void btnExeEly_Click(object sender, EventArgs e)
  1165. {
  1166. OpenFileDialog sfd = new OpenFileDialog();
  1167. sfd.Title = "选择ELY文件:";
  1168. //sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
  1169. sfd.Filter = "ELY文件|*.ELY";
  1170. if (sfd.ShowDialog() == DialogResult.OK)
  1171. {
  1172. iSEM.SetRemoteELYPath(@"\\192.168.1.197\wq\");
  1173. iSEM.CmdFIBLoadELY(sfd.FileName);
  1174. }
  1175. }
  1176. private void btnExeEly2_Click(object sender, EventArgs e)
  1177. {
  1178. iSEM.CmdFIBEXPOSUREELY();
  1179. }
  1180. private void btnFIBStatus_Click(object sender, EventArgs e)
  1181. {
  1182. btnFIBStatus.Text = iSEM.GetFIBMode().ToString();
  1183. }
  1184. private void btnPost1_Click(object sender, EventArgs e)
  1185. {
  1186. float degree = 0;
  1187. int direction = 0;
  1188. int state = 0;
  1189. wr.Img_OffsetAngle_Direction(txtaddr.Text,Convert.ToInt32(txtTypee.Text),txtfirm.Text, out degree, out direction, out state);
  1190. lbldegree1.Text = degree.ToString("0.0");
  1191. lbldirection1.Text = direction.ToString();
  1192. lblstate1.Text = state.ToString();
  1193. }
  1194. private void btnPost2_Click(object sender, EventArgs e)
  1195. {
  1196. float offsetx1 = 0;
  1197. float offsety1 = 0;
  1198. float offsetx2 = 0;
  1199. float offsety2 = 0;
  1200. int state = 0;
  1201. wr.Img_Cut_Position(txtaddr.Text, Convert.ToInt32(txtTypee.Text), txtfirm.Text, out offsetx1, out offsety1, out offsetx2, out offsety2, out state);
  1202. lbllocationx1.Text = offsetx1.ToString("0.0");
  1203. lbllocationy1.Text = offsety1.ToString("0.0");
  1204. lbllocationx2.Text = offsetx2.ToString("0.0");
  1205. lbllocationy2.Text = offsety2.ToString("0.0");
  1206. lblstate2.Text = state.ToString();
  1207. }
  1208. private void btnPost3_Click(object sender, EventArgs e)
  1209. {
  1210. int state = 0;
  1211. wr.Img_Cut_Success(txtaddr.Text, txtaddr2.Text, out state);
  1212. lblstate3.Text = state.ToString();
  1213. }
  1214. private void btnPost4_Click(object sender, EventArgs e)
  1215. {
  1216. float offsetx = 0;
  1217. float offsety = 0;
  1218. int state = 0;
  1219. wr.Img_Trapezoid_Top_Center_Position(txtaddr.Text, out offsetx, out offsety, out state);
  1220. lbltopcx.Text = offsetx.ToString("0.0");
  1221. lbltopcy.Text = offsety.ToString("0.0");
  1222. lblstate4.Text = state.ToString();
  1223. }
  1224. private void btnPost5_Click(object sender, EventArgs e)
  1225. {
  1226. List<string> filenames = new List<string>();
  1227. filenames.Add("1111111");
  1228. filenames.Add("2222222");
  1229. filenames.Add("3333333");
  1230. lblfocuspath.Text = wr.Img_Auto_Focus(filenames);
  1231. }
  1232. private void btnPost6_Click(object sender, EventArgs e)
  1233. {
  1234. List<string> filenames = new List<string>();
  1235. filenames.Add("1111111");
  1236. filenames.Add("2222222");
  1237. filenames.Add("3333333");
  1238. lblstigpath.Text = wr.Img_Auto_Focus(filenames);
  1239. }
  1240. private void btnPost7_Click(object sender, EventArgs e)
  1241. {
  1242. float degree = 0;
  1243. int direction = 0;
  1244. int state = 0;
  1245. //wr.Img_Center_Position_OffsetAngle_Direction(txtaddr.Text, out degree, out direction, out state);
  1246. //lblcenterx.Text = offsetx.ToString("0.0");
  1247. //lblcentery.Text = offsety.ToString("0.0");
  1248. lbldegree2.Text = degree.ToString();
  1249. lbldirection2.Text = direction.ToString();
  1250. lblstate7.Text = state.ToString();
  1251. }
  1252. private void btnPost9_Click(object sender, EventArgs e)
  1253. {
  1254. int state = 0;
  1255. wr.Img_Measure_Size(txtaddr.Text, txtaddr2.Text,0.000001f,0.000002f,"D:\\", Convert.ToInt32(txtTypee.Text), txtfirm.Text,out state);
  1256. lblstate9.Text = state.ToString();
  1257. }
  1258. private void btnScanRotationSetLock_Click(object sender, EventArgs e)
  1259. {
  1260. iSEM.SetScanRotationOff();
  1261. }
  1262. private void button1_Click_1(object sender, EventArgs e)
  1263. {
  1264. iSEM.SetTiltAngleOff();
  1265. }
  1266. private void btnTiltAngleSetOn_Click(object sender, EventArgs e)
  1267. {
  1268. iSEM.SetTiltAngleOn();
  1269. }
  1270. private void btnScanRotationSetOn_Click(object sender, EventArgs e)
  1271. {
  1272. iSEM.SetScanRotationOn();
  1273. }
  1274. private void btnExeEly3_Click(object sender, EventArgs e)
  1275. {
  1276. iSEM.CmdFIBSTARTELY();
  1277. }
  1278. private void btnCreateConfig_Click(object sender, EventArgs e)
  1279. {
  1280. MeasureParam cfm = new MeasureParam();
  1281. cfm.Is_Photograph = chkWIsP.Checked;
  1282. cfm.PT = chkWPT.Checked;
  1283. cfm.PTTemp = txtWPTF.Text;
  1284. cfm.FIBTemp = txtWFIBF.Text;
  1285. cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
  1286. cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
  1287. cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
  1288. cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
  1289. cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
  1290. if(cbbWXZ.SelectedIndex==0)
  1291. {
  1292. cfm.Correction_Angle = 36;
  1293. }
  1294. else
  1295. {
  1296. cfm.Correction_Angle = 54;
  1297. }
  1298. cfm.SampleName = cbbWYP.Text;
  1299. cfm.Firm = cbbWCS.Text;
  1300. ConfigFile cf = new ConfigFile(cfm);
  1301. cf.Save(@"E:\test.cfg");
  1302. List<String> _sT = sT.ToList();
  1303. if(_sT.IndexOf(cbbWYP.Text)<0)
  1304. {
  1305. _sT.Add(cbbWYP.Text);
  1306. sT = _sT.ToArray();
  1307. string wsT = "";
  1308. for(int i=0;i<sT.Length;i++)
  1309. {
  1310. wsT += sT[i] + ",";
  1311. }
  1312. wsT = wsT.Substring(0, wsT.Length - 1);
  1313. config.AppSettings.Settings["Sample_Type"].Value = wsT;
  1314. }
  1315. List<String> _firms = firms.ToList();
  1316. if (_firms.IndexOf(cbbWCS.Text) < 0)
  1317. {
  1318. _firms.Add(cbbWCS.Text);
  1319. firms = _firms.ToArray();
  1320. string wFirms = "";
  1321. for (int i = 0; i < firms.Length; i++)
  1322. {
  1323. wFirms += firms[i] + ",";
  1324. }
  1325. wFirms = wFirms.Substring(0, wFirms.Length - 1);
  1326. config.AppSettings.Settings["Firm"].Value = wFirms;
  1327. }
  1328. config.Save(ConfigurationSaveMode.Modified);
  1329. ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
  1330. reloadconfig();
  1331. }
  1332. private void btnReadConfig_Click(object sender, EventArgs e)
  1333. {
  1334. MeasureParam cfm = new MeasureParam();
  1335. ConfigFile cf = new ConfigFile(cfm);
  1336. cf.Read(@"E:\test.cfg");
  1337. chkRIsP.Checked = cfm.Is_Photograph;
  1338. chkRPT.Checked = cfm.PT;
  1339. txtRPTF.Text = cfm.PTTemp;
  1340. txtRFIBF.Text = cfm.FIBTemp;
  1341. txtRLZ.Text = cfm.Stretch_Magnification.ToString();
  1342. txtRQGF.Text = cfm.Location_Magnification.ToString();
  1343. txtRQGD.Text = cfm.Location_Voltage.ToString();
  1344. txtRPZF.Text = cfm.Photograph_Magnification.ToString();
  1345. txtRPZD.Text = cfm.Photograph_Voltage.ToString();
  1346. txtRXZ.Text = cfm.Correction_Angle.ToString();
  1347. txtRYP.Text = cfm.SampleName;
  1348. txtRCS.Text = cfm.Firm;
  1349. }
  1350. private void FormUnitControl_Load(object sender, EventArgs e)
  1351. {
  1352. reloadconfig();
  1353. cbbWYP.SelectedIndex = 0;
  1354. cbbWCS.SelectedIndex = 0;
  1355. cbbWXZ.SelectedIndex = 0;
  1356. this.chart1.Series[0].Points.Clear();
  1357. }
  1358. private void reloadconfig()
  1359. {
  1360. String sample_Type = ConfigurationManager.AppSettings["Sample_Type"];
  1361. String firm = ConfigurationManager.AppSettings["Firm"];
  1362. sT = sample_Type.Split(',');
  1363. cbbWYP.Items.Clear();
  1364. for (int i = 0; i < sT.Length; i++)
  1365. {
  1366. cbbWYP.Items.Add(sT[i]);
  1367. }
  1368. firms = firm.Split(',');
  1369. cbbWCS.Items.Clear();
  1370. for (int i = 0; i < firms.Length; i++)
  1371. {
  1372. cbbWCS.Items.Add(firms[i]);
  1373. }
  1374. }
  1375. private void btnPsFile_Click(object sender, EventArgs e)
  1376. {
  1377. OpenFileDialog sfd = new OpenFileDialog();
  1378. sfd.Title = "选择位置文件:";
  1379. //sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
  1380. sfd.Filter = "TXT文件|*.TXT";
  1381. if (sfd.ShowDialog() == DialogResult.OK)
  1382. {
  1383. //Console.WriteLine(sfd.FileName);
  1384. StreamReader sr = new StreamReader(sfd.FileName, Encoding.Default);
  1385. String line = "";
  1386. sr.ReadLine();
  1387. sr.ReadLine();
  1388. sr.ReadLine();
  1389. sr.ReadLine();
  1390. line = sr.ReadLine();
  1391. sr.Close();
  1392. sr.Dispose();
  1393. String[] lines = line.Split(',');
  1394. double x = Convert.ToDouble(lines[1]);
  1395. double y = Convert.ToDouble(lines[2]);
  1396. chart1.Series[0].Points.AddXY(x, y);
  1397. chart1.Series[0].Points[0].Label = x.ToString("0.000") + "," + y.ToString("0.000");
  1398. }
  1399. }
  1400. private void btnrect_Click(object sender, EventArgs e)
  1401. {
  1402. this.chart1.Series[0].Points.Clear();
  1403. List<double> xpoints = new List<double>();
  1404. List<double> ypoints = new List<double>();
  1405. //排列数
  1406. int rag = Convert.ToInt32(txtarray.Text);
  1407. //间距
  1408. float dist = Convert.ToSingle(txtdistance.Text);
  1409. //中心点x,y轴坐标
  1410. float cx = Convert.ToSingle(txtx.Text);
  1411. float cy = Convert.ToSingle(txty.Text);
  1412. //所有点集合
  1413. List<PointF> ptfs = new List<PointF>();
  1414. ptfs = AnalysisPosition(cx, cy, Convert.ToSingle(txtsample1x.Text),
  1415. Convert.ToSingle(txtsample1y.Text), dist, rag);
  1416. for(int i=0;i<ptfs.Count;i++)
  1417. {
  1418. chart1.Series[0].Points.AddXY(ptfs[i].X, ptfs[i].Y);
  1419. chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = ptfs[i].X.ToString("0.000") + "," + ptfs[i].Y.ToString("0.000");
  1420. }
  1421. ////求样品1的水平角度
  1422. //double angle = 0;
  1423. ////xpoints.Add(Math.Pow(Math.Pow(Convert.ToDouble(txtx.Text), 2) + Math.Pow(Convert.ToDouble(txty.Text), 2), 0.5));
  1424. ////ypoints.Add(Math.Pow(Math.Pow(Convert.ToDouble(txtx.Text), 2) + Math.Pow(Convert.ToDouble(txty.Text), 2), 0.5));
  1425. //xpoints.Add(Convert.ToDouble(txtsample1x.Text));
  1426. //ypoints.Add(Convert.ToDouble(txtsample1y.Text));
  1427. ////计算第一个点与X轴的交角度数
  1428. //angle = Math.Atan2(ypoints[0] - cy, cx - xpoints[0]) * 180 / Math.PI;
  1429. //lblPs1.Text = angle.ToString("0.0");
  1430. ////这里是求与第一个点横向排列的其他点的移动角度
  1431. ////就是按45度向左向右移动的度
  1432. //angle = 45 - angle;
  1433. //angle = angle * Math.PI / 180;
  1434. //txtsample1x.Text = xpoints[0].ToString("0.000");
  1435. //txtsample1y.Text = ypoints[0].ToString("0.000");
  1436. //chart1.Series[0].Points.AddXY(xpoints[0], ypoints[0]);
  1437. //chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = xpoints[0].ToString("0.000") + "," + ypoints[0].ToString("0.000");
  1438. //double tx = 0;
  1439. //double ty = 0;
  1440. //for (int j = 0; j < rag; j++)
  1441. //{
  1442. // //计算每行第一个点的坐标
  1443. // if(j>0)
  1444. // {
  1445. // tx = dist * j * Math.Sin(angle);
  1446. // ty = dist * j * Math.Cos(angle);
  1447. // xpoints.Add(tx + xpoints[0]);
  1448. // ypoints.Add(ypoints[0] - ty);
  1449. // chart1.Series[0].Points.AddXY(xpoints[xpoints.Count-1], ypoints[ypoints.Count-1]);
  1450. // chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = xpoints[xpoints.Count - 1].ToString("0.000") + "," + ypoints[ypoints.Count - 1].ToString("0.000");
  1451. // }
  1452. // //计算每行其他点的坐标
  1453. // for (int i = 1; i < rag; i++)
  1454. // {
  1455. // tx = dist * i * Math.Cos(angle);
  1456. // ty = dist * i * Math.Sin(angle);
  1457. // xpoints.Add(tx + xpoints[j * rag]);
  1458. // ypoints.Add(ty + ypoints[j * rag]);
  1459. // chart1.Series[0].Points.AddXY(xpoints[xpoints.Count - 1], ypoints[ypoints.Count - 1]);
  1460. // chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = xpoints[xpoints.Count - 1].ToString("0.000") + "," + ypoints[ypoints.Count - 1].ToString("0.000");
  1461. // }
  1462. //}
  1463. }
  1464. /// <summary>
  1465. /// 分析点坐标
  1466. /// </summary>
  1467. /// <param name="centerX">中心点X轴坐标</param>
  1468. /// <param name="centerY">中心点Y轴坐标</param>
  1469. /// <param name="firstX">第一个点X轴坐标</param>
  1470. /// <param name="firstY">第一个点Y轴坐标</param>
  1471. /// <param name="distance">点与点的距离</param>
  1472. /// <param name="rag">行、列数</param>
  1473. /// <param name="ptsx">计算生成所有X轴坐标</param>
  1474. /// <param name="ptsy">计算生成所有Y轴坐标</param>
  1475. public List<PointF> AnalysisPosition(float centerX, float centerY, float firstX, float firstY, float distance, int rag)
  1476. {
  1477. //求样品1的水平角度
  1478. double angle = 0;
  1479. //清空所有点信息
  1480. List<float> ptsx = new List<float>();
  1481. List<float> ptsy = new List<float>();
  1482. //将第一个点加入到点信息中
  1483. ptsx.Add(firstX);
  1484. ptsy.Add(firstY);
  1485. //计算第一个点与X轴的交角度数
  1486. angle = Math.Atan2(ptsy[0] - centerY, centerX - ptsx[0]) * 180 / Math.PI;
  1487. //这里是求与第一个点横向排列的其他点的移动角度
  1488. //就是按45度向左向右移动的度
  1489. angle = 45 - angle;
  1490. angle = angle * Math.PI / 180;
  1491. float tx = 0;
  1492. float ty = 0;
  1493. for (int j = 0; j < rag; j++)
  1494. {
  1495. //计算每行第一个点的坐标
  1496. if (j > 0)
  1497. {
  1498. tx = (float)(distance * j * Math.Sin(angle));
  1499. ty = (float)(distance * j * Math.Cos(angle));
  1500. ptsx.Add(tx + ptsx[0]);
  1501. ptsy.Add(ptsy[0] - ty);
  1502. }
  1503. //计算每行其他点的坐标
  1504. for (int i = 1; i < rag; i++)
  1505. {
  1506. tx = (float)(distance * i * Math.Cos(angle));
  1507. ty = (float)(distance * i * Math.Sin(angle));
  1508. ptsx.Add(tx + ptsx[j * rag]);
  1509. ptsy.Add(ty + ptsy[j * rag]);
  1510. }
  1511. }
  1512. List<PointF> pts = new List<PointF>();
  1513. for (int i = 0; i < ptsx.Count; i++)
  1514. {
  1515. //增加的点
  1516. PointF pf = new PointF();
  1517. pf.X = ptsx[i];
  1518. pf.Y = ptsy[i];
  1519. pts.Add(pf);
  1520. }
  1521. return pts;
  1522. }
  1523. private void btn30_Click(object sender, EventArgs e)
  1524. {
  1525. txtsample1x.Text = "21.7";
  1526. txtsample1y.Text = "90";
  1527. btnrect_Click(null, null);
  1528. }
  1529. private void btn45_Click(object sender, EventArgs e)
  1530. {
  1531. txtsample1x.Text = "29.65";
  1532. txtsample1y.Text = "100.35";
  1533. btnrect_Click(null, null);
  1534. }
  1535. private void btn60_Click(object sender, EventArgs e)
  1536. {
  1537. txtsample1x.Text = "40";
  1538. txtsample1y.Text = "108.3";
  1539. btnrect_Click(null, null);
  1540. }
  1541. private void button2_Click(object sender, EventArgs e)
  1542. {
  1543. float ret = iSEM.GetSEMVoltage();
  1544. if (float.IsNaN(ret))
  1545. {
  1546. txtVoltage.Text = "NaN";
  1547. txtVoltage.Enabled = false;
  1548. button2.Enabled = false;
  1549. }
  1550. else
  1551. {
  1552. txtVoltage.Text = ret.ToString();
  1553. button2.Enabled = true;
  1554. }
  1555. }
  1556. private void button1_Click(object sender, EventArgs e)
  1557. {
  1558. float set = 0;
  1559. if (float.TryParse(txtVoltage.Text, out set))
  1560. {
  1561. iSEM.SetSEMVoltage(set);
  1562. }
  1563. }
  1564. /// 图像拉直算法
  1565. /// </summary>
  1566. /// <param name="Slope">倾斜角度</param>
  1567. /// <param name="x0">圆心坐标x</param>
  1568. /// <param name="y0">圆心坐标y</param>
  1569. /// <param name="x1">倾斜情况下帧图的坐标x</param>
  1570. /// <param name="y1">倾斜情况下帧图的坐标y</param>
  1571. /// <param name="Hx">复位到原位置需要移动的x值(返回值)</param>
  1572. /// <param name="Hy">复位到原位置需要移动的y值(返回值)</param>
  1573. /// <returns></returns>
  1574. public bool Straightening(float Slope, float x0, float y0, float x1, float y1, ref float Hx, ref float Hy)
  1575. {
  1576. try
  1577. {
  1578. float xr = x1 - x0;//倾斜图到中心的距离差x
  1579. float yr = y1 - y0;//倾斜图到中心的距离差y
  1580. float R =(float)Math.Sqrt(xr * xr + yr * yr);//圆心到倾斜图的长度
  1581. //double D = 2 * R * Math.Sin(ScanRotation / 2);//倾斜图与矫正图底边的长度
  1582. float k = (float)(Math.Atan(yr / xr) / Math.PI * 180);//x1,y1的直角三角形圆心角度
  1583. float k_S = k - Slope;//通过夹角差求x2,y2
  1584. //int y2 = (int)Math.Round(Math.Sin(Math.PI / (180 / k_S)) * R);
  1585. //int x2 = (int)Math.Round(Math.Cos(Math.PI / (180 / k_S)) * R);
  1586. float y2 = (float)(Math.Sin(Math.PI / (180 / k_S)) * R);
  1587. float x2 = (float)(Math.Cos(Math.PI / (180 / k_S)) * R);
  1588. if (Slope > 0 || Slope < 0)
  1589. {
  1590. Hx = x0 + x2;
  1591. Hy = y0 + y2;
  1592. }
  1593. else
  1594. {
  1595. Hx = 0;
  1596. Hy = 0;
  1597. }
  1598. return true;
  1599. }
  1600. catch (Exception)
  1601. {
  1602. return false;
  1603. }
  1604. }
  1605. private void button3_Click(object sender, EventArgs e)
  1606. {
  1607. float x1 = 0, y1 = 0;
  1608. Straightening(45, 48.156f, 49.968f, (float)31.679, (float)58.870, ref x1, ref y1);
  1609. button3.Text = x1.ToString("0.00") + "\n" + y1.ToString("0.00");
  1610. }
  1611. private void btntest_Click(object sender, EventArgs e)
  1612. {
  1613. //FileStream fs = new FileStream(txtaddr.Text, FileMode.Create, FileAccess.Write);
  1614. //StreamWriter sw = new StreamWriter(fs);
  1615. //sw.WriteLine("aaaa");
  1616. //sw.Close();
  1617. //sw.Dispose();
  1618. //fs.Close();
  1619. //fs.Dispose();
  1620. File.Copy(txtaddr2.Text, txtaddr.Text, true);
  1621. }
  1622. private void button4_Click(object sender, EventArgs e)
  1623. {
  1624. iSEM.SetWorkingDistance(0.006f);
  1625. Thread.Sleep(8000);
  1626. iSEM.GrabImage("D:\\HOZ1.0\\6.tif", 0, 0, 1024, 768, 0);
  1627. Thread.Sleep(3000);
  1628. iSEM.SetWorkingDistance(0.007f);
  1629. Thread.Sleep(8000);
  1630. iSEM.GrabImage("D:\\HOZ1.0\\7.tif", 0, 0, 1024, 768, 0);
  1631. Thread.Sleep(3000);
  1632. iSEM.SetWorkingDistance(0.0073f);
  1633. Thread.Sleep(8000);
  1634. iSEM.GrabImage("D:\\HOZ1.0\\73.tif", 0, 0, 1024, 768, 0);
  1635. Thread.Sleep(3000);
  1636. }
  1637. //移动到像素位置
  1638. bool MoveToPix(float sx,float sy,float xc, float yc,float ps,out float nx,out float ny)
  1639. {
  1640. int width = 1024/2;
  1641. int height = 768/2;
  1642. float deltX = (xc - (float)width) * ps;
  1643. float deltY = (yc - (float)height) * ps;
  1644. float xpCur = sx;
  1645. float ypCur = sy;
  1646. float xpNew = xpCur - deltX;
  1647. float ypNew = ypCur - deltY;
  1648. nx = xpNew;
  1649. ny = ypNew;
  1650. //if (deltX > 10)//使用移动样品台实现
  1651. //{
  1652. // if (!iSEM.SetStageGotoX(xpNew))
  1653. // {
  1654. // return false;
  1655. // }
  1656. // //判断是否移动完成
  1657. // while (true)
  1658. // {
  1659. // Thread.Sleep(5000);
  1660. // if (iSEM.GetStageIs() == 0)
  1661. // {
  1662. // break;
  1663. // }
  1664. // }
  1665. // //arg.Message = "移动到新x" + xpNew.ToString() + "位置失败";
  1666. // //arg.State = true;
  1667. // //SendMsg("1-7");
  1668. //}
  1669. //else//使用移动光束实现
  1670. //{
  1671. // float beamX = deltX * (float)0.66;
  1672. // if (!iSEM.SetBeamShiftX(beamX))
  1673. // {
  1674. // return false;
  1675. // }
  1676. //}
  1677. //if (deltY > 10)//使用移动样品台实现
  1678. //{
  1679. // if (!iSEM.SetStageGotoY(ypNew))
  1680. // {
  1681. // return false;
  1682. // }
  1683. // //判断是否移动完成
  1684. // while (true)
  1685. // {
  1686. // Thread.Sleep(5000);
  1687. // if (iSEM.GetStageIs() == 0)
  1688. // {
  1689. // break;
  1690. // }
  1691. // }
  1692. //}
  1693. //else//使用移动光束实现
  1694. //{
  1695. // float beamY = deltY * (float)0.671;
  1696. // if (!iSEM.SetBeamShiftY(beamY))
  1697. // {
  1698. // return false;
  1699. // }
  1700. //}
  1701. return true;
  1702. }
  1703. private void btnimgv_Click(object sender, EventArgs e)
  1704. {
  1705. float sx = 0, sy = 0;
  1706. float x1 = 0, y1 = 0;
  1707. float nx = 0, ny = 0;
  1708. float ps = 0;
  1709. sx = Convert.ToSingle(txtstagenx.Text);
  1710. sy = Convert.ToSingle(txtstageny.Text);
  1711. x1 = Convert.ToSingle(txtimgx.Text);
  1712. y1 = Convert.ToSingle(txtimgy.Text);
  1713. ps = Convert.ToSingle(txtps.Text);
  1714. MoveToPix(sx,sy,x1, y1, ps,out nx,out ny);
  1715. txtstagevx.Text = nx.ToString("0.000000");
  1716. txtstagevy.Text = ny.ToString("0.000000");
  1717. }
  1718. private void btnPost8_Click(object sender, EventArgs e)
  1719. {
  1720. System.Drawing.Point pt1, pt2;
  1721. float mag1 = 0, mag2 = 0;
  1722. int state = 0;
  1723. //wr.Img_Two_Region_Position(txtaddr.Text, Convert.ToInt32(txtTypee.Text), txtfirm.Text, out pt1, out mag1, out pt2, out mag2, out state);
  1724. //if(state==1)
  1725. //{
  1726. // lblcenter1.Text = pt1.X.ToString() + "," + pt1.Y.ToString();
  1727. // lblcenter2.Text = pt2.X.ToString() + "," + pt2.Y.ToString();
  1728. // lblMag1.Text = mag1.ToString();
  1729. // lblMag2.Text = mag2.ToString();
  1730. // lblstate8.Text = state.ToString();
  1731. //}
  1732. //else
  1733. //{
  1734. // lblstate8.Text = "0";
  1735. // lblcenter1.Text = "";
  1736. // lblcenter2.Text = "";
  1737. // lblMag1.Text = "";
  1738. // lblMag2.Text = "";
  1739. //}
  1740. }
  1741. List<List<Segment>> listFeature = new List<List<Segment>>();
  1742. private void btnEDS_Click(object sender, EventArgs e)
  1743. {
  1744. List<System.Drawing.Point> listPoints = new List<System.Drawing.Point>();
  1745. int state = 0;
  1746. //wr.EDS_Param("aaaaa", out listPoints, out listFeature, out state);
  1747. lblEDS.Text = state.ToString();
  1748. if (state == 1)
  1749. {
  1750. listbPoints.Items.Clear();
  1751. foreach (Point pt in listPoints)
  1752. {
  1753. listbPoints.Items.Add(pt.X.ToString() + "," + pt.Y.ToString());
  1754. }
  1755. listbAreas.Items.Clear();
  1756. listbArea.Items.Clear();
  1757. int i = 1;
  1758. foreach (List<Segment> ls in listFeature)
  1759. {
  1760. listbAreas.Items.Add("第" + i.ToString() + "个面");
  1761. i++;
  1762. }
  1763. if (listbAreas.Items.Count > 0)
  1764. {
  1765. listbAreas.SelectedIndex = 0;
  1766. //List<Segment> listSegment = new List<Segment>();
  1767. //listSegment = listFeature[0];
  1768. //foreach (Segment sm in listSegment)
  1769. //{
  1770. // listbArea.Items.Add(sm.X.ToString() + "," + sm.Y.ToString() + "," + sm.Length.ToString());
  1771. //}
  1772. }
  1773. }
  1774. }
  1775. private void listbAreas_SelectedIndexChanged(object sender, EventArgs e)
  1776. {
  1777. try
  1778. {
  1779. listbArea.Items.Clear();
  1780. List<Segment> listSegment = new List<Segment>();
  1781. listSegment = listFeature[listbAreas.SelectedIndex];
  1782. foreach (Segment sm in listSegment)
  1783. {
  1784. listbArea.Items.Add(sm.X.ToString() + "," + sm.Y.ToString() + "," + sm.Length.ToString());
  1785. }
  1786. }
  1787. catch { }
  1788. }
  1789. }
  1790. }