DlgStageEdit.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. using OTSDataType;
  2. using OTSModelSharp;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Drawing.Drawing2D;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. using OTSModelSharp.Measure.GetStageInfo;
  14. namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
  15. {
  16. public partial class DlgStageEdit : Form
  17. {
  18. // stage file
  19. CStageParam m_pStageFile;
  20. public CStage m_pStage;
  21. StageDisplayHelp stageDisplayHelp;
  22. OTSCommon.Language lan;
  23. System.Collections.Hashtable hashtable;
  24. public DlgStageEdit()
  25. {
  26. InitializeComponent();
  27. }
  28. public DlgStageEdit(CStage cStage)
  29. {
  30. InitializeComponent();
  31. m_pStage = cStage;
  32. }
  33. ComboBox cmb_Temp = new ComboBox();
  34. private void DlgStageEdit_Load(object sender, EventArgs e)
  35. {
  36. lan = new OTSCommon.Language(this);
  37. hashtable = lan.GetNameTable(this.Name);
  38. radioButton_OTS.Checked = true;
  39. radioButton_BoundarySquare.Checked = true;
  40. radioButton_StandardsampleSqare.Checked = true;
  41. string str = hashtable["str1"].ToString();
  42. dataGridView_Holes.Columns.Add("HoleName", str);
  43. str = hashtable["str2"].ToString();
  44. dataGridView_Holes.Columns.Add("HoleShape", str);
  45. str = hashtable["str3"].ToString();
  46. dataGridView_Holes.Columns.Add("CenterCoordinatesX", str);
  47. str = hashtable["str4"].ToString();
  48. dataGridView_Holes.Columns.Add("CenterCoordinatesY", str);
  49. str = hashtable["str5"].ToString();
  50. dataGridView_Holes.Columns.Add("Param1", str);
  51. str = hashtable["str6"].ToString();
  52. dataGridView_Holes.Columns.Add("Param2", str);
  53. str = hashtable["str7"].ToString();
  54. dataGridView_Holes.Rows.Add("1", str, -4250, -16000, 12000, 0);
  55. //SetDataGridViewStyle();
  56. cmb_Temp.Visible = false;
  57. cmb_Temp.Items.Add(str);
  58. str = hashtable["str8"].ToString();
  59. cmb_Temp.Items.Add(str);
  60. cmb_Temp.SelectedIndexChanged += new EventHandler(cmb_Temp_SelectedIndexChanged);
  61. dataGridView_Holes.Controls.Add(cmb_Temp);
  62. stageDisplayHelp = new StageDisplayHelp();
  63. if(m_pStage!=null)
  64. {
  65. LoadStageData(m_pStage);
  66. }
  67. SetHelp();
  68. //Object pDC = new Object();
  69. //pDC = m_ctrlStagePicture.CreateGraphics();
  70. ////消除锯齿
  71. //((Graphics)pDC).SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  72. //((Graphics)pDC).InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  73. //((Graphics)pDC).CompositingQuality = CompositingQuality.HighQuality;//再加一点
  74. }
  75. void SetHelp()
  76. {
  77. string str = hashtable["str9"].ToString();
  78. helpProvider1.SetHelpString(label1, "样品台名不能为空字串,不能含\',\'字符!");
  79. helpProvider1.SetHelpString(groupBox1, "样品台边框行有5个数值参数。形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0");
  80. helpProvider1.SetHelpString(groupBox2, "标样信息行有5个数值参数。形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0");
  81. helpProvider1.SetHelpString(groupBox3, "样品孔信息行有6个数值参数,1个字符串参数,5个数值参数。1个字符串参数为样品孔名。5个数值参数为形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0。");
  82. }
  83. void LoadStageData(CStage cStage)
  84. {
  85. tStageName.Text = m_pStage.GetName();
  86. if(m_pStage.GetBoundary().GetShape()== otsdataconst.DOMAIN_SHAPE.ROUND)
  87. {
  88. radioButton_BoundaryCircle.Checked = true;
  89. tBoundaryWide.Text = m_pStage.GetBoundary().GetDiameter().ToString();
  90. tBoundaryHeight.Text = "0";
  91. }
  92. else
  93. {
  94. radioButton_BoundarySquare.Checked = true;
  95. tBoundaryWide.Text = m_pStage.GetBoundary().GetRectDomain().Width.ToString();
  96. tBoundaryHeight.Text = m_pStage.GetBoundary().GetRectDomain().Height.ToString();
  97. }
  98. tBoundaryX.Text= m_pStage.GetBoundary().GetDomainCenter().X.ToString();
  99. tBoundaryY.Text = m_pStage.GetBoundary().GetDomainCenter().Y.ToString();
  100. if(m_pStage.GetSTD().GetShape()== otsdataconst.DOMAIN_SHAPE.ROUND)
  101. {
  102. radioButton_StandardsampleCircle.Checked = true;
  103. tStandardsampleWide.Text = m_pStage.GetSTD().GetDiameter().ToString();
  104. }
  105. else
  106. {
  107. radioButton_StandardsampleSqare.Checked = true;
  108. tStandardsampleWide.Text = m_pStage.GetSTD().GetRectDomain().Width.ToString();
  109. }
  110. tStandardsampleX.Text = m_pStage.GetSTD().GetDomainCenter().X.ToString();
  111. tStandardsampleY.Text = m_pStage.GetSTD().GetDomainCenter().Y.ToString();
  112. tStandardsampleHeight.Text = m_pStage.GetSTD().GetRectDomain().Height.ToString();
  113. dataGridView_Holes.Rows[0].Cells[0].Value = m_pStage.GetHoleList()[0].GetName();
  114. if (m_pStage.GetHoleList()[0].GetShape() == otsdataconst.DOMAIN_SHAPE.ROUND)
  115. {
  116. dataGridView_Holes.Rows[0].Cells[1].Value = "圆形";
  117. dataGridView_Holes.Rows[0].Cells[4].Value = m_pStage.GetHoleList()[0].GetDiameter().ToString();
  118. dataGridView_Holes.Rows[0].Cells[5].Value = "0";
  119. }
  120. else
  121. {
  122. dataGridView_Holes.Rows[0].Cells[1].Value = "方形";
  123. dataGridView_Holes.Rows[0].Cells[4].Value = m_pStage.GetHoleList()[0].GetRectDomain().Width.ToString();
  124. dataGridView_Holes.Rows[0].Cells[5].Value = m_pStage.GetHoleList()[0].GetRectDomain().Height.ToString();
  125. }
  126. dataGridView_Holes.Rows[0].Cells[2].Value = m_pStage.GetHoleList()[0].GetDomainCenter().X.ToString();
  127. dataGridView_Holes.Rows[0].Cells[3].Value = m_pStage.GetHoleList()[0].GetDomainCenter().Y.ToString();
  128. for (int i=1;i< m_pStage.GetHoleList().Count;i++)
  129. {
  130. string sr = "";
  131. string pra1 = "";
  132. string pra2 = "";
  133. if (m_pStage.GetHoleList()[i].GetShape() == otsdataconst.DOMAIN_SHAPE.ROUND)
  134. {
  135. sr= "圆形";
  136. pra1 = m_pStage.GetHoleList()[i].GetDiameter().ToString();
  137. pra2 = "0";
  138. }
  139. else
  140. {
  141. sr= "方形";
  142. pra1 = m_pStage.GetHoleList()[i].GetRectDomain().Width.ToString();
  143. pra2 = m_pStage.GetHoleList()[i].GetRectDomain().Height.ToString();
  144. }
  145. dataGridView_Holes.Rows.Add(m_pStage.GetHoleList()[i].GetName(), sr, m_pStage.GetHoleList()[i].GetDomainCenter().X.ToString(), m_pStage.GetHoleList()[i].GetDomainCenter().Y.ToString(), pra1, pra2);
  146. }
  147. }
  148. private void radioButton_BoundaryCircle_Click(object sender, EventArgs e)
  149. {
  150. label8.Enabled = false;
  151. tBoundaryHeight.Enabled = false;
  152. tBoundaryHeight.Text = "0";
  153. label7.Text = "直径:";
  154. }
  155. private void radioButton_BoundarySquare_Click(object sender, EventArgs e)
  156. {
  157. label8.Enabled = true;
  158. tBoundaryHeight.Enabled = true;
  159. label7.Text = "宽度:";
  160. }
  161. private void radioButton_StandardsampleCircle_Click(object sender, EventArgs e)
  162. {
  163. label9.Enabled = false;
  164. tStandardsampleHeight.Enabled = false;
  165. tStandardsampleHeight.Text = "0";
  166. label10.Text = "直径:";
  167. }
  168. private void radioButton__StandardsampleSqare_Click(object sender, EventArgs e)
  169. {
  170. label9.Enabled = true;
  171. tStandardsampleHeight.Enabled = true;
  172. label10.Text = "宽度:";
  173. }
  174. private void dataGridView_Holes_CurrentCellChanged(object sender, EventArgs e)
  175. {
  176. if(dataGridView_Holes.CurrentRow==null)
  177. {
  178. return;
  179. }
  180. if(dataGridView_Holes.CurrentCell.ColumnIndex==1)
  181. {
  182. Rectangle rect = dataGridView_Holes.GetCellDisplayRectangle(dataGridView_Holes.CurrentCell.ColumnIndex, dataGridView_Holes.CurrentCell.RowIndex, false);
  183. string HoleShape = dataGridView_Holes.CurrentCell.Value.ToString();
  184. cmb_Temp.Left = rect.Left;
  185. cmb_Temp.Top = rect.Top;
  186. cmb_Temp.Width = rect.Width;
  187. cmb_Temp.SelectedIndex = 0;
  188. cmb_Temp.Visible = true;
  189. }
  190. else
  191. {
  192. cmb_Temp.Visible = false;
  193. }
  194. }
  195. void cmb_Temp_SelectedIndexChanged(object sender ,EventArgs e)
  196. {
  197. if (dataGridView_Holes.CurrentRow == null)
  198. {
  199. return;
  200. }
  201. if (((ComboBox)sender).SelectedIndex == 0)
  202. {
  203. dataGridView_Holes.CurrentCell.Value = "圆形";
  204. dataGridView_Holes.CurrentRow.Cells[5].Value = 0;
  205. }
  206. else
  207. {
  208. dataGridView_Holes.CurrentCell.Value = "方形";
  209. dataGridView_Holes.CurrentRow.Cells[5].Value = "";
  210. }
  211. }
  212. private void dataGridView_Holes_Scroll(object sender, ScrollEventArgs e)
  213. {
  214. this.cmb_Temp.Visible = false;
  215. }
  216. private void button_Generate_Click(object sender, EventArgs e)
  217. {
  218. if (!CheckParams())
  219. {
  220. this.button_Ok.Enabled = false;
  221. MessageBox.Show("Please check Params!");
  222. return;
  223. }
  224. CSEMStageData a_pCSEMStageData = new CSEMStageData();
  225. //获取配置文件中 StageData 内容
  226. COTSDefaultParam m_DefaultParam = new COTSDefaultParam();
  227. m_DefaultParam.LoadInfoFromProgMgrFile();
  228. a_pCSEMStageData = m_DefaultParam.GetStageDataParam();
  229. m_pStage = new CStage();
  230. m_pStage.SetName(tStageName.Text);
  231. // boundary
  232. string strValue = "";
  233. if(radioButton_BoundaryCircle.Checked)
  234. {
  235. strValue += "0";
  236. tBoundaryHeight.Text="0";
  237. }
  238. else
  239. {
  240. strValue += "1";
  241. }
  242. strValue += "," + tBoundaryX.Text+","+tBoundaryY.Text+","+tBoundaryWide.Text+","+ tBoundaryHeight.Text;
  243. CDomain pBoundary = stageDisplayHelp.GetDomain(strValue);
  244. // STD
  245. strValue = "";
  246. if(radioButton_StandardsampleCircle.Checked)
  247. {
  248. strValue += "0";
  249. tStandardsampleHeight.Text = "0";
  250. }
  251. else
  252. {
  253. strValue += "1";
  254. }
  255. strValue += "," + tStandardsampleX.Text + "," + tStandardsampleY.Text + "," + tStandardsampleWide.Text + "," + tStandardsampleHeight.Text;
  256. CDomain pSTD = stageDisplayHelp.GetDomain(strValue);
  257. // coordinate system
  258. CStageParam.COORDINATE_SYSTEM_SETTING nCoodrSysSetting = CStageParam.COORDINATE_SYSTEM_SETTING.INVALID;
  259. if(radioButton_OTS.Checked)
  260. {
  261. nCoodrSysSetting = (CStageParam.COORDINATE_SYSTEM_SETTING)0;
  262. }
  263. else
  264. {
  265. nCoodrSysSetting = (CStageParam.COORDINATE_SYSTEM_SETTING)1;
  266. }
  267. // Holes list
  268. List<CHole> listHoles = new List<CHole>();
  269. for(int i=0;i<dataGridView_Holes.Rows.Count;i++)
  270. {
  271. strValue = "";
  272. if(dataGridView_Holes.Rows[i].Cells[1].Value.ToString()=="圆形")
  273. {
  274. strValue += "0";
  275. }
  276. else
  277. {
  278. strValue += "1";
  279. }
  280. strValue += ","+ dataGridView_Holes.Rows[i].Cells[2].Value + "," + dataGridView_Holes.Rows[i].Cells[3].Value + "," + dataGridView_Holes.Rows[i].Cells[4].Value + "," + dataGridView_Holes.Rows[i].Cells[5].Value;
  281. CDomain pDomain = stageDisplayHelp.GetDomain(strValue);
  282. //add holes
  283. listHoles.Add(new CHole(dataGridView_Holes.Rows[i].Cells[0].Value.ToString(), pDomain));
  284. }
  285. // check stage components
  286. // name should be ok
  287. if (pBoundary == null)
  288. {
  289. return ;
  290. }
  291. if (pBoundary.IsInvalid())
  292. {
  293. // boundary is invalid
  294. return ;
  295. }
  296. if (pSTD != null)
  297. {
  298. // STD has to be inside of the boundary
  299. if (!pBoundary.DomainInDomain(pSTD))
  300. {
  301. MessageBox.Show("STD is over the boundary!");
  302. return;
  303. }
  304. }
  305. else
  306. {
  307. return;
  308. }
  309. // hole has to be inside of the boundary and can't have common part with STD and each other
  310. List<CHole> listStageHoles = new List<CHole>();
  311. foreach (var pHole in listHoles)
  312. {
  313. if (!pBoundary.DomainInDomain(pHole))
  314. {
  315. MessageBox.Show(pHole.GetName() + "is over the boundary, jump over!");
  316. continue;
  317. }
  318. else if (pSTD.IntersectDomain(pHole))
  319. {
  320. MessageBox.Show(pHole.GetName() + " has common part with STD, jump over!");
  321. continue;
  322. }
  323. bool bHasCommonPart = false;
  324. foreach (var pStageHole in listStageHoles)
  325. {
  326. if (pStageHole.IntersectDomain(pHole))
  327. {
  328. MessageBox.Show(pHole.GetName() + " has common part with a hole already on the stage!");
  329. bHasCommonPart = true;
  330. break;
  331. }
  332. }
  333. if (bHasCommonPart)
  334. {
  335. // this hole has common part with a hole already on the stage, jump over
  336. continue;
  337. }
  338. // the hole is ok, add it into stage holes list
  339. listStageHoles.Add(pHole);
  340. }
  341. if (listStageHoles.Count == 0)
  342. {
  343. // no hole at all
  344. return ;
  345. }
  346. // the stage is in SEM coordinate system, convert all components to OTS system
  347. if (nCoodrSysSetting == CStageParam.COORDINATE_SYSTEM_SETTING.SEM)
  348. {
  349. if (!a_pCSEMStageData.ConverSEMToOTSSystem(pBoundary, pSTD, listStageHoles))
  350. {
  351. return ;
  352. }
  353. }
  354. m_pStage.SetBoundary(pBoundary);
  355. m_pStage.SetSTD(pSTD);
  356. m_pStage.SetHoleList(listStageHoles, true);
  357. DrawStage();
  358. this.button_Ok.Enabled = true;
  359. }
  360. public void DrawStage()
  361. {
  362. Rectangle rc = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
  363. Rectangle re = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
  364. int pWnd = otsdataconst.IDC_PIC_STAGE;
  365. int nWidth = (int)rc.Width;
  366. int nHeight = (int)rc.Height;
  367. Object pDC = new Object();
  368. bool DeleteObject = false;
  369. //paint the DC with white
  370. Brush pOldBrush = new SolidBrush(Color.FromArgb(50, Color.White));
  371. m_ctrlStagePicture.Refresh();
  372. //Image img = (Image)new Bitmap(m_ctrlStagePicture.Width, m_ctrlStagePicture.Height);
  373. //Graphics graphics = m_ctrlStagePicture.CreateGraphics();// Graphics.FromImage(img);
  374. //graphics.FillRectangle(new SolidBrush(Color.Beige), re);
  375. pDC = m_ctrlStagePicture.CreateGraphics();
  376. //消除锯齿
  377. ((Graphics)pDC).SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  378. ((Graphics)pDC).InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  379. ((Graphics)pDC).CompositingQuality = CompositingQuality.HighQuality;//再加一点
  380. //get stage information
  381. CDomain pBoundery = m_pStage.GetBoundary();// GetBoundary();
  382. System.Drawing.Rectangle BounderyRect = pBoundery.GetDomainRect();
  383. int nBounderyWidth = (int)(BounderyRect.Width);//um,,pixle is (nWidth - PIC_EDGE * 2 )
  384. int nBounderyHeight = 0;
  385. if (pBoundery.GetShape() == otsdataconst.DOMAIN_SHAPE.RECTANGLE)
  386. {nBounderyHeight = (int)(BounderyRect.Height);}
  387. else
  388. {
  389. nBounderyHeight = (int)(BounderyRect.Width);
  390. }
  391. double PixSize = 0;
  392. double coordinateSystemEndpoint = 0;
  393. if (nBounderyWidth > nBounderyHeight)
  394. {
  395. PixSize = (long)((double)nBounderyWidth / (double)(nWidth - StageDisplayHelp.PIC_EDGE * 2));
  396. coordinateSystemEndpoint = nBounderyWidth/2;
  397. }
  398. else
  399. {
  400. PixSize = (long)((double)nBounderyHeight / (double)(nHeight - StageDisplayHelp.PIC_EDGE * 2));
  401. coordinateSystemEndpoint = nBounderyHeight/2;
  402. }
  403. //draw boundery
  404. Brush pLTGrayBrush = new SolidBrush(Color.FromArgb(255, 0, 0));
  405. stageDisplayHelp.DrawStageBoundery(m_pStage, nWidth, nHeight, pDC, PixSize);
  406. ////draw STD
  407. //Brush pBlackBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
  408. //DrawStageSTD(m_pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
  409. ////draw holes
  410. //Brush pWriteBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
  411. stageDisplayHelp.DrawStageHole(m_pStage, nWidth, nHeight, pDC, PixSize);
  412. // draw ratio
  413. stageDisplayHelp.DrawRatio(nBounderyWidth, nWidth, nHeight, pDC, (IntPtr)pWnd, rc);
  414. //stageDisplayHelp.DrawXY(pDC, m_ctrlStagePicture.Width, m_ctrlStagePicture.Height, PixSize, coordinateSystemEndpoint);
  415. pLTGrayBrush.Dispose();
  416. //pBlackBrush.Dispose();
  417. //pWriteBrush.Dispose();
  418. //graphics.Dispose();
  419. //((Graphics)pDC).Dispose();
  420. pOldBrush.Dispose();
  421. }
  422. private void button_Ok_Click(object sender, EventArgs e)
  423. {
  424. this.DialogResult = DialogResult.OK;
  425. this.Close();
  426. }
  427. private void button_AddHole_Click(object sender, EventArgs e)
  428. {
  429. dataGridView_Holes.Rows.Add("1", "圆形", -4250, -16000, 12000, 0);
  430. }
  431. private void button_DelHole_Click(object sender, EventArgs e)
  432. {
  433. if(dataGridView_Holes.Rows.Count<1)
  434. {
  435. return;
  436. }
  437. int index = dataGridView_Holes.CurrentCell.RowIndex;
  438. dataGridView_Holes.Rows.RemoveAt(index);
  439. }
  440. bool CheckParams()
  441. {
  442. double dout;
  443. if (!double.TryParse(tBoundaryX.Text,out dout))
  444. {
  445. return false;
  446. }
  447. if (!double.TryParse(tBoundaryY.Text, out dout))
  448. {
  449. return false;
  450. }
  451. if (!double.TryParse(tBoundaryWide.Text, out dout))
  452. {
  453. return false;
  454. }
  455. if (!double.TryParse(tBoundaryHeight.Text, out dout))
  456. {
  457. return false;
  458. }
  459. if (!double.TryParse(tStandardsampleX.Text, out dout))
  460. {
  461. return false;
  462. }
  463. if (!double.TryParse(tStandardsampleY.Text, out dout))
  464. {
  465. return false;
  466. }
  467. if (!double.TryParse(tStandardsampleWide.Text, out dout))
  468. {
  469. return false;
  470. }
  471. if (!double.TryParse(tStandardsampleHeight.Text, out dout))
  472. {
  473. return false;
  474. }
  475. for (int i=0;i<dataGridView_Holes.Rows.Count;i++)
  476. {
  477. for(int j=2;j<=5;j++)
  478. {
  479. if (!double.TryParse(dataGridView_Holes.Rows[i].Cells[j].Value.ToString(), out dout))
  480. {
  481. return false;
  482. }
  483. }
  484. }
  485. return true;
  486. }
  487. private void m_ctrlStagePicture_Paint(object sender, PaintEventArgs e)
  488. {
  489. }
  490. private void DlgStageEdit_Paint(object sender, PaintEventArgs e)
  491. {
  492. }
  493. private void DlgStageEdit_HelpButtonClicked(object sender, CancelEventArgs e)
  494. {
  495. MessageBox.Show("样品台文件说明\n样品台名行只能有一个字符串参数。样品台名不能为空字串,不能含\',\'字符\n样品台边框行有5个数值参数。形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0\n标样信息行有5个数值参数。形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0\n样品孔信息行有6个数值参数,1个字符串参数,5个数值参数。1个字符串参数为样品孔名。5个数值参数为形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0。", "Help",MessageBoxButtons.OK,MessageBoxIcon.Information);
  496. }
  497. private void button_Coordinate_Click(object sender, EventArgs e)
  498. {
  499. if (button_Coordinate.Text == "坐标系显示")
  500. {
  501. Object pDC = new Object();
  502. pDC = m_ctrlStagePicture.CreateGraphics();
  503. Rectangle rc = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
  504. int nWidth = (int)rc.Width;
  505. int nHeight = (int)rc.Height;
  506. double nBounderyWidth = 0;//um,,pixle is (nWidth - PIC_EDGE * 2 )
  507. double nBounderyHeight = 0;
  508. if(double.TryParse(tBoundaryWide.Text,out nBounderyWidth))
  509. {
  510. nBounderyWidth = double.Parse(tBoundaryWide.Text);
  511. }
  512. else
  513. {
  514. nBounderyWidth = 50000;
  515. }
  516. if (double.TryParse(tBoundaryHeight.Text, out nBounderyHeight))
  517. {
  518. nBounderyHeight = double.Parse(tBoundaryHeight.Text);
  519. }
  520. else
  521. {
  522. nBounderyHeight = 50000;
  523. }
  524. double PixSize = 0;
  525. double coordinateSystemEndpointX = nBounderyWidth / 2;
  526. double coordinateSystemEndpointY= nBounderyHeight / 2;
  527. if(radioButton_BoundaryCircle.Checked)
  528. {
  529. coordinateSystemEndpointY = coordinateSystemEndpointX;
  530. }
  531. if (nBounderyWidth > nBounderyHeight)
  532. {
  533. PixSize = (long)((double)nBounderyWidth / (double)(nWidth - StageDisplayHelp.PIC_EDGE * 2));
  534. }
  535. else
  536. {
  537. PixSize = (long)((double)nBounderyHeight / (double)(nHeight - StageDisplayHelp.PIC_EDGE * 2));
  538. }
  539. stageDisplayHelp.DrawXY(pDC, m_ctrlStagePicture.Width, m_ctrlStagePicture.Height, PixSize, coordinateSystemEndpointX,coordinateSystemEndpointY);
  540. button_Coordinate.Text = "坐标系关闭";
  541. }
  542. else
  543. {
  544. if(m_pStage != null)
  545. {
  546. DrawStage();
  547. }
  548. else
  549. {
  550. m_ctrlStagePicture.Refresh();
  551. }
  552. button_Coordinate.Text = "坐标系显示";
  553. }
  554. }
  555. }
  556. }