- CloseCycleBeginForm() -> WaitBeginFormClosed() - CloseBeginForm() added to SequenceBase(forced dialog close) - CloseModellFormHandler added to UiBridge.Bridge
155 lines
4.5 KiB
C#
155 lines
4.5 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using TBF.Resources;
|
|
|
|
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
|
|
|
|
namespace TBF.BenchControl.DataEntry.Munich
|
|
{
|
|
public partial class CycleEndForm : Form, GenericDevices.IHasCompleted
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(CycleEndForm));
|
|
|
|
// 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[] MainStateText;
|
|
public string[] AuxStateText;
|
|
public float[] QRise;
|
|
public float[] QFall;
|
|
public string ProtocolTitle;
|
|
|
|
// Set to 'true' when the form closes
|
|
public bool Completed { get { return completed; } }
|
|
bool completed;
|
|
|
|
public CycleEndForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
MainStateText = new string[Program.WMsCount / 2];
|
|
AuxStateText = new string[Program.WMsCount / 2];
|
|
QRise = new float[Program.WMsCount / 2];
|
|
QFall = new float[Program.WMsCount / 2];
|
|
completed = false;
|
|
StartForceCloseHandler();
|
|
|
|
Localize();
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
Text = Strings.Data;
|
|
protocolGroupBox.Text = Strings.Protocol;
|
|
groupBox1.Text = Strings.Water_Meter + " 1";
|
|
mainState1Label.Text = Strings.Main_Water_Meter_State;
|
|
auxState1Label.Text = Strings.Aux_Water_Meter_State;
|
|
qRise1Label.Text = Strings.Qrise;
|
|
qFall1Label.Text = Strings.Qfall;
|
|
|
|
groupBox2.Text = Strings.Water_Meter + " 2";
|
|
mainState2Label.Text = Strings.Main_Water_Meter_State;
|
|
auxState2Label.Text = Strings.Aux_Water_Meter_State;
|
|
qRise2Label.Text = Strings.Qrise;
|
|
qFall2Label.Text = Strings.Qfall;
|
|
|
|
groupBox3.Text = Strings.Water_Meter + " 3";
|
|
mainState3Label.Text = Strings.Main_Water_Meter_State;
|
|
auxState3Label.Text = Strings.Aux_Water_Meter_State;
|
|
qRise3Label.Text = Strings.Qrise;
|
|
qFall3Label.Text = Strings.Qfall;
|
|
}
|
|
|
|
private void CycleEndForm_Load(object sender, EventArgs e)
|
|
{
|
|
radioButton1.Text = ProtocolName1;
|
|
radioButton2.Text = ProtocolName2;
|
|
radioButton3.Text = ProtocolName3;
|
|
|
|
qRise1TextBox.Text = Utils.FloatToStr(Sequences.SequenceBase.Qrise, 3);
|
|
qFall1TextBox.Text = Utils.FloatToStr(Sequences.SequenceBase.Qfall, 3);
|
|
|
|
if (Program.WMsCount / 2 >= 2)
|
|
{
|
|
qRise2TextBox.Text = Utils.FloatToStr(Sequences.SequenceBase.Qrise, 3);
|
|
qFall2TextBox.Text = Utils.FloatToStr(Sequences.SequenceBase.Qfall, 3);
|
|
}
|
|
else
|
|
{
|
|
groupBox2.Visible = false;
|
|
Height = 305;
|
|
}
|
|
|
|
if (Program.WMsCount / 2 >= 3)
|
|
{
|
|
qRise3TextBox.Text = Utils.FloatToStr(Sequences.SequenceBase.Qrise, 3);
|
|
qFall3TextBox.Text = Utils.FloatToStr(Sequences.SequenceBase.Qfall, 3);
|
|
}
|
|
else
|
|
{
|
|
groupBox3.Visible = false;
|
|
}
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
float ftmp;
|
|
bool allOK = true;
|
|
|
|
MainStateText[0] = mainState1TextBox.Text;
|
|
AuxStateText[0] = auxState1TextBox.Text;
|
|
if (Utils.TryParseUFloat(qRise1TextBox.Text, out ftmp)) { QRise[0] = ftmp; } else { allOK = false; }
|
|
if (Utils.TryParseUFloat(qFall1TextBox.Text, out ftmp)) { QFall[0] = ftmp; } else { allOK = false; }
|
|
|
|
if (Program.WMsCount / 2 >= 2)
|
|
{
|
|
MainStateText[1] = mainState2TextBox.Text;
|
|
AuxStateText[1] = auxState2TextBox.Text;
|
|
if (Utils.TryParseUFloat(qRise2TextBox.Text, out ftmp)) { QRise[1] = ftmp; } else { allOK = false; }
|
|
if (Utils.TryParseUFloat(qFall2TextBox.Text, out ftmp)) { QFall[1] = ftmp; } else { allOK = false; }
|
|
}
|
|
|
|
if (Program.WMsCount / 2 >= 3)
|
|
{
|
|
MainStateText[2] = mainState3TextBox.Text;
|
|
AuxStateText[2] = auxState3TextBox.Text;
|
|
if (Utils.TryParseUFloat(qRise3TextBox.Text, out ftmp)) { QRise[2] = ftmp; } else { allOK = false; }
|
|
if (Utils.TryParseUFloat(qFall3TextBox.Text, out ftmp)) { QFall[2] = ftmp; } else { allOK = false; }
|
|
}
|
|
|
|
if (radioButton1.Checked) ProtocolTitle = ProtocolName1;
|
|
else if (radioButton2.Checked) ProtocolTitle = ProtocolName2;
|
|
else if (radioButton3.Checked) ProtocolTitle = ProtocolName3;
|
|
|
|
if (allOK)
|
|
{
|
|
completed = true;
|
|
Close();
|
|
}
|
|
}
|
|
|
|
#region Forced close handling
|
|
|
|
public void StartForceCloseHandler()
|
|
{
|
|
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
|
{
|
|
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
|
else OnForceClose(sender, args);
|
|
};
|
|
}
|
|
|
|
void OnForceClose(object sender, EventArgs args)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|