78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace TBF.BenchControl.DataEntry.Munich3
|
|
{
|
|
public partial class CycleEndForm : Form, GenericDevices.IHasCompleted
|
|
{
|
|
/// <summary> Number of text boxes for serial numbers </summary>
|
|
public readonly int WaterMetersCount;
|
|
|
|
// To be set before the form opens
|
|
public string ProtocolName1;
|
|
public string ProtocolName2;
|
|
public string ProtocolName3;
|
|
|
|
// To be retrieved after the form closes
|
|
public string ProtocolTitle;
|
|
public string[] EndStateText;
|
|
|
|
// Set to 'true' when the form closes
|
|
public bool Completed { get { return completed; } }
|
|
bool completed;
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
|
public CycleEndForm(int waterMetersCount)
|
|
{
|
|
this.WaterMetersCount = waterMetersCount;
|
|
InitializeComponent();
|
|
EndStateText = new string[WaterMetersCount];
|
|
completed = false;
|
|
}
|
|
|
|
/// <summary> Parameterless constructor for 3 watermeters </summary>
|
|
public CycleEndForm()
|
|
: this(3)
|
|
{
|
|
}
|
|
|
|
private void CycleEndForm_Load(object sender, EventArgs e)
|
|
{
|
|
// TODO: localize strings
|
|
|
|
Height = 195 + 90 * WaterMetersCount;
|
|
|
|
if (WaterMetersCount < 1) groupBox1.Visible = false;
|
|
if (WaterMetersCount < 2) groupBox2.Visible = false;
|
|
if (WaterMetersCount < 3) groupBox3.Visible = false;
|
|
if (WaterMetersCount < 4) groupBox4.Visible = false;
|
|
if (WaterMetersCount < 5) groupBox5.Visible = false;
|
|
if (WaterMetersCount < 6) groupBox6.Visible = false;
|
|
|
|
radioButton1.Text = ProtocolName1;
|
|
radioButton2.Text = ProtocolName2;
|
|
radioButton3.Text = ProtocolName3;
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (WaterMetersCount >= 1) EndStateText[0] = textBox1.Text;
|
|
if (WaterMetersCount >= 2) EndStateText[1] = textBox3.Text;
|
|
if (WaterMetersCount >= 3) EndStateText[2] = textBox4.Text;
|
|
if (WaterMetersCount >= 4) EndStateText[3] = textBox5.Text;
|
|
if (WaterMetersCount >= 5) EndStateText[4] = textBox6.Text;
|
|
if (WaterMetersCount >= 6) EndStateText[5] = textBox6.Text;
|
|
|
|
if (radioButton1.Checked) ProtocolTitle = ProtocolName1;
|
|
else if (radioButton2.Checked) ProtocolTitle = ProtocolName2;
|
|
else if (radioButton3.Checked) ProtocolTitle = ProtocolName3;
|
|
|
|
completed = true;
|
|
Close();
|
|
}
|
|
}
|
|
}
|