123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670 |
- using OTSDataType;
- using OTSModelSharp;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using OTSModelSharp.Measure.GetStageInfo;
- namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
- {
- public partial class DlgStageEdit : Form
- {
- // stage file
- //CStageParam m_pStageFile;
- public CStage Stage;
- StageDisplayHelp stageDisplayHelp;
- OTSCommon.Language lan;
- System.Collections.Hashtable hashtable;
- List<string> StageNames = new List<string>();
- public DlgStageEdit(List<string> a_StageNames)
- {
- InitializeComponent();
- StageNames = a_StageNames;
- }
-
- public DlgStageEdit(CStage a_Stage,List<string> a_StageNames)
- {
- InitializeComponent();
- Stage = a_Stage;
- StageNames = a_StageNames;
- }
- ComboBox cmb_Temp = new ComboBox();
- private void DlgStageEdit_Load(object sender, EventArgs e)
- {
- lan = new OTSCommon.Language(this);
- hashtable = lan.GetNameTable(this.Name);
- radioButton_OTS.Checked = true;
- radioButton_BoundarySquare.Checked = true;
- radioButton_StandardsampleSqare.Checked = true;
- string str = hashtable["str1"].ToString();
- dataGridView_Holes.Columns.Add("HoleName", str);
- str = hashtable["str2"].ToString();
- dataGridView_Holes.Columns.Add("HoleShape", str);
- str = hashtable["str3"].ToString();
- dataGridView_Holes.Columns.Add("CenterCoordinatesX", str);
- str = hashtable["str4"].ToString();
- dataGridView_Holes.Columns.Add("CenterCoordinatesY", str);
- str = hashtable["str5"].ToString();
- dataGridView_Holes.Columns.Add("Param1", str);
- str = hashtable["str6"].ToString();
- dataGridView_Holes.Columns.Add("Param2", str);
- str = hashtable["str7"].ToString();
- dataGridView_Holes.Rows.Add("1", str, -4250, -16000, 12000, 0);
-
- cmb_Temp.Visible = false;
- cmb_Temp.Items.Add(str);
- str = hashtable["str8"].ToString();
- cmb_Temp.Items.Add(str);
- cmb_Temp.SelectedIndexChanged += new EventHandler(cmb_Temp_SelectedIndexChanged);
- dataGridView_Holes.Controls.Add(cmb_Temp);
- stageDisplayHelp = new StageDisplayHelp();
- if(Stage!=null)
- {
- LoadStageData(Stage);
- }
- SetHelp();
- StageNames.Remove(tStageName.Text.Trim());
- }
- void SetHelp()
- {
- string str = hashtable["str9"].ToString();
- helpProvider1.SetHelpString(label1, "样品台名不能为空字串,不能含\',\'字符!");
- helpProvider1.SetHelpString(groupBox1, "样品台边框行有5个数值参数。形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0");
- helpProvider1.SetHelpString(groupBox2, "标样信息行有5个数值参数。形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0");
- helpProvider1.SetHelpString(groupBox3, "样品孔信息行有6个数值参数,1个字符串参数,5个数值参数。1个字符串参数为样品孔名。5个数值参数为形状参数,中心x坐标,中心y坐标,宽度或直径,高度或0。");
- }
- void LoadStageData(CStage cStage)
- {
- tStageName.Text = Stage.GetName();
- if(Stage.GetBoundary().GetShape()== otsdataconst.DOMAIN_SHAPE.ROUND)
- {
- radioButton_BoundaryCircle.Checked = true;
- tBoundaryWide.Text = Stage.GetBoundary().GetDiameter().ToString();
- tBoundaryWide.Enabled = false;
- tBoundaryHeight.Text = "0";
- }
- else
- {
- radioButton_BoundarySquare.Checked = true;
- tBoundaryWide.Text = Stage.GetBoundary().GetRectDomain().Width.ToString();
- tBoundaryWide.Enabled = true;
- tBoundaryHeight.Text = Stage.GetBoundary().GetRectDomain().Height.ToString();
- }
- tBoundaryX.Text= Stage.GetBoundary().GetDomainCenter().X.ToString();
- tBoundaryY.Text = Stage.GetBoundary().GetDomainCenter().Y.ToString();
- if(Stage.GetSTD().GetShape()== otsdataconst.DOMAIN_SHAPE.ROUND)
- {
- radioButton_StandardsampleCircle.Checked = true;
- tStandardsampleHeight.Enabled = false;
- tStandardsampleWide.Text = Stage.GetSTD().GetDiameter().ToString();
- }
- else
- {
- radioButton_StandardsampleSqare.Checked = true;
- tStandardsampleHeight.Enabled =true;
- tStandardsampleWide.Text = Stage.GetSTD().GetRectDomain().Width.ToString();
- }
- tStandardsampleX.Text = Stage.GetSTD().GetDomainCenter().X.ToString();
- tStandardsampleY.Text = Stage.GetSTD().GetDomainCenter().Y.ToString();
- tStandardsampleHeight.Text = Stage.GetSTD().GetRectDomain().Height.ToString();
- dataGridView_Holes.Rows[0].Cells[0].Value = Stage.GetHoleList()[0].GetName();
- if (Stage.GetHoleList()[0].GetShape() == otsdataconst.DOMAIN_SHAPE.ROUND)
- {
- dataGridView_Holes.Rows[0].Cells[1].Value = "圆形";
- dataGridView_Holes.Rows[0].Cells[4].Value = Stage.GetHoleList()[0].GetDiameter().ToString();
- dataGridView_Holes.Rows[0].Cells[5].Value = "0";
- }
- else
- {
- dataGridView_Holes.Rows[0].Cells[1].Value = "方形";
- dataGridView_Holes.Rows[0].Cells[4].Value = Stage.GetHoleList()[0].GetRectDomain().Width.ToString();
- dataGridView_Holes.Rows[0].Cells[5].Value = Stage.GetHoleList()[0].GetRectDomain().Height.ToString();
- }
-
- dataGridView_Holes.Rows[0].Cells[2].Value = Stage.GetHoleList()[0].GetDomainCenter().X.ToString();
- dataGridView_Holes.Rows[0].Cells[3].Value = Stage.GetHoleList()[0].GetDomainCenter().Y.ToString();
-
- for (int i=1;i< Stage.GetHoleList().Count;i++)
- {
- string sr = "";
- string pra1 = "";
- string pra2 = "";
- if (Stage.GetHoleList()[i].GetShape() == otsdataconst.DOMAIN_SHAPE.ROUND)
- {
- sr= "圆形";
- pra1 = Stage.GetHoleList()[i].GetDiameter().ToString();
- pra2 = "0";
- }
- else
- {
- sr= "方形";
- pra1 = Stage.GetHoleList()[i].GetRectDomain().Width.ToString();
- pra2 = Stage.GetHoleList()[i].GetRectDomain().Height.ToString();
- }
- dataGridView_Holes.Rows.Add(Stage.GetHoleList()[i].GetName(), sr, Stage.GetHoleList()[i].GetDomainCenter().X.ToString(), Stage.GetHoleList()[i].GetDomainCenter().Y.ToString(), pra1, pra2);
- }
- }
- private void radioButton_BoundaryCircle_Click(object sender, EventArgs e)
- {
- label8.Enabled = false;
- tBoundaryHeight.Enabled = false;
- tBoundaryHeight.Text = "0";
- label7.Text = "直径:";
- }
- private void radioButton_BoundarySquare_Click(object sender, EventArgs e)
- {
- label8.Enabled = true;
- tBoundaryHeight.Enabled = true;
- label7.Text = "宽度:";
- }
- private void radioButton_StandardsampleCircle_Click(object sender, EventArgs e)
- {
- label9.Enabled = false;
- tStandardsampleHeight.Enabled = false;
- tStandardsampleHeight.Text = "0";
- label10.Text = "直径:";
- }
- private void radioButton__StandardsampleSqare_Click(object sender, EventArgs e)
- {
- label9.Enabled = true;
- tStandardsampleHeight.Enabled = true;
- label10.Text = "宽度:";
- }
- private void dataGridView_Holes_CurrentCellChanged(object sender, EventArgs e)
- {
- if(dataGridView_Holes.CurrentRow==null)
- {
- return;
- }
- if(dataGridView_Holes.CurrentCell.ColumnIndex==1)
- {
- Rectangle rect = dataGridView_Holes.GetCellDisplayRectangle(dataGridView_Holes.CurrentCell.ColumnIndex, dataGridView_Holes.CurrentCell.RowIndex, false);
- string HoleShape = dataGridView_Holes.CurrentCell.Value.ToString();
- cmb_Temp.Left = rect.Left;
- cmb_Temp.Top = rect.Top;
- cmb_Temp.Width = rect.Width;
- cmb_Temp.SelectedIndex = 0;
- cmb_Temp.Visible = true;
- }
- else
- {
- cmb_Temp.Visible = false;
- }
- }
- void cmb_Temp_SelectedIndexChanged(object sender ,EventArgs e)
- {
-
- if (dataGridView_Holes.CurrentRow == null)
- {
- return;
- }
- if (((ComboBox)sender).SelectedIndex == 0)
- {
- dataGridView_Holes.CurrentCell.Value = "圆形";
- dataGridView_Holes.CurrentRow.Cells[5].Value = 0;
- }
- else
- {
- dataGridView_Holes.CurrentCell.Value = "方形";
- dataGridView_Holes.CurrentRow.Cells[5].Value = "";
- }
-
- }
- private void dataGridView_Holes_Scroll(object sender, ScrollEventArgs e)
- {
- this.cmb_Temp.Visible = false;
- }
- private void button_Generate_Click(object sender, EventArgs e)
- {
- if(StageNames.Contains(tStageName.Text.Trim()))
- {
- MessageBox.Show("Already exist " + tStageName.Text.Trim() + "!", "Error");
- return;
- }
- if (!CheckParams())
- {
- this.button_Ok.Enabled = false;
- MessageBox.Show("Please check Params!");
- return;
- }
- if (tBoundaryWide.Text == "1" || tBoundaryHeight.Text == "1" || tStandardsampleWide.Text == "1" || tStandardsampleHeight.Text == "1")
- {
- this.button_Ok.Enabled = false;
- MessageBox.Show("The length value cannot be 1!");
- return;
- }
- for (int i = 0; i < dataGridView_Holes.Rows.Count; i++)
- {
- for (int j = 4; j <= 5; j++)
- {
- if (dataGridView_Holes.Rows[i].Cells[j].Value.ToString() == "1")
- {
- this.button_Ok.Enabled = false;
- MessageBox.Show("The length value cannot be 1!");
- return;
- }
- }
- }
- CSEMStageData a_pCSEMStageData = new CSEMStageData();
- //获取配置文件中 StageData 内容
- COTSDefaultParam m_DefaultParam = new COTSDefaultParam();
- m_DefaultParam.LoadInfoFromProgMgrFile();
- a_pCSEMStageData = m_DefaultParam.GetStageDataParam();
- Stage = new CStage();
- Stage.SetName(tStageName.Text);
- // boundary
- string strValue = "";
- if(radioButton_BoundaryCircle.Checked)
- {
- strValue += "0";
- tBoundaryHeight.Text="0";
- }
- else
- {
- strValue += "1";
- }
- strValue += "," + tBoundaryX.Text+","+tBoundaryY.Text+","+tBoundaryWide.Text+","+ tBoundaryHeight.Text;
- CDomain pBoundary = stageDisplayHelp.GetDomain(strValue);
- // STD
- strValue = "";
- if(radioButton_StandardsampleCircle.Checked)
- {
- strValue += "0";
- tStandardsampleHeight.Text = "0";
- }
- else
- {
- strValue += "1";
- }
- strValue += "," + tStandardsampleX.Text + "," + tStandardsampleY.Text + "," + tStandardsampleWide.Text + "," + tStandardsampleHeight.Text;
- CDomain pSTD = stageDisplayHelp.GetDomain(strValue);
- // coordinate system
- CStageParam.COORDINATE_SYSTEM_SETTING nCoodrSysSetting = CStageParam.COORDINATE_SYSTEM_SETTING.INVALID;
- if(radioButton_OTS.Checked)
- {
- nCoodrSysSetting = (CStageParam.COORDINATE_SYSTEM_SETTING)0;
- }
- else
- {
- nCoodrSysSetting = (CStageParam.COORDINATE_SYSTEM_SETTING)1;
- }
- // Holes list
- List<CHole> listHoles = new List<CHole>();
- for(int i=0;i<dataGridView_Holes.Rows.Count;i++)
- {
- strValue = "";
- if(dataGridView_Holes.Rows[i].Cells[1].Value.ToString()=="圆形")
- {
- strValue += "0";
- }
- else
- {
- strValue += "1";
- }
- 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;
- CDomain pDomain = stageDisplayHelp.GetDomain(strValue);
- //add holes
- listHoles.Add(new CHole(dataGridView_Holes.Rows[i].Cells[0].Value.ToString(), pDomain));
- }
- // check stage components
- // name should be ok
- if (pBoundary == null)
- {
- return ;
- }
- if (pBoundary.IsInvalid())
- {
- // boundary is invalid
- return ;
- }
- if (pSTD != null)
- {
- // STD has to be inside of the boundary
- if (!pBoundary.DomainInDomain(pSTD))
- {
- MessageBox.Show("STD is over the boundary!");
- return;
- }
- }
- else
- {
- return;
- }
- // hole has to be inside of the boundary and can't have common part with STD and each other
- List<CHole> listStageHoles = new List<CHole>();
- foreach (var pHole in listHoles)
- {
- if (!pBoundary.DomainInDomain(pHole))
- {
- MessageBox.Show(pHole.GetName() + "is over the boundary, jump over!");
- continue;
- }
- else if (pSTD.IntersectDomain(pHole))
- {
- MessageBox.Show(pHole.GetName() + " has common part with STD, jump over!");
- continue;
- }
- bool bHasCommonPart = false;
- foreach (var pStageHole in listStageHoles)
- {
- if (pStageHole.IntersectDomain(pHole))
- {
- MessageBox.Show(pHole.GetName() + " has common part with a hole already on the stage!");
- bHasCommonPart = true;
- break;
- }
- }
- if (bHasCommonPart)
- {
- // this hole has common part with a hole already on the stage, jump over
- continue;
- }
- // the hole is ok, add it into stage holes list
- listStageHoles.Add(pHole);
- }
- if (listStageHoles.Count == 0)
- {
- // no hole at all
- return ;
- }
- // the stage is in SEM coordinate system, convert all components to OTS system
- if (nCoodrSysSetting == CStageParam.COORDINATE_SYSTEM_SETTING.SEM)
- {
- if (!a_pCSEMStageData.ConverSEMToOTSSystem(pBoundary, pSTD, listStageHoles))
- {
- return ;
- }
- }
- Stage.SetBoundary(pBoundary);
- Stage.SetSTD(pSTD);
- Stage.SetHoleList(listStageHoles, true);
- DrawStage();
- btn_reght90.Enabled = true;
- btn_left90.Enabled = true;
- this.button_Ok.Enabled = true;
- }
- public void DrawStage()
- {
- Rectangle rc = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
- //Rectangle re = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
- int pWnd = otsdataconst.IDC_PIC_STAGE;
- int nWidth = (int)rc.Width;
- int nHeight = (int)rc.Height;
- Object pDC = new Object();
- //bool DeleteObject = false;
- //paint the DC with white
- Brush pOldBrush = new SolidBrush(Color.FromArgb(50, Color.White));
- m_ctrlStagePicture.Refresh();
- //Image img = (Image)new Bitmap(m_ctrlStagePicture.Width, m_ctrlStagePicture.Height);
- //Graphics graphics = m_ctrlStagePicture.CreateGraphics();// Graphics.FromImage(img);
- //graphics.FillRectangle(new SolidBrush(Color.Beige), re);
- pDC = m_ctrlStagePicture.CreateGraphics();
- //消除锯齿
- ((Graphics)pDC).SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- ((Graphics)pDC).InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- ((Graphics)pDC).CompositingQuality = CompositingQuality.HighQuality;//再加一点
- //get stage information
- CDomain pBoundery = Stage.GetBoundary();// GetBoundary();
- System.Drawing.RectangleF BounderyRect = pBoundery.GetDomainRect();
- int nBounderyWidth = (int)(BounderyRect.Width);//um,,pixle is (nWidth - PIC_EDGE * 2 )
- int nBounderyHeight = 0;
- if (pBoundery.GetShape() == otsdataconst.DOMAIN_SHAPE.RECTANGLE)
- {nBounderyHeight = (int)(BounderyRect.Height);}
- else
- {
- nBounderyHeight = (int)(BounderyRect.Width);
- }
- double PixSize = 0;
- double coordinateSystemEndpoint /*= 0*/;
- if (nBounderyWidth > nBounderyHeight)
- {
- PixSize = (long)((double)nBounderyWidth / (double)(nWidth - StageDisplayHelp.PIC_EDGE * 2));
- coordinateSystemEndpoint = nBounderyWidth/2;
- }
- else
- {
- PixSize = (long)((double)nBounderyHeight / (double)(nHeight - StageDisplayHelp.PIC_EDGE * 2));
- coordinateSystemEndpoint = nBounderyHeight/2;
- }
- //draw boundery
- Brush pLTGrayBrush = new SolidBrush(Color.FromArgb(255, 0, 0));
- stageDisplayHelp.DrawStageBoundery(Stage, nWidth, nHeight, pDC, PixSize);
- //draw STD
- Brush pBlackBrush = new SolidBrush(Color.FromArgb(255, 0, 0));
- stageDisplayHelp.DrawStageSTD(Stage, nWidth, nHeight, pDC, PixSize);
- ////draw holes
- //Brush pWriteBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
- stageDisplayHelp.DrawStageHole(Stage, nWidth, nHeight, pDC, PixSize);
- // draw ratio
- stageDisplayHelp.DrawRatio(nBounderyWidth, nWidth, nHeight, pDC, (IntPtr)pWnd, rc);
- if (button_Coordinate.Text == "坐标系关闭")
- {
- double coordinateSystemEndpointX = nBounderyWidth / 2;
- double coordinateSystemEndpointY = nBounderyHeight / 2;
- stageDisplayHelp.DrawXY(pDC, m_ctrlStagePicture.Width, m_ctrlStagePicture.Height, PixSize, coordinateSystemEndpointX, coordinateSystemEndpointY);
- }
- pLTGrayBrush.Dispose();
- //pBlackBrush.Dispose();
- //pWriteBrush.Dispose();
- //graphics.Dispose();
- //((Graphics)pDC).Dispose();
- pOldBrush.Dispose();
- }
- private void button_Ok_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- private void button_AddHole_Click(object sender, EventArgs e)
- {
- dataGridView_Holes.Rows.Add("1", "圆形", -4250, -16000, 12000, 0);
- }
- private void button_DelHole_Click(object sender, EventArgs e)
- {
- if(dataGridView_Holes.Rows.Count<1)
- {
- return;
- }
- int index = dataGridView_Holes.CurrentCell.RowIndex;
- dataGridView_Holes.Rows.RemoveAt(index);
- }
- bool CheckParams()
- {
- double dout;
- if (!double.TryParse(tBoundaryX.Text,out dout))
- {
- return false;
- }
- if (!double.TryParse(tBoundaryY.Text, out dout))
- {
- return false;
- }
- if (!double.TryParse(tBoundaryWide.Text, out dout))
- {
- return false;
- }
- if (!double.TryParse(tBoundaryHeight.Text, out dout))
- {
- return false;
- }
- if (!double.TryParse(tStandardsampleX.Text, out dout))
- {
- return false;
- }
- if (!double.TryParse(tStandardsampleY.Text, out dout))
- {
- return false;
- }
- if (!double.TryParse(tStandardsampleWide.Text, out dout))
- {
- return false;
- }
- if (!double.TryParse(tStandardsampleHeight.Text, out dout))
- {
- return false;
- }
- for (int i=0;i<dataGridView_Holes.Rows.Count;i++)
- {
- for(int j=2;j<=5;j++)
- {
- if (!double.TryParse(dataGridView_Holes.Rows[i].Cells[j].Value.ToString(), out dout))
- {
- return false;
- }
- }
- }
- if (radioButton_BoundarySquare.Checked)
- {
- if (double.Parse(tBoundaryHeight.Text) == 0)
- {
- return false;
- }
- }
- if (radioButton_StandardsampleSqare.Checked)
- {
- if (double.Parse(tStandardsampleHeight.Text) == 0)
- {
- return false;
- }
- }
- return true;
- }
- private void m_ctrlStagePicture_Paint(object sender, PaintEventArgs e)
- {
- }
- private void DlgStageEdit_Paint(object sender, PaintEventArgs e)
- {
-
- }
- private void DlgStageEdit_HelpButtonClicked(object sender, CancelEventArgs e)
- {
- 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);
- }
- private void button_Coordinate_Click(object sender, EventArgs e)
- {
- if (button_Coordinate.Text == "坐标系显示")
- {
- Object pDC = new Object();
- pDC = m_ctrlStagePicture.CreateGraphics();
- Rectangle rc = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
- int nWidth = (int)rc.Width;
- int nHeight = (int)rc.Height;
- double nBounderyWidth = 0;//um,,pixle is (nWidth - PIC_EDGE * 2 )
- double nBounderyHeight = 0;
- if(double.TryParse(tBoundaryWide.Text,out nBounderyWidth))
- {
- nBounderyWidth = double.Parse(tBoundaryWide.Text);
- }
- else
- {
- nBounderyWidth = 50000;
- }
- if (double.TryParse(tBoundaryHeight.Text, out nBounderyHeight))
- {
- nBounderyHeight = double.Parse(tBoundaryHeight.Text);
- }
- else
- {
- nBounderyHeight = 50000;
- }
- double PixSize = 0;
- double coordinateSystemEndpointX = nBounderyWidth / 2;
- double coordinateSystemEndpointY= nBounderyHeight / 2;
- if(radioButton_BoundaryCircle.Checked)
- {
- coordinateSystemEndpointY = coordinateSystemEndpointX;
- }
- if (nBounderyWidth > nBounderyHeight)
- {
- PixSize = (long)((double)nBounderyWidth / (double)(nWidth - StageDisplayHelp.PIC_EDGE * 2));
- }
- else
- {
- PixSize = (long)((double)nBounderyHeight / (double)(nHeight - StageDisplayHelp.PIC_EDGE * 2));
- }
- stageDisplayHelp.DrawXY(pDC, m_ctrlStagePicture.Width, m_ctrlStagePicture.Height, PixSize, coordinateSystemEndpointX,coordinateSystemEndpointY);
- button_Coordinate.Text = "坐标系关闭";
- }
- else
- {
- button_Coordinate.Text = "坐标系显示";
- if(Stage != null)
- {
- DrawStage();
- }
- else
- {
- m_ctrlStagePicture.Refresh();
- }
- }
- }
- private void btn_reght90_Click(object sender, EventArgs e)
- {
- double it = 0;
- for (int i = 0; i < dataGridView_Holes.Rows.Count; i++)
- {
- it = Convert.ToDouble(dataGridView_Holes.Rows[i].Cells[3].Value);
- dataGridView_Holes.Rows[i].Cells[3].Value= -Convert.ToDouble(dataGridView_Holes.Rows[i].Cells[2].Value);
- dataGridView_Holes.Rows[i].Cells[2].Value = it;
- }
- dataGridView_Holes.Refresh();
- button_Generate_Click(null, null);
- }
- private void btn_left90_Click(object sender, EventArgs e)
- {
- double it = 0;
- for (int i = 0; i < dataGridView_Holes.Rows.Count; i++)
- {
- it = -Convert.ToDouble(dataGridView_Holes.Rows[i].Cells[3].Value);
- dataGridView_Holes.Rows[i].Cells[3].Value = Convert.ToDouble(dataGridView_Holes.Rows[i].Cells[2].Value);
- dataGridView_Holes.Rows[i].Cells[2].Value = it;
- }
- dataGridView_Holes.Refresh();
- button_Generate_Click(null, null);
- }
- }
- }
|