ControllerSettingForm.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.Xml;
  5. using System.IO;
  6. using System.Windows.Forms.DataVisualization.Charting;
  7. using System.Threading;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using OTSCLRINTERFACE;
  11. using OTSModelSharp.ServiceCenter;
  12. namespace OTSSysMgrApp
  13. {
  14. public partial class ControllerSettingForm : Form
  15. {
  16. #region 全部变量声明
  17. RecommendedConfiguration recommendedConfiguration;
  18. //连接状态
  19. bool ConnectionState = false;
  20. static string xmlFilePath = System.Configuration.ConfigurationManager.ConnectionStrings["XMLFilePath"].ConnectionString;
  21. //日志路径
  22. static string LogPath = System.Configuration.ConfigurationManager.ConnectionStrings["LogPath"].ConnectionString;
  23. static NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  24. IEDSController m_EDSHardwareMgr = null;
  25. //图片
  26. Bitmap bitmap = null;
  27. //国际化
  28. Language lan;
  29. //国际化存储信息
  30. Hashtable table;
  31. #endregion
  32. public enum connectionEnumType
  33. {
  34. EDSOnlyPointXRay = 0,
  35. EDSMultiPointXRay = 1,
  36. EDSAreaXRay = 2,
  37. ScanImage = 3
  38. }
  39. #region 构造函数
  40. public ControllerSettingForm()
  41. {
  42. InitializeComponent();
  43. m_EDSHardwareMgr = EDSController.GetEDSController(Convert.ToInt32(tbRWidth.Text), Convert.ToInt32(tbRHeight.Text), 5000);
  44. lan = new Language(this);
  45. table = lan.GetNameTable(this.Name);
  46. }
  47. /// <summary>
  48. /// 连接电镜
  49. /// </summary>
  50. /// <param name="connectionType"></param>
  51. public bool ConnectionSem(connectionEnumType connectionType)
  52. {
  53. //连接电镜标识
  54. bool DisConnResult = false;
  55. //判断连接状态
  56. if (!ConnectionState)
  57. {
  58. //连接电镜设置
  59. DisConnResult = m_EDSHardwareMgr.Init();
  60. }
  61. if (DisConnResult)
  62. {
  63. ConnectionState = true;
  64. }
  65. else
  66. {
  67. ConnectionState = false;
  68. }
  69. return DisConnResult;
  70. }
  71. /// <summary>
  72. /// EDS初始化
  73. /// </summary>
  74. public bool EDSInit()
  75. {
  76. bool initResult = false;
  77. //线程调用 加载
  78. initResult = m_EDSHardwareMgr.Init();
  79. return initResult;
  80. }
  81. #endregion
  82. #region 窗体中控件事件汇总
  83. private void btnClearXRay_Click(object sender, EventArgs e)
  84. {
  85. chartXRay.Series.RemoveAt(0);
  86. }
  87. private void btnCollectionTime_Click(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. int CollectionTime = 0;
  92. //判断是否为空与类型
  93. if (!IsNull(tbCollectionTime))
  94. {
  95. tbCollectionTime.Focus();
  96. return;
  97. }
  98. if (!IsType(tbCollectionTime.Text, 1))
  99. {
  100. tbCollectionTime.Focus();
  101. return;
  102. }
  103. //获取参数与设置参数
  104. CollectionTime = Convert.ToInt32(tbCollectionTime.Text);
  105. bool result = false;
  106. if (result)
  107. {
  108. //配置结果提示
  109. ShowMessage(3);
  110. }
  111. else
  112. {
  113. ShowMessage(4);
  114. }
  115. }
  116. catch (Exception ex)
  117. {
  118. //记录日志信息(异常日志)
  119. log.Error(ex.Message.ToString());
  120. }
  121. }
  122. private void ControllerSettingForm_Load(object sender, EventArgs e)
  123. {
  124. //设置窗体图表
  125. Control.CheckForIllegalCrossThreadCalls = false;
  126. ddlDwellTime.SelectedIndex = 0;
  127. InitXRayData();
  128. int width = Convert.ToInt32(tbRWidth.Text);
  129. int height = Convert.ToInt32(tbRHeight.Text);
  130. m_EDSHardwareMgr = EDSController.GetEDSController(width, height, 5000);
  131. cb_Xdirection.Items.Add("LEFT_TOWARD");
  132. cb_Xdirection.Items.Add("RIGHT_TOWARD");
  133. cb_Ydirection.Items.Add("UP_TOWARD");
  134. cb_Ydirection.Items.Add("DOWN_TOWARD");
  135. tB_scanFieldSize100.Text = "1270";
  136. cb_imageresolution.Items.Add("1024*768");
  137. cb_imageresolution.Items.Add("1024*704");
  138. cb_imageresolution.Items.Add("1536*1024");
  139. string xmlpath = Application.StartupPath + @"\Config\SysData\OTSProgMgrParam.pmf";
  140. string xAxisDir = "";
  141. string yAxisDir = "";
  142. string scanFieldSize = "";
  143. ReadConfigXml(xmlpath, ref xAxisDir, ref yAxisDir, ref scanFieldSize);
  144. if (xAxisDir.Split(':')[1] == "LEFT_TOWARD")
  145. {
  146. cb_Xdirection.SelectedIndex = 0;
  147. }
  148. else
  149. {
  150. cb_Xdirection.SelectedIndex = 1;
  151. }
  152. if (yAxisDir.Split(':')[1] == "UP_TOWARD")
  153. {
  154. cb_Ydirection.SelectedIndex = 0;
  155. }
  156. else
  157. {
  158. cb_Ydirection.SelectedIndex = 1;
  159. }
  160. tB_scanFieldSize100.Text = scanFieldSize;
  161. cb_imageresolution.SelectedIndex = 0;
  162. }
  163. Thread ScanThread = null;
  164. private void btnDisplay_Click(object sender, EventArgs e)
  165. {
  166. GetBSEDisplay();
  167. }
  168. private bool GetScanImage(int iWidth, int iHeigh, string DwellTime, ref byte[] bImageData)
  169. {
  170. //电镜设置对象
  171. var scan = ScanController.GetScanController();
  172. int GetImgCount = 0;
  173. try
  174. {
  175. //连接电镜
  176. bool IsConnec = scan.Init();
  177. if (!IsConnec)
  178. {
  179. return false;
  180. }
  181. #region 设置图像分辨率
  182. //设置宽度
  183. if (!scan.SetImageSize(iWidth, iHeigh))
  184. {
  185. return false;
  186. }
  187. #endregion
  188. #region 采集时间
  189. //采集时间
  190. int nDwellTime = Convert.ToInt32(DwellTime);
  191. //设置采集时间
  192. if (!scan.SetDwellTime(nDwellTime))
  193. {
  194. return false;
  195. }
  196. #endregion
  197. int resultCount = iWidth * iHeigh;
  198. var img = scan.AcquireBSEImage();
  199. bImageData = img.GetImageDataPtr();
  200. }
  201. catch (Exception ex)
  202. {
  203. NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString());
  204. return false;
  205. }
  206. return true;
  207. }
  208. protected void GetBSEDisplay()
  209. {
  210. try
  211. {
  212. string str1 = table["str1"].ToString();
  213. btnDisplay.Text = str1;
  214. btnDisplay.Enabled = false;
  215. btnDisplay.Refresh();
  216. if (pbImage.Image != null)
  217. {
  218. pbImage.Image = null;
  219. pbImage.Refresh();
  220. }
  221. Thread.Sleep(100);
  222. //设置图像分辨率
  223. int width = 0;
  224. int height = 0;
  225. //获取宽度
  226. width = Convert.ToInt32(tbRWidth.Text);
  227. height = Convert.ToInt32(tbRHeight.Text);
  228. byte[] ImageByte = new byte[width * height];
  229. Bitmap bitmap = null;
  230. int iWidth = Convert.ToInt32(tbRWidth.Text);
  231. int iHeight = Convert.ToInt32(tbRHeight.Text);
  232. bool resultValue = GetScanImage(iWidth, iHeight, ddlDwellTime.Text, ref ImageByte);
  233. string str2 = table["str2"].ToString();
  234. if (resultValue )
  235. {
  236. if (ImageByte != null)
  237. {
  238. bitmap = CImageHandler.ToGrayBitmap(ImageByte, width, height);
  239. pbImage.Image = bitmap;
  240. btnSaveImage.Enabled = true;
  241. log.Info("Image capture success!\nImage resolution:" + tbRWidth.Text + "X" + tbRHeight.Text + ";");
  242. }
  243. else
  244. {
  245. MessageBox.Show(str2, "Tip");
  246. }
  247. }
  248. else
  249. {
  250. MessageBox.Show(str2, "Tip");
  251. }
  252. }
  253. catch (Exception ex)
  254. {
  255. log.Error("ControllerSettingForm_btnDisplay_Click--错误信息:" + ex.ToString());
  256. }
  257. finally
  258. {
  259. string str = table["btndisplay"].ToString();
  260. btnDisplay.Text = str;
  261. btnDisplay.Enabled = true;
  262. btnDisplay.Refresh();
  263. }
  264. }
  265. private void btnClear_Click(object sender, EventArgs e)
  266. {
  267. pbImage.BackgroundImage = null;
  268. }
  269. Thread EDSThread = null;
  270. private void btnDisplayXRay_Click(object sender, EventArgs e)
  271. {
  272. try
  273. {
  274. string str1 = table["str1"].ToString();
  275. btnDisplayXRay.Text = str1;
  276. btnDisplayXRay.Enabled = false;
  277. btnDisplayXRay.Refresh();
  278. btnPointXRay.Enabled = false;
  279. btnPointXRay.Refresh();
  280. btnAreaRay.Enabled = false;
  281. btnAreaRay.Refresh();
  282. btnClearData.Enabled = false;
  283. btnClearData.Refresh();
  284. InitXRayData();
  285. if (ConnectionSem(connectionEnumType.EDSOnlyPointXRay))
  286. {
  287. if (EDSInit())
  288. {
  289. //图像数据
  290. uint[] a_XrayData = new uint[2000];
  291. uint a_Milliseconds = 0;
  292. //采集时间
  293. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  294. //采集XRay数据
  295. bool result = m_EDSHardwareMgr.CollectSpectrum(a_Milliseconds, ref a_XrayData);
  296. if (!result)
  297. {
  298. log.Info("CollectSpectrum failed!");
  299. }
  300. int[] XData = new int[2000];
  301. uint nXrayCount = 0;
  302. for (int i = 1; i <= 2000; i++)
  303. {
  304. XData[i - 1] = i;
  305. nXrayCount += a_XrayData[i - 1];
  306. }
  307. //绑定数据源
  308. chartData(XData, a_XrayData);
  309. //显示Xray计数
  310. lbXrayCount.Text = nXrayCount.ToString();
  311. }
  312. }
  313. log.Info("Single point collection succeeded!");
  314. }
  315. catch (Exception ex)
  316. {
  317. //记录日志
  318. log.Error(ex.Message.ToString());
  319. }
  320. finally
  321. {
  322. string str = table["btndisplayxray"].ToString();
  323. btnDisplayXRay.Text = str;
  324. btnDisplayXRay.Enabled = true;
  325. btnDisplayXRay.Refresh();
  326. btnPointXRay.Enabled = true;
  327. btnPointXRay.Refresh();
  328. btnAreaRay.Enabled = true;
  329. btnAreaRay.Refresh();
  330. btnClearData.Enabled = true;
  331. btnClearData.Refresh();
  332. }
  333. }
  334. public void RunEDSThread()
  335. {
  336. try
  337. {
  338. //图像数据
  339. uint[] a_XrayData = new uint[2000];
  340. uint a_Milliseconds = 0;
  341. //采集时间
  342. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  343. //采集XRay数据
  344. m_EDSHardwareMgr.CollectSpectrum(a_Milliseconds, ref a_XrayData);
  345. int[] XData = new int[2000];
  346. for (int i = 1; i <= 2000; i++)
  347. {
  348. XData[i - 1] = i;
  349. }
  350. //绑定数据源
  351. chartData(XData, a_XrayData);
  352. }
  353. catch (Exception ex)
  354. {
  355. //记录日志
  356. log.Error(ex.Message.ToString());
  357. }
  358. }
  359. public void chartData(int[] XData, uint[] YData)
  360. {
  361. //chartXRay = new Chart();
  362. //背景
  363. if (chartXRay.ChartAreas.Count == 0)
  364. {
  365. chartXRay.ChartAreas.Add(new ChartArea() { Name = "" }); //背景框
  366. }
  367. chartXRay.ChartAreas[0].Axes[0].MajorGrid.Enabled = false; //X轴上网格
  368. chartXRay.ChartAreas[0].Axes[1].MajorGrid.Enabled = false; //y轴上网格
  369. chartXRay.ChartAreas[0].Axes[0].MajorGrid.LineDashStyle = ChartDashStyle.Dash; //网格类型 短横线
  370. chartXRay.ChartAreas[0].Axes[0].MajorGrid.LineColor = Color.Gray;
  371. chartXRay.ChartAreas[0].Axes[0].MajorTickMark.Enabled = false; // x轴上突出的小点
  372. chartXRay.ChartAreas[0].Axes[1].MajorTickMark.Enabled = false; //
  373. chartXRay.ChartAreas[0].Axes[1].MajorGrid.LineWidth = 1;
  374. //图表数据区,有多个重叠则循环添加
  375. if (chartXRay.Series.Count == 0)
  376. {
  377. chartXRay.Series.Add(new Series() { Name = "" });
  378. }
  379. chartXRay.Series[0].ChartType = SeriesChartType.Line; //图类型(折线)
  380. chartXRay.Series[0].Points.DataBindXY(XData, YData); //添加数据
  381. chartXRay.Series[0].Label = "";
  382. chartXRay.Series[0].LegendText = "";
  383. //折线段配置
  384. chartXRay.Series[0].Color = Color.Blue; //线条颜色
  385. chartXRay.Series[0].BorderWidth = 1; //线条粗细
  386. chartXRay.Series[0].MarkerBorderColor = Color.Red; //标记点边框颜色
  387. chartXRay.Series[0].MarkerBorderWidth = 1; //标记点边框大小
  388. chartXRay.Series[0].MarkerColor = Color.Red; //标记点中心颜色
  389. chartXRay.Series[0].MarkerSize = 0; //标记点大小
  390. //chartXRay.Series[0].BorderWidth = 500;
  391. //另外
  392. //饼图说明设置,这用来设置饼图每一块的信息显示在什么地方
  393. chartXRay.Series[0]["PieLabelStyle"] = "Outside";//将文字移到外侧
  394. chartXRay.Series[0]["PieLineColor"] = "Black";//绘制黑色的连线。
  395. //柱状图其他设置
  396. chartXRay.Series[0]["DrawingStyle"] = "Emboss"; //设置柱状平面形状
  397. chartXRay.Series[0]["PointWidth"] = "0.1"; //设置柱状大小
  398. }
  399. #endregion
  400. #region 设置按钮事件
  401. private void btnSetInfo_Click(object sender, EventArgs e)
  402. {
  403. if (!IsConnection())
  404. {
  405. //return;
  406. }
  407. //获取响应按钮
  408. Button btnTest = (Button)sender;
  409. try
  410. {
  411. //节点名称与节点参数值
  412. string Name = string.Empty;
  413. string Value = string.Empty;
  414. //判断本地中是否存在文件路径
  415. if (ExistsFile(xmlFilePath))
  416. {
  417. //遍历tabHardwareSet标签中所有的TextBox控件
  418. foreach (Control control in this.tabXRay.Controls)
  419. {
  420. //判断类型名称
  421. if (control is TextBox)
  422. {
  423. Name = (control as TextBox).Name.Substring(2);
  424. if (btnTest.Name.Contains(Name))
  425. {
  426. //判断是否为空与类型
  427. if (!IsNull(((TextBox)control)))
  428. {
  429. ((TextBox)control).Focus();
  430. return;
  431. }
  432. if (!IsType(((TextBox)control).Text, 1))
  433. {
  434. ((TextBox)control).Focus();
  435. return;
  436. }
  437. //获取节点名称与节点参数值
  438. Value = (control as TextBox).Text;
  439. SaveSetting(Name, Value);
  440. }
  441. }
  442. }
  443. //遍历tabHardwareSet标签中所有的TextBox控件
  444. foreach (Control control in this.tabImage.Controls)
  445. {
  446. //判断类型名称
  447. if (control is TextBox)
  448. {
  449. Name = (control as TextBox).Name.Substring(2);
  450. if (btnTest.Name.Contains(Name))
  451. {
  452. //判断是否为空与类型
  453. if (!IsNull(((TextBox)control)))
  454. {
  455. ((TextBox)control).Focus();
  456. return;
  457. }
  458. if (!IsType(((TextBox)control).Text, 1))
  459. {
  460. ((TextBox)control).Focus();
  461. return;
  462. }
  463. //获取节点名称与节点参数值
  464. Value = (control as TextBox).Text;
  465. SaveSetting(Name, Value);
  466. }
  467. }
  468. }
  469. }
  470. else
  471. {
  472. //如果文件不存在,则创建文件
  473. CreateFile(xmlFilePath);
  474. }
  475. }
  476. catch (Exception ex)
  477. {
  478. //记录日志信息
  479. log.Error(ex.Message.ToString());
  480. }
  481. }
  482. #endregion
  483. #region 保存设置
  484. /// <summary>
  485. /// 保存设置
  486. /// </summary>
  487. /// <param name="Name">节点名称</param>
  488. /// <param name="Value">节点参数值</param>
  489. public void SaveSetting(string Name, string Value)
  490. {
  491. try
  492. {
  493. //判断XML文件中是否存在
  494. if (!XMLOperationClass.ExistsXmlInfo(Name))
  495. {
  496. //调用添加XML节点功能
  497. XMLOperationClass.AddXmlInfo(Name, Value);
  498. }
  499. else
  500. {
  501. //调用修改XML节点功能
  502. XMLOperationClass.EditXmlInfo(Name, Value);
  503. }
  504. }
  505. catch (Exception ex)
  506. {
  507. //记录日志信息
  508. log.Error(ex.Message.ToString());
  509. }
  510. }
  511. #endregion
  512. #region 修改设置
  513. public void EditSetting(string Name, string Value)
  514. {
  515. try
  516. {
  517. //调用修改XML节点功能
  518. XMLOperationClass.EditXmlInfo(Name, Value);
  519. }
  520. catch (Exception ex)
  521. {
  522. //记录日志信息
  523. log.Error(ex.Message.ToString());
  524. }
  525. }
  526. #endregion
  527. #region 判断文件路径
  528. /// <summary>
  529. /// 判断文件路径
  530. /// </summary>
  531. /// <param name="path"></param>
  532. /// <returns></returns>
  533. public bool CreateFile(string path)
  534. {
  535. Directory.CreateDirectory(path);
  536. return false;
  537. }
  538. #endregion
  539. #region 判断文件是否存在
  540. /// <summary>
  541. /// 判断文件是否存在
  542. /// </summary>
  543. /// <param name="path">文件路径</param>
  544. /// <returns></returns>
  545. public bool ExistsFile(string path)
  546. {
  547. try
  548. {
  549. if (File.Exists(path))
  550. {
  551. return true;
  552. }
  553. return false;
  554. }
  555. catch (Exception ex)
  556. {
  557. //记录日志信息
  558. log.Error(ex.Message.ToString());
  559. return false;
  560. }
  561. }
  562. #endregion
  563. #region 获取窗体中所有参数
  564. /// <summary>
  565. /// 获取窗体中控件的所有参数
  566. /// </summary>
  567. public void GetWindowsControlValue()
  568. {
  569. try
  570. {
  571. XmlDocument doc = new XmlDocument();
  572. //加载Xml文件
  573. doc.Load(xmlFilePath);
  574. //获取根节点
  575. XmlElement root = doc.DocumentElement;
  576. //获取子节点集合
  577. XmlNodeList mainNodes = root.GetElementsByTagName("parameter");
  578. foreach (XmlNode node in mainNodes)
  579. {
  580. //获取Name属性值
  581. string text = ((XmlElement)node).GetAttribute("Name");
  582. string value = ((XmlElement)node).GetAttribute("Value");
  583. foreach (Control control in this.tabXRay.Controls)
  584. {
  585. //判断类型名称
  586. if (control.Name.Contains(text))
  587. {
  588. if (control is TextBox)
  589. {
  590. ((TextBox)control).Text = value;
  591. }
  592. else if (control is ComboBox)
  593. {
  594. ((ComboBox)control).SelectedValue = value;
  595. }
  596. else if (control is CheckBox)
  597. {
  598. ((CheckBox)control).Checked = text.Equals("1") ? true : false;
  599. }
  600. }
  601. }
  602. foreach (Control control in this.tabImage.Controls)
  603. {
  604. //判断类型名称
  605. if (control.Name.Contains(text))
  606. {
  607. if (control is TextBox)
  608. {
  609. ((TextBox)control).Text = value;
  610. }
  611. else if (control is ComboBox)
  612. {
  613. ((ComboBox)control).SelectedValue = value;
  614. }
  615. else if (control is CheckBox)
  616. {
  617. ((CheckBox)control).Checked = text.Equals("1") ? true : false;
  618. }
  619. }
  620. }
  621. }
  622. }
  623. catch (Exception ex)
  624. {
  625. //记录日志信息
  626. log.Error(ex.Message.ToString());
  627. }
  628. }
  629. #endregion
  630. #region 用户信息提示
  631. /// <summary>
  632. /// 提示
  633. /// </summary>
  634. /// <param name="Message"></param>
  635. private void ShowMessage(int MessageType)
  636. {
  637. string message1 = table["message1"].ToString();
  638. string message2 = table["message2"].ToString();
  639. string message3 = table["message3"].ToString();
  640. string message4 = table["message4"].ToString();
  641. string message5 = table["message5"].ToString();
  642. string message6 = table["message6"].ToString();
  643. string message7 = table["message7"].ToString();
  644. string message8 = table["message8"].ToString();
  645. string message9 = table["message9"].ToString();
  646. string message10 = table["message10"].ToString();
  647. string MessageInfo = string.Empty;
  648. switch (MessageType)
  649. {
  650. case 0:
  651. MessageInfo = message1;
  652. break;
  653. case 1:
  654. MessageInfo = message2;
  655. break;
  656. case 2:
  657. MessageInfo = message3;
  658. break;
  659. case 3:
  660. MessageInfo = message4;
  661. break;
  662. case 4:
  663. MessageInfo = message5;
  664. break;
  665. case 5:
  666. MessageInfo = message6;
  667. break;
  668. case 6:
  669. MessageInfo = message7;
  670. break;
  671. case 7:
  672. MessageInfo = message8;
  673. break;
  674. case 8:
  675. MessageInfo = message9;
  676. break;
  677. case 9:
  678. MessageInfo = message10;
  679. break;
  680. }
  681. MessageBox.Show(MessageInfo, "Tip");
  682. }
  683. #endregion
  684. #region 判断控制内容是否为空 与 判断输入的格式是否正确
  685. /// <summary>
  686. /// 判断控制内容是否为空
  687. /// </summary>
  688. /// <param name="tbContent"></param>
  689. /// <returns></returns>
  690. public bool IsNull(TextBox tbContent)
  691. {
  692. if (tbContent.Text.Trim().Equals(""))
  693. {
  694. //为空提示
  695. ShowMessage(0);
  696. //获取焦点
  697. tbContent.Focus();
  698. return false;
  699. }
  700. return true;
  701. }
  702. /// <summary>
  703. ///
  704. /// </summary>
  705. /// <param name="objValue"></param>
  706. /// <param name="objType"></param>
  707. /// <returns></returns>
  708. public bool IsType(object ObjValue, int ObjType)
  709. {
  710. try
  711. {
  712. switch (ObjType)
  713. {
  714. case 1:
  715. int intValue = Convert.ToInt32(ObjValue);
  716. break;
  717. case 2:
  718. double douValue = Convert.ToDouble(ObjValue);
  719. break;
  720. case 3:
  721. float floValue = Convert.ToSingle(ObjValue);
  722. break;
  723. }
  724. return true;
  725. }
  726. catch (Exception)
  727. {
  728. //为空提示
  729. ShowMessage(7);
  730. return false;
  731. }
  732. }
  733. /// <summary>
  734. /// 判断是否连接
  735. /// </summary>
  736. /// <returns></returns>
  737. public bool IsConnection()
  738. {
  739. if (ConnectionState)
  740. {
  741. return true;
  742. }
  743. return false;
  744. }
  745. #endregion
  746. private void ControllerSettingForm_FormClosing(object sender, FormClosingEventArgs e)
  747. {
  748. }
  749. private void tabSetting_SelectedIndexChanged(object sender, EventArgs e)
  750. {
  751. try
  752. {
  753. if (ScanThread != null)
  754. {
  755. ScanThread.Abort();
  756. }
  757. if (EDSThread != null)
  758. {
  759. EDSThread.Abort();
  760. }
  761. if (tabSetting.SelectedIndex == 0)
  762. {
  763. EDSInit();
  764. }
  765. }
  766. catch (Exception)
  767. {
  768. }
  769. }
  770. private void btnSaveImage_Click(object sender, EventArgs e)
  771. {
  772. if (bitmap != null)
  773. {
  774. string fileName = LogPath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpeg";
  775. bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
  776. }
  777. }
  778. private void btnPointXRay_Click(object sender, EventArgs e)
  779. {
  780. GetPointXRay();
  781. }
  782. protected void GetPointXRay()
  783. {
  784. try
  785. {
  786. string str = table["str1"].ToString();
  787. btnDisplayXRay.Enabled = false;
  788. btnDisplayXRay.Refresh();
  789. btnPointXRay.Text = str;
  790. btnPointXRay.Enabled = false;
  791. btnPointXRay.Refresh();
  792. btnAreaRay.Enabled = false;
  793. btnAreaRay.Refresh();
  794. btnClearData.Enabled = false;
  795. btnClearData.Refresh();
  796. InitXRayData();
  797. if (ConnectionSem(connectionEnumType.EDSMultiPointXRay))
  798. {
  799. if (EDSInit())
  800. {
  801. //图像数据
  802. uint[] a_XrayData = new uint[2000];
  803. uint a_Milliseconds = 0;
  804. //采集时间
  805. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  806. //采集XRay数据
  807. List<COTSParticleClr> cOTSParticleClrs = new List<COTSParticleClr>();
  808. for (int i = 0; i < 5; i++)
  809. {
  810. COTSParticleClr cOTSParticle = new COTSParticleClr();
  811. CPosXrayClr cPosXray = new CPosXrayClr();
  812. cOTSParticle.SetXray(cPosXray);
  813. cOTSParticle.SetXRayPos(new Point(100 + i, 100 + i));
  814. cOTSParticleClrs.Add(cOTSParticle);
  815. }
  816. m_EDSHardwareMgr.SetResolution(int.Parse(tbRWidth.Text), int.Parse(tbRHeight.Text));
  817. bool result=m_EDSHardwareMgr.GetXRayByParts(cOTSParticleClrs, a_Milliseconds, false);
  818. if(!result)
  819. {
  820. log.Error("m_EDSHardwareMgr.GetXRayByPoints failed!");
  821. }
  822. int[] XData = new int[2000];
  823. uint nXrayCount = 0;
  824. for (int j = 0; j < 5; j++)
  825. {
  826. a_XrayData = cOTSParticleClrs[j].GetXray().GetXrayData();
  827. for (int i = 1; i <= 2000; i++)
  828. {
  829. XData[i - 1] = i;
  830. nXrayCount += a_XrayData[i - 1];
  831. }
  832. }
  833. //绑定数据源
  834. chartData(XData, a_XrayData);
  835. //显示Xray计数
  836. lbXrayCount.Text = nXrayCount.ToString();
  837. }
  838. }
  839. log.Info("Multipoint collection succeeded!");
  840. }
  841. catch (Exception ex)
  842. {
  843. //记录日志
  844. log.Error(ex.Message.ToString());
  845. }
  846. finally
  847. {
  848. string str = table["btnpointxray"].ToString();
  849. btnPointXRay.Text = str;
  850. btnPointXRay.Enabled = true;
  851. btnPointXRay.Refresh();
  852. btnDisplayXRay.Enabled = true;
  853. btnDisplayXRay.Refresh();
  854. btnAreaRay.Enabled = true;
  855. btnAreaRay.Refresh();
  856. btnClearData.Enabled = true;
  857. btnClearData.Refresh();
  858. }
  859. }
  860. private void btnAreaRay_Click(object sender, EventArgs e)
  861. {
  862. try
  863. {
  864. string str = table["str1"].ToString();
  865. btnDisplayXRay.Enabled = false;
  866. btnDisplayXRay.Refresh();
  867. btnPointXRay.Enabled = false;
  868. btnPointXRay.Refresh();
  869. btnAreaRay.Text = str;
  870. btnAreaRay.Enabled = false;
  871. btnAreaRay.Refresh();
  872. btnClearData.Enabled = false;
  873. btnClearData.Refresh();
  874. InitXRayData();
  875. if (ConnectionSem(connectionEnumType.EDSAreaXRay))
  876. {
  877. if (EDSInit())
  878. {
  879. //图像数据
  880. uint[] a_XrayData = new uint[2000];
  881. uint a_Milliseconds = 0;
  882. //采集时间
  883. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  884. //采集XRay数据
  885. var fea = new COTSFeatureClr();
  886. var segs = new List<COTSSegmentClr>();
  887. segs.Add(new COTSSegmentClr(5, 10, 12));
  888. segs.Add(new COTSSegmentClr(6, 10, 12));
  889. segs.Add(new COTSSegmentClr(7, 10, 12));
  890. fea.SetSegmentsList(segs, false);
  891. string ele = "";
  892. //设置图像分辨率
  893. int width = 0;
  894. int height = 0;
  895. //获取宽度
  896. //width = Convert.ToInt32(tbRWidth.Text);
  897. //height = Convert.ToInt32(tbRHeight.Text);
  898. //m_EDSHardwareMgr.SetResolution(width, height);
  899. bool isTrue = GetXRayBySingleFeature(a_Milliseconds, fea, ref a_XrayData,ref ele, false);
  900. int[] XData = new int[2000];
  901. uint nXrayCount = 0;
  902. for (int i = 1; i <= 2000; i++)
  903. {
  904. XData[i - 1] = i;
  905. nXrayCount += a_XrayData[i - 1];
  906. }
  907. //绑定数据源
  908. chartData(XData, a_XrayData);
  909. //显示Xray计数
  910. lbXrayCount.Text = nXrayCount.ToString();
  911. }
  912. }
  913. }
  914. catch (Exception ex)
  915. {
  916. //记录日志
  917. log.Error(ex.Message.ToString());
  918. }
  919. finally
  920. {
  921. string str = table["btnarearay"].ToString();
  922. btnPointXRay.Enabled = true;
  923. btnPointXRay.Refresh();
  924. btnDisplayXRay.Enabled = true;
  925. btnDisplayXRay.Refresh();
  926. btnAreaRay.Text = str;
  927. btnAreaRay.Enabled = true;
  928. btnAreaRay.Refresh();
  929. btnClearData.Enabled = true;
  930. btnClearData.Refresh();
  931. }
  932. }
  933. public bool GetXRayBySingleFeature(uint a_nXRayAQTime, COTSFeatureClr fea, ref uint[] a_XrayData, ref string ele, bool a_bElementInfo)
  934. {
  935. var eds = EDSController.GetEDSController(Convert.ToInt32(tbRWidth.Text),Convert.ToInt32(tbRHeight.Text),5000);
  936. var part = new COTSParticleClr();
  937. part.SetFeature(fea);
  938. var parts = new List<COTSParticleClr>();
  939. parts.Add(part);
  940. eds.GetXRayByFeatures(parts, a_nXRayAQTime, a_bElementInfo);
  941. a_XrayData = parts[0].GetXray().GetXrayData();
  942. ele = parts[0].GetXray().GetQuantifiedElementsStr();
  943. return true;
  944. }
  945. private void btnClearData_Click(object sender, EventArgs e)
  946. {
  947. try
  948. {
  949. InitXRayData();
  950. }
  951. catch (Exception ex)
  952. {
  953. //记录日志
  954. log.Error(ex.Message.ToString());
  955. }
  956. }
  957. public void InitXRayData()
  958. {
  959. try
  960. {
  961. //图像数据
  962. uint[] a_XrayData = new uint[2000];
  963. uint a_Milliseconds = 0;
  964. //采集时间
  965. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  966. //采集XRay数据
  967. int[] XData = new int[2000];
  968. uint nXrayCount = 0;
  969. for (int i = 1; i <= 2000; i++)
  970. {
  971. XData[i - 1] = i;
  972. nXrayCount += a_XrayData[i - 1];
  973. }
  974. //绑定数据源
  975. chartData(XData, a_XrayData);
  976. //显示Xray计数
  977. lbXrayCount.Text = nXrayCount.ToString();
  978. chartXRay.Refresh();
  979. ConnectionState = false;
  980. log.Info("Cleared successfully!");
  981. }
  982. catch (Exception ex)
  983. {
  984. //记录日志
  985. log.Error(ex.Message.ToString());
  986. }
  987. }
  988. #region 获取元素分析
  989. private void btnEanalysis_Click(object sender, EventArgs e)
  990. {
  991. try
  992. {
  993. string str = table["str1"].ToString();
  994. btnDisplayXRay.Enabled = false;
  995. btnDisplayXRay.Refresh();
  996. btnPointXRay.Enabled = false;
  997. btnPointXRay.Refresh();
  998. btnAreaRay.Enabled = false;
  999. btnAreaRay.Refresh();
  1000. btnEanalysis.Text = str;
  1001. btnEanalysis.Enabled = false;
  1002. btnEanalysis.Refresh();
  1003. btnClearData.Enabled = false;
  1004. btnClearData.Refresh();
  1005. InitXRayData();
  1006. if (ConnectionSem(connectionEnumType.EDSAreaXRay))
  1007. {
  1008. if (EDSInit())
  1009. {
  1010. //图像数据
  1011. uint[] a_XrayData = new uint[2000];
  1012. uint a_Milliseconds = 0;
  1013. //采集时间
  1014. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  1015. //采集元素分析数据
  1016. ValueType a_nElementNum = 0;
  1017. string a_strResult = string.Empty;
  1018. try
  1019. {
  1020. GetXRayElements(a_Milliseconds, ref a_XrayData, ref a_nElementNum, ref a_strResult);
  1021. }
  1022. catch (Exception ex)
  1023. {
  1024. log.Error("ControllerSettingForm_btnEanalysis_Click:--GetXRayElements()_Exception" + ex.Message.ToString());
  1025. }
  1026. int[] XData = new int[2000];
  1027. uint nXrayCount = 0;
  1028. for (int i = 1; i <= 2000; i++)
  1029. {
  1030. XData[i - 1] = i;
  1031. nXrayCount += a_XrayData[i - 1];
  1032. }
  1033. //绑定数据源
  1034. chartData(XData, a_XrayData);
  1035. //显示Xray计数
  1036. lbXrayCount.Text = nXrayCount.ToString();
  1037. //显示元素分析结果内容
  1038. ShowXRayElementResultForm showXRayElementResultForm = new ShowXRayElementResultForm((int)a_nElementNum, a_strResult);
  1039. showXRayElementResultForm.ShowDialog();
  1040. }
  1041. }
  1042. log.Info("Element analysis success!");
  1043. }
  1044. catch (Exception ex)
  1045. {
  1046. //记录日志
  1047. log.Error(ex.Message.ToString());
  1048. }
  1049. finally
  1050. {
  1051. string str = table["btneanalysis"].ToString();
  1052. btnPointXRay.Enabled = true;
  1053. btnPointXRay.Refresh();
  1054. btnDisplayXRay.Enabled = true;
  1055. btnDisplayXRay.Refresh();
  1056. btnAreaRay.Enabled = true;
  1057. btnAreaRay.Refresh();
  1058. btnEanalysis.Text = str;
  1059. btnEanalysis.Enabled = true;
  1060. btnEanalysis.Refresh();
  1061. btnClearData.Enabled = true;
  1062. btnClearData.Refresh();
  1063. }
  1064. }
  1065. public bool GetXRayElements(uint a_nXRayAQTime, ref uint[] a_XrayData, ref ValueType a_nElementNum, ref string a_strResult)
  1066. {
  1067. var eds = EDSController.GetEDSController(Convert.ToInt32(tbRWidth.Text), Convert.ToInt32(tbRHeight.Text), 5000);
  1068. var part = new COTSParticleClr();
  1069. var pos = new Point(10, 10);
  1070. part.SetXRayPos(pos);
  1071. var parts = new List<COTSParticleClr>();
  1072. parts.Add(part);
  1073. eds.GetXRayByParts(parts, a_nXRayAQTime, true);
  1074. a_XrayData = parts[0].GetXray().GetXrayData();
  1075. a_strResult = parts[0].GetXray().GetQuantifiedElementsStr();
  1076. a_nElementNum = parts[0].GetXray().GetElementQuantifyData().Count;
  1077. return true;
  1078. }
  1079. #endregion
  1080. private void btn_continuousshot_Click(object sender, EventArgs e)
  1081. {
  1082. pictureBox1.Image = null;
  1083. pictureBox2.Image = null;
  1084. pictureBox3.Image = null;
  1085. pictureBox4.Image = null;
  1086. pictureBox1.BorderStyle = BorderStyle.None;
  1087. pictureBox2.BorderStyle = BorderStyle.None;
  1088. pictureBox3.BorderStyle = BorderStyle.None;
  1089. pictureBox4.BorderStyle = BorderStyle.None;
  1090. btn_continuousshot.Enabled = false;
  1091. btn_confirm.Enabled = false;
  1092. this.Refresh();
  1093. ISemController m_Sem = SemController.GetSEMController();
  1094. bool flag = m_Sem.Connect();
  1095. //电镜设置对象
  1096. var cfun = ScanController.GetScanController();
  1097. bool IsConnec = cfun.Init();
  1098. double Magnification = 0;
  1099. m_Sem.GetMagnification(ref Magnification);
  1100. //double a_dScanFieldSizeX = 0;
  1101. //double a_dScanFieldSizeY = 0;
  1102. //m_Sem.GetScanFieldSize(ref a_dScanFieldSizeX,ref a_dScanFieldSizeY);
  1103. double scanFieldSize100 = 0;
  1104. double.TryParse(tB_scanFieldSize100.Text, out scanFieldSize100);
  1105. double scanFieldSize = scanFieldSize100 * 100 / Magnification;
  1106. double PositionX = 0;
  1107. double PositionY = 0;
  1108. double PositionR = 0;
  1109. m_Sem.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR);
  1110. double PositionXO = PositionX;
  1111. double PositionYO = PositionY;
  1112. //double PositionR0 = PositionR;
  1113. int width = 1024;
  1114. int height = 768;
  1115. //设置图像分辨率
  1116. if (cb_imageresolution.Text.Trim() == "")
  1117. {
  1118. MessageBox.Show("imageresolution cannot be null!");
  1119. return;
  1120. }
  1121. else
  1122. {
  1123. width = Convert.ToInt32(cb_imageresolution.Text.Split('*')[0]);
  1124. height = Convert.ToInt32(cb_imageresolution.Text.Split('*')[1]);
  1125. pictureBox1.Height = pictureBox1.Width * height / width;
  1126. pictureBox2.Height = pictureBox1.Height;
  1127. pictureBox3.Height = pictureBox1.Height;
  1128. pictureBox4.Height = pictureBox1.Height;
  1129. pictureBox2.Location = new Point(pictureBox1.Location.X + pictureBox1.Width, pictureBox1.Location.Y);
  1130. pictureBox3.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + pictureBox1.Height);
  1131. pictureBox4.Location = new Point(pictureBox1.Location.X + pictureBox1.Width, pictureBox1.Location.Y + pictureBox1.Height);
  1132. }
  1133. this.Refresh();
  1134. double scanFieldSizeH = scanFieldSize * height / width;
  1135. m_Sem.SetScanExternal(true);
  1136. try
  1137. {
  1138. for (int i = 0; i < 4; i++)
  1139. {
  1140. if (i == 0)
  1141. {
  1142. }
  1143. else if (i == 1)
  1144. {
  1145. switch (cb_Xdirection.SelectedItem.ToString())
  1146. {
  1147. case "RIGHT_TOWARD": PositionX += scanFieldSize; break;
  1148. default: PositionX -= scanFieldSize; break;
  1149. }
  1150. m_Sem.MoveSEMToPoint(PositionX, PositionY);
  1151. }
  1152. else if (i == 2)
  1153. {
  1154. switch (cb_Ydirection.SelectedItem.ToString())
  1155. {
  1156. case "UP_TOWARD": PositionY -= scanFieldSizeH; break;
  1157. default: PositionY += scanFieldSizeH; break;
  1158. }
  1159. m_Sem.MoveSEMToPoint(PositionX, PositionY);
  1160. }
  1161. else
  1162. {
  1163. switch (cb_Xdirection.SelectedItem.ToString())
  1164. {
  1165. case "RIGHT_TOWARD": PositionX -= scanFieldSize; break;
  1166. default: PositionX += scanFieldSize; break;
  1167. }
  1168. m_Sem.MoveSEMToPoint(PositionX, PositionY);
  1169. }
  1170. //Thread.Sleep(50);
  1171. byte[] ImageByte = new byte[width * height];
  1172. bool resultValue = GetScanImage(width, height, "2", ref ImageByte);
  1173. if (resultValue)
  1174. {
  1175. if (ImageByte != null)
  1176. {
  1177. var bitmap = CImageHandler.ToGrayBitmap(ImageByte, width, height);
  1178. switch (i)
  1179. {
  1180. case 0:
  1181. pictureBox1.Image = bitmap;
  1182. break;
  1183. case 1:
  1184. pictureBox2.Image = bitmap;
  1185. break;
  1186. case 2:
  1187. pictureBox4.Image = bitmap;
  1188. break;
  1189. case 3:
  1190. pictureBox3.Image = bitmap;
  1191. break;
  1192. }
  1193. this.Refresh();
  1194. }
  1195. }
  1196. }
  1197. m_Sem.MoveSEMToPoint(PositionXO, PositionYO);
  1198. }
  1199. catch (Exception ex)
  1200. {
  1201. log.Error("continuousshot--错误信息:" + ex.ToString());
  1202. pictureBox1.BorderStyle = BorderStyle.FixedSingle;
  1203. pictureBox2.BorderStyle = BorderStyle.FixedSingle;
  1204. pictureBox3.BorderStyle = BorderStyle.FixedSingle;
  1205. pictureBox4.BorderStyle = BorderStyle.FixedSingle;
  1206. }
  1207. finally
  1208. {
  1209. m_Sem.SetScanExternal(false);
  1210. btn_continuousshot.Enabled = true;
  1211. btn_confirm.Enabled = true;
  1212. btn_continuousshot.Refresh();
  1213. }
  1214. }
  1215. bool ReadConfigXml(string xmlpath,ref string xAxisDir,ref string yAxisDir,ref string scanFieldSize)
  1216. {
  1217. try
  1218. {
  1219. XmlDocument xmlDocument = new XmlDocument();
  1220. xmlDocument.Load(xmlpath);
  1221. XmlNodeList nodeList = xmlDocument.SelectSingleNode("XMLData").ChildNodes;
  1222. foreach (XmlNode xn in nodeList)
  1223. {
  1224. XmlElement xe = (XmlElement)xn;
  1225. if (xe.GetAttribute("RegName") == "StageData")
  1226. {
  1227. scanFieldSize=xe.GetAttribute("scanFieldSize");
  1228. xAxisDir=xe.GetAttribute("xAxisDir");
  1229. yAxisDir=xe.GetAttribute("yAxisDir");
  1230. break;
  1231. }
  1232. }
  1233. }
  1234. catch (Exception ex)
  1235. {
  1236. MessageBox.Show(ex.ToString());
  1237. return false;
  1238. }
  1239. return true;
  1240. }
  1241. bool SaveConfigXml(string xmlpath, string xAxisDir, string yAxisDir, string scanFieldSize)
  1242. {
  1243. try
  1244. {
  1245. XmlDocument xmlDocument = new XmlDocument();
  1246. xmlDocument.Load(xmlpath);
  1247. XmlNodeList nodeList = xmlDocument.SelectSingleNode("XMLData").ChildNodes;
  1248. foreach (XmlNode xn in nodeList)
  1249. {
  1250. XmlElement xe = (XmlElement)xn;
  1251. if (xe.GetAttribute("RegName") == "StageData")
  1252. {
  1253. xe.SetAttribute("scanFieldSize", scanFieldSize);
  1254. xe.SetAttribute("xAxisDir", xAxisDir);
  1255. xe.SetAttribute("yAxisDir", yAxisDir);
  1256. break;
  1257. }
  1258. }
  1259. xmlDocument.Save(xmlpath);
  1260. }
  1261. catch (Exception ex)
  1262. {
  1263. MessageBox.Show(ex.ToString());
  1264. return false;
  1265. }
  1266. return true;
  1267. }
  1268. private void btn_confirm_Click(object sender, EventArgs e)
  1269. {
  1270. double dscanFieldSize100 = 0;
  1271. if (cb_Xdirection.Text.Trim() != null && cb_imageresolution.Text.Trim() != null && cb_Ydirection.Text.Trim() != null && double.TryParse(tB_scanFieldSize100.Text, out dscanFieldSize100))
  1272. {
  1273. string xmlpath = Application.StartupPath + @"\Config\SysData\OTSProgMgrParam.pmf";
  1274. string xAxisDir = "";
  1275. string yAxisDir = "";
  1276. switch (cb_Xdirection.SelectedItem.ToString())
  1277. {
  1278. case "LEFT_TOWARD":
  1279. xAxisDir = "0:LEFT_TOWARD";
  1280. break;
  1281. default:
  1282. xAxisDir = "1:RIGHT_TOWARD";
  1283. break;
  1284. }
  1285. switch(cb_Ydirection.Text)
  1286. {
  1287. case "UP_TOWARD":
  1288. yAxisDir="0:" + cb_Ydirection.Text;
  1289. break;
  1290. default:
  1291. yAxisDir = "1:DOWN_TOWARD";
  1292. break;
  1293. }
  1294. SaveConfigXml(xmlpath, xAxisDir, yAxisDir, tB_scanFieldSize100.Text);
  1295. }
  1296. else
  1297. {
  1298. MessageBox.Show("Please check params!");
  1299. }
  1300. }
  1301. private void btn_Recommendedconfiguration_Click(object sender, EventArgs e)
  1302. {
  1303. if (recommendedConfiguration == null || recommendedConfiguration.IsDisposed)
  1304. {
  1305. recommendedConfiguration = new RecommendedConfiguration();
  1306. recommendedConfiguration.Show();
  1307. }
  1308. else
  1309. {
  1310. recommendedConfiguration.Activate();
  1311. }
  1312. }
  1313. }
  1314. }