SlopFocus.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using OTSCLRINTERFACE;
  2. using OTSDataType;
  3. using OTSMeasureApp._0_OTSModel.OTSDataType;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace OTSMeasureApp._5_OTSMeasureStatuImageFun
  15. {
  16. public partial class SlopFocus : Form
  17. {
  18. COTSControlFunExport cfun;
  19. CSlopFocusParam slopFocusParam;
  20. bool m_result=false;
  21. OTSSamplespaceWindow oTSSamplespaceWindow;
  22. public bool result {get => m_result; set => m_result = value; }
  23. //国际化
  24. OTSCommon.Language lan;
  25. Hashtable table;
  26. public SlopFocus(OTSSamplespaceWindow a_oTSSamplespaceWindow)
  27. {
  28. InitializeComponent();
  29. oTSSamplespaceWindow = a_oTSSamplespaceWindow;
  30. //国际化
  31. lan = new OTSCommon.Language(this);
  32. table = lan.GetNameTable(this.Name);
  33. }
  34. public CSlopFocusParam GetCSlopFocusParam()
  35. {
  36. return slopFocusParam;
  37. }
  38. private void bn_OK_Click(object sender, EventArgs e)
  39. {
  40. double iPX1, iPY1, iPX2, iPY2, iPX3,iPY3;
  41. iPX1 = iPY1 = iPX2 = iPY2 = iPX3=iPY3 = 0;
  42. double dPW1, dPW2, dPW3;
  43. dPW1 = dPW2 = dPW3 = 0;
  44. 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))
  45. {
  46. MessageBox.Show("Please check Params!");
  47. return;
  48. }
  49. 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))
  50. {
  51. MessageBox.Show("Please select different points!");
  52. return;
  53. }
  54. if(slopFocusParam==null)
  55. {
  56. slopFocusParam = new CSlopFocusParam();
  57. }
  58. slopFocusParam.IsUsingSlopParam = cB_enable.Checked;
  59. slopFocusParam.FirstPoint = new Point((int)iPX1, (int)iPY1);
  60. slopFocusParam.FirstWD = dPW1;
  61. slopFocusParam.SecondPoint = new Point((int)iPX2, (int)iPY2);
  62. slopFocusParam.SecondWD = dPW2;
  63. slopFocusParam.ThirdPoint = new Point((int)iPX3, (int)iPY3);
  64. slopFocusParam.ThirdWD = dPW3;
  65. oTSSamplespaceWindow.setSlopFocusParam(this);
  66. this.Hide();
  67. }
  68. private void SlopFocus_Load(object sender, EventArgs e)
  69. {
  70. if(cfun==null)
  71. {
  72. cfun = COTSControlFunExport.GetControllerInstance();
  73. }
  74. }
  75. private void bn_FirstPoint_Click(object sender, EventArgs e)
  76. {
  77. //double a, b, c;
  78. //a = b = 20;
  79. //c = 20;
  80. //cfun.SetSemPositionXY(a, b, c);
  81. //cfun.SetSemWorkingDistance(c);
  82. double Px = 0;
  83. double Py = 0;
  84. double Pr = 0;
  85. if(cfun.GetSemPositionXY(ref Px,ref Py,ref Pr))
  86. {
  87. tB_FirstPointX.Text = Px.ToString();
  88. tB_FirstPointY.Text = Py.ToString();
  89. }
  90. double WD = 0;
  91. if(cfun.GetSemWorkingDistance(ref WD))
  92. {
  93. tB_FirstPointD.Text = WD.ToString();
  94. }
  95. }
  96. private void bn_SecondPoint_Click(object sender, EventArgs e)
  97. {
  98. //double a, b, c;
  99. //a = b = 10;
  100. //c = 10;
  101. //cfun.SetSemPositionXY(a, b, c);
  102. //cfun.SetSemWorkingDistance(c);
  103. double Px = 0;
  104. double Py = 0;
  105. double Pr = 0;
  106. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  107. {
  108. tB_SecondPointX.Text = Px.ToString();
  109. tB_SecondPointY.Text = Py.ToString();
  110. }
  111. double WD = 0;
  112. if (cfun.GetSemWorkingDistance(ref WD))
  113. {
  114. tB_SecondPointD.Text = WD.ToString();
  115. }
  116. }
  117. private void bn_ThirdPoint_Click(object sender, EventArgs e)
  118. {
  119. //double a, b, c;
  120. //a = b = 30;
  121. //c = 30;
  122. //cfun.SetSemPositionXY(a, b, c);
  123. //cfun.SetSemWorkingDistance(c);
  124. double Px = 0;
  125. double Py = 0;
  126. double Pr = 0;
  127. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  128. {
  129. tB_ThirdPointX.Text = Px.ToString();
  130. tB_ThirdPointY.Text = Py.ToString();
  131. }
  132. double WD = 0;
  133. if (cfun.GetSemWorkingDistance(ref WD))
  134. {
  135. tB_ThirdPointD.Text = WD.ToString();
  136. }
  137. }
  138. private void bn_Cancel_Click(object sender, EventArgs e)
  139. {
  140. m_result = false;
  141. this.Hide();
  142. }
  143. private void SlopFocus_FormClosing(object sender, FormClosingEventArgs e)
  144. {
  145. e.Cancel = true;
  146. this.Hide();
  147. }
  148. }
  149. }