DlgStageEdit.cs 24 KB

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