ControllerSettingForm.cs 50 KB

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