OtherSelection.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace OTSMeasureApp._7_OTSProgMgrInfo
  11. {
  12. public partial class OtherSelectionForm : Form
  13. {
  14. string _OtherSelection = "";
  15. public string OtherSelection
  16. {
  17. set
  18. {
  19. _OtherSelection = value;
  20. }
  21. get
  22. {
  23. return _OtherSelection;
  24. }
  25. }
  26. public OtherSelectionForm()
  27. {
  28. InitializeComponent();
  29. }
  30. private void OtherSelection_Load(object sender, EventArgs e)
  31. {
  32. Init();
  33. }
  34. private void btn_ok_Click(object sender, EventArgs e)
  35. {
  36. if(!CheckAndSaveParams())
  37. {
  38. MessageBox.Show("Please check params!");
  39. return;
  40. }
  41. this.DialogResult = DialogResult.OK;
  42. }
  43. void Init()
  44. {
  45. string[] strit = _OtherSelection.Split(',');
  46. foreach( string str in strit)
  47. {
  48. string[] stit = str.Split(':');
  49. switch(stit[0])
  50. {
  51. case "dmax":
  52. cB_Dmax.Checked = true;
  53. string[] sit = stit[1].Split('-');
  54. tB_Dmax_min.Text = sit[0];
  55. tB_Dmax_max.Text = sit[1];
  56. break;
  57. case "dmin":
  58. cB_Dmin.Checked = true;
  59. string[] sit1 = stit[1].Split('-');
  60. tB_Dmin_min.Text = sit1[0];
  61. tB_Dmin_max.Text = sit1[1];
  62. break;
  63. case "aspect":
  64. cB_Aspect.Checked = true;
  65. string[] sit2 = stit[1].Split('-');
  66. tB_Aspect_min.Text = sit2[0];
  67. tB_Aspect_max.Text = sit2[1];
  68. break;
  69. case "ferret":
  70. cB_Ferret.Checked = true;
  71. string[] sit4 = stit[1].Split('-');
  72. tB_Ferret_min.Text = sit4[0];
  73. tB_Ferret_max.Text = sit4[1];
  74. break;
  75. case "orientation":
  76. cB_orientation.Checked = true;
  77. string[] sit3 = stit[1].Split('-');
  78. tB_orientation_min.Text = sit3[0];
  79. tB_orientation_max.Text = sit3[1];
  80. break;
  81. default:
  82. break;
  83. }
  84. }
  85. }
  86. bool CheckAndSaveParams()
  87. {
  88. _OtherSelection = "";
  89. double dia;
  90. if (cB_Dmax.Checked)
  91. {
  92. if (!double.TryParse(tB_Dmax_min.Text, out dia))
  93. {
  94. return false;
  95. }
  96. _OtherSelection += "dmax:" + dia.ToString() + "-";
  97. if (!double.TryParse(tB_Dmax_max.Text, out dia))
  98. {
  99. return false;
  100. }
  101. if(double.Parse(tB_Dmax_min.Text)>=dia)
  102. {
  103. return false;
  104. }
  105. _OtherSelection += dia.ToString() + ",";
  106. }
  107. if (cB_Dmin.Checked)
  108. {
  109. if (!double.TryParse(tB_Dmin_min.Text, out dia))
  110. {
  111. return false;
  112. }
  113. _OtherSelection += "dmin:" + dia.ToString() + "-";
  114. if (!double.TryParse(tB_Dmin_max.Text, out dia))
  115. {
  116. return false;
  117. }
  118. if (double.Parse(tB_Dmin_min.Text) >= dia)
  119. {
  120. return false;
  121. }
  122. _OtherSelection += dia.ToString() + ",";
  123. }
  124. if (cB_Aspect.Checked)
  125. {
  126. if (!double.TryParse(tB_Aspect_min.Text, out dia))
  127. {
  128. return false;
  129. }
  130. _OtherSelection += "aspect:" + dia.ToString() + "-";
  131. if (!double.TryParse(tB_Aspect_max.Text, out dia))
  132. {
  133. return false;
  134. }
  135. if (double.Parse(tB_Aspect_min.Text) >= dia)
  136. {
  137. return false;
  138. }
  139. _OtherSelection += dia.ToString() + ",";
  140. }
  141. if (cB_orientation.Checked)
  142. {
  143. if (!double.TryParse(tB_orientation_min.Text, out dia))
  144. {
  145. return false;
  146. }
  147. _OtherSelection += "orientation:" + dia.ToString() + "-";
  148. if (!double.TryParse(tB_orientation_max.Text, out dia))
  149. {
  150. return false;
  151. }
  152. if (double.Parse(tB_orientation_min.Text) >= dia)
  153. {
  154. return false;
  155. }
  156. _OtherSelection += dia.ToString() +",";
  157. }
  158. if (cB_Ferret.Checked)
  159. {
  160. if (!double.TryParse(tB_Ferret_min.Text, out dia))
  161. {
  162. return false;
  163. }
  164. _OtherSelection += "ferret:" + dia.ToString() + "-";
  165. if (!double.TryParse(tB_Ferret_max.Text, out dia))
  166. {
  167. return false;
  168. }
  169. if (double.Parse(tB_Ferret_min.Text) >= dia)
  170. {
  171. return false;
  172. }
  173. _OtherSelection += dia.ToString() + ",";
  174. }
  175. if (_OtherSelection!="")
  176. {
  177. _OtherSelection=_OtherSelection.Substring(0, _OtherSelection.Length - 1);
  178. }
  179. return true;
  180. }
  181. private void btn_cancel_Click(object sender, EventArgs e)
  182. {
  183. this.DialogResult = DialogResult.Cancel;
  184. }
  185. }
  186. }