using OTSCLRINTERFACE; using OTSDataType; using OTSMeasureApp._0_OTSModel.OTSDataType; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace OTSMeasureApp._5_OTSMeasureStatuImageFun { public partial class SlopFocus : Form { COTSControlFunExport cfun; CSlopFocusParam slopFocusParam; bool m_result=false; OTSSamplespaceWindow oTSSamplespaceWindow; public bool result {get => m_result; set => m_result = value; } public SlopFocus(OTSSamplespaceWindow a_oTSSamplespaceWindow) { InitializeComponent(); oTSSamplespaceWindow = a_oTSSamplespaceWindow; } public CSlopFocusParam GetCSlopFocusParam() { return slopFocusParam; } private void bn_OK_Click(object sender, EventArgs e) { double iPX1, iPY1, iPX2, iPY2, iPX3,iPY3; iPX1 = iPY1 = iPX2 = iPY2 = iPX3=iPY3 = 0; double dPW1, dPW2, dPW3; dPW1 = dPW2 = dPW3 = 0; if(!double.TryParse(tB_FirstPointX.Text,out iPX1)|| !double.TryParse(tB_FirstPointY.Text, out iPY1) || !double.TryParse(tB_SecondPointX.Text, out iPX2) || !double.TryParse(tB_SecondPointY.Text, out iPY2) || !double.TryParse(tB_ThirdPointX.Text, out iPX3) || !double.TryParse(tB_ThirdPointY.Text, out iPY3) || !double.TryParse(tB_FirstPointD.Text, out dPW1) || !double.TryParse(tB_SecondPointD.Text, out dPW2) || !double.TryParse(tB_ThirdPointD.Text, out dPW3)) { MessageBox.Show("Please check Params!"); return; } if((tB_FirstPointX.Text== tB_SecondPointX.Text&& tB_FirstPointY.Text== tB_SecondPointY.Text)||(tB_FirstPointX.Text== tB_ThirdPointX.Text&& tB_FirstPointY.Text== tB_ThirdPointY.Text)||(tB_SecondPointX.Text== tB_ThirdPointX.Text&& tB_SecondPointY.Text== tB_ThirdPointY.Text)) { MessageBox.Show("Please select different points!"); return; } if(slopFocusParam==null) { slopFocusParam = new CSlopFocusParam(); } slopFocusParam.IsUsingSlopParam = cB_enable.Checked; slopFocusParam.FirstPoint = new Point((int)iPX1, (int)iPY1); slopFocusParam.FirstWD = dPW1; slopFocusParam.SecondPoint = new Point((int)iPX2, (int)iPY2); slopFocusParam.SecondWD = dPW2; slopFocusParam.ThirdPoint = new Point((int)iPX3, (int)iPY3); slopFocusParam.ThirdWD = dPW3; oTSSamplespaceWindow.setSlopFocusParam(this); this.Hide(); } private void SlopFocus_Load(object sender, EventArgs e) { if(cfun==null) { cfun = COTSControlFunExport.GetControllerInstance(); } } private void bn_FirstPoint_Click(object sender, EventArgs e) { //double a, b, c; //a = b = 20; //c = 20; //cfun.SetSemPositionXY(a, b, c); //cfun.SetSemWorkingDistance(c); double Px = 0; double Py = 0; double Pr = 0; if(cfun.GetSemPositionXY(ref Px,ref Py,ref Pr)) { tB_FirstPointX.Text = Px.ToString(); tB_FirstPointY.Text = Py.ToString(); } double WD = 0; if(cfun.GetSemWorkingDistance(ref WD)) { tB_FirstPointD.Text = WD.ToString(); } } private void bn_SecondPoint_Click(object sender, EventArgs e) { //double a, b, c; //a = b = 10; //c = 10; //cfun.SetSemPositionXY(a, b, c); //cfun.SetSemWorkingDistance(c); double Px = 0; double Py = 0; double Pr = 0; if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr)) { tB_SecondPointX.Text = Px.ToString(); tB_SecondPointY.Text = Py.ToString(); } double WD = 0; if (cfun.GetSemWorkingDistance(ref WD)) { tB_SecondPointD.Text = WD.ToString(); } } private void bn_ThirdPoint_Click(object sender, EventArgs e) { //double a, b, c; //a = b = 30; //c = 30; //cfun.SetSemPositionXY(a, b, c); //cfun.SetSemWorkingDistance(c); double Px = 0; double Py = 0; double Pr = 0; if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr)) { tB_ThirdPointX.Text = Px.ToString(); tB_ThirdPointY.Text = Py.ToString(); } double WD = 0; if (cfun.GetSemWorkingDistance(ref WD)) { tB_ThirdPointD.Text = WD.ToString(); } } private void bn_Cancel_Click(object sender, EventArgs e) { m_result = false; this.Hide(); } } }