123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- 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;
- }
- }
- }
|