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._7_OTSProgMgrInfo { public partial class OtherSelectionForm : Form { string _OtherSelection = ""; public string OtherSelection { set { _OtherSelection = value; } get { return _OtherSelection; } } public OtherSelectionForm() { InitializeComponent(); } private void OtherSelection_Load(object sender, EventArgs e) { Init(); } private void btn_ok_Click(object sender, EventArgs e) { if(!CheckAndSaveParams()) { MessageBox.Show("Please check params!"); return; } this.DialogResult = DialogResult.OK; } void Init() { string[] strit = _OtherSelection.Split(','); foreach( string str in strit) { string[] stit = str.Split(':'); switch(stit[0]) { case "dmax": cB_Dmax.Checked = true; string[] sit = stit[1].Split('-'); tB_Dmax_min.Text = sit[0]; tB_Dmax_max.Text = sit[1]; break; case "dmin": cB_Dmin.Checked = true; string[] sit1 = stit[1].Split('-'); tB_Dmin_min.Text = sit1[0]; tB_Dmin_max.Text = sit1[1]; break; case "aspect": cB_Aspect.Checked = true; string[] sit2 = stit[1].Split('-'); tB_Aspect_min.Text = sit2[0]; tB_Aspect_max.Text = sit2[1]; break; case "ferret": cB_Ferret.Checked = true; string[] sit4 = stit[1].Split('-'); tB_Ferret_min.Text = sit4[0]; tB_Ferret_max.Text = sit4[1]; break; case "orientation": cB_orientation.Checked = true; string[] sit3 = stit[1].Split('-'); tB_orientation_min.Text = sit3[0]; tB_orientation_max.Text = sit3[1]; break; default: break; } } } bool CheckAndSaveParams() { _OtherSelection = ""; double dia; if (cB_Dmax.Checked) { if (!double.TryParse(tB_Dmax_min.Text, out dia)) { return false; } _OtherSelection += "dmax:" + dia.ToString() + "-"; if (!double.TryParse(tB_Dmax_max.Text, out dia)) { return false; } if(double.Parse(tB_Dmax_min.Text)>=dia) { return false; } _OtherSelection += dia.ToString() + ","; } if (cB_Dmin.Checked) { if (!double.TryParse(tB_Dmin_min.Text, out dia)) { return false; } _OtherSelection += "dmin:" + dia.ToString() + "-"; if (!double.TryParse(tB_Dmin_max.Text, out dia)) { return false; } if (double.Parse(tB_Dmin_min.Text) >= dia) { return false; } _OtherSelection += dia.ToString() + ","; } if (cB_Aspect.Checked) { if (!double.TryParse(tB_Aspect_min.Text, out dia)) { return false; } _OtherSelection += "aspect:" + dia.ToString() + "-"; if (!double.TryParse(tB_Aspect_max.Text, out dia)) { return false; } if (double.Parse(tB_Aspect_min.Text) >= dia) { return false; } _OtherSelection += dia.ToString() + ","; } if (cB_orientation.Checked) { if (!double.TryParse(tB_orientation_min.Text, out dia)) { return false; } _OtherSelection += "orientation:" + dia.ToString() + "-"; if (!double.TryParse(tB_orientation_max.Text, out dia)) { return false; } if (double.Parse(tB_orientation_min.Text) >= dia) { return false; } _OtherSelection += dia.ToString() +","; } if (cB_Ferret.Checked) { if (!double.TryParse(tB_Ferret_min.Text, out dia)) { return false; } _OtherSelection += "ferret:" + dia.ToString() + "-"; if (!double.TryParse(tB_Ferret_max.Text, out dia)) { return false; } if (double.Parse(tB_Ferret_min.Text) >= dia) { return false; } _OtherSelection += dia.ToString() + ","; } if (_OtherSelection!="") { _OtherSelection=_OtherSelection.Substring(0, _OtherSelection.Length - 1); } return true; } private void btn_cancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } } }