SlopFocus.cs 4.7 KB

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