55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
///
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Forms;
|
|
using Workplace.Resources;
|
|
|
|
namespace Workplace.Forms
|
|
{
|
|
public partial class WeightLimitsDlg : Form
|
|
{
|
|
public double MinWeight;
|
|
public double MaxWeight;
|
|
public string WeightOptionsWay;
|
|
|
|
public WeightLimitsDlg(double min, double max)
|
|
{
|
|
InitializeComponent();
|
|
MinWeight = min;
|
|
MaxWeight = max;
|
|
minWeightTextBox.Text = min.ToString("F1");
|
|
maxWeightTextBox.Text = max.ToString("F1");
|
|
Localize();
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
Text = Strings.Enter_weight_limits;
|
|
minWeightLabel.Text = Strings.Min_weight + " [g]";
|
|
maxWeightLabel.Text = Strings.Max_weight + " [g]";
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
if ((double.TryParse(minWeightTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out MinWeight) ||
|
|
double.TryParse(minWeightTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out MinWeight)) &&
|
|
(double.TryParse(maxWeightTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out MaxWeight) ||
|
|
double.TryParse(maxWeightTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out MaxWeight)) &&
|
|
MaxWeight > MinWeight &&
|
|
MinWeight >= 0)
|
|
{
|
|
WeightOptionsWay = Strings.Weight_limits_were_entered_manually;
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
asterixLabel.Visible = true;
|
|
DialogResult = DialogResult.None;
|
|
}
|
|
}
|
|
}
|
|
}
|