60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
|
|
using System;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace DataStreamInterfaceTest
|
|||
|
|
{
|
|||
|
|
public partial class GetDblValueDlg : Form
|
|||
|
|
{
|
|||
|
|
public double DblValue;
|
|||
|
|
|
|||
|
|
double lowerLimit;
|
|||
|
|
double upperLimit;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public GetDblValueDlg()
|
|||
|
|
: this("Enter flow in [m3/h] please")
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public GetDblValueDlg(string title)
|
|||
|
|
: this(title, 0, 100.0)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public GetDblValueDlg(string title, double lowerLimit, double upperLimit)
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
this.Text = title;
|
|||
|
|
this.lowerLimit = lowerLimit;
|
|||
|
|
this.upperLimit = upperLimit;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void okButton_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
double val;
|
|||
|
|
if (TryParseUDouble(valueTextBox.Text, out val))
|
|||
|
|
{
|
|||
|
|
DblValue = val;
|
|||
|
|
DialogResult = DialogResult.OK;
|
|||
|
|
Close();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Invalid value");
|
|||
|
|
DialogResult = DialogResult.None;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Parse an unsigned double number
|
|||
|
|
/// </summary>
|
|||
|
|
bool TryParseUDouble(string text, out double result)
|
|||
|
|
{
|
|||
|
|
return double.TryParse(text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out result) ||
|
|||
|
|
double.TryParse(text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|