636 lines
34 KiB
C#
636 lines
34 KiB
C#
///
|
|
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Common;
|
|
using Config;
|
|
using TBF.Rig.GenericDevices;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.Rig.DataEntry.Standard24
|
|
{
|
|
public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted
|
|
{
|
|
enum Kind
|
|
{
|
|
Undefined,
|
|
Start,
|
|
AdvancedStart,
|
|
End,
|
|
}
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm));
|
|
|
|
// Set to 'true' when the form closes
|
|
public bool Completed { get { return completed; } }
|
|
bool completed;
|
|
|
|
/// <summary> Number of text boxes for serial numbers </summary>
|
|
public readonly int WaterMetersCount;
|
|
readonly IRegReader[] regReaders;
|
|
readonly bool[] disabled;
|
|
readonly string closeFormKeys;
|
|
|
|
// To be retrieved after the form closes
|
|
public double[] WMStartState;
|
|
public readonly string[] WMStartStateStr;
|
|
public double[] WMEndState;
|
|
public readonly string[] WMEndStateStr;
|
|
|
|
public Unit VolumeUnit;
|
|
|
|
Kind kind; /// false=start states, true=end states
|
|
double refVolume;
|
|
double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
|
|
double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
|
|
bool fixedErrorLimits; /// false in case of calculated error limits
|
|
|
|
int TextBoxesCount;
|
|
///
|
|
Label[] labels;
|
|
TextBox[] startTextBoxes;
|
|
TextBox[] endTextBoxes;
|
|
Label[] exclamations;
|
|
|
|
IList<TextBox> activeTextBoxes;
|
|
IList<int> activeWmNrs;
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor initializing common part for start and endstate form
|
|
/// </summary>
|
|
public TestStartEndForm()
|
|
{
|
|
InitializeComponent();
|
|
ControlBox = false;
|
|
|
|
TextBoxesCount = 24;
|
|
|
|
labels = new Label[]
|
|
{
|
|
label1, label2, label3, label4, label5, label6, label7, label8, label9, label10,
|
|
label11, label12, label13, label14, label15, label16, label17, label18, label19, label20,
|
|
label21, label22, label23, label24,
|
|
};
|
|
startTextBoxes = new TextBox[]
|
|
{
|
|
startTextBox1, startTextBox2, startTextBox3, startTextBox4, startTextBox5, startTextBox6,
|
|
startTextBox7, startTextBox8, startTextBox9, startTextBox10, startTextBox11, startTextBox12,
|
|
startTextBox13, startTextBox14, startTextBox15, startTextBox16, startTextBox17, startTextBox18,
|
|
startTextBox19, startTextBox20, startTextBox21, startTextBox22, startTextBox23, startTextBox24,
|
|
};
|
|
endTextBoxes = new TextBox[]
|
|
{
|
|
endTextBox1, endTextBox2, endTextBox3, endTextBox4, endTextBox5, endTextBox6,
|
|
endTextBox7, endTextBox8, endTextBox9, endTextBox10, endTextBox11, endTextBox12,
|
|
endTextBox13, endTextBox14, endTextBox15, endTextBox16, endTextBox17, endTextBox18,
|
|
endTextBox19, endTextBox20, endTextBox21, endTextBox22, endTextBox23, endTextBox24,
|
|
};
|
|
exclamations = new Label[]
|
|
{
|
|
exclamation1, exclamation2, exclamation3, exclamation4, exclamation5, exclamation6,
|
|
exclamation7, exclamation8, exclamation9, exclamation10, exclamation11, exclamation12,
|
|
exclamation13, exclamation14, exclamation15, exclamation16, exclamation17, exclamation18,
|
|
exclamation19, exclamation20, exclamation21, exclamation22, exclamation23, exclamation24,
|
|
};
|
|
|
|
activeTextBoxes = new List<TextBox>();
|
|
activeWmNrs = new List<int>();
|
|
|
|
for (Unit u = 0; u < Unit.Count; u++)
|
|
{
|
|
if (Units.IsVolume(u)) unitComboBox.Items.Add(u.ToDescription());
|
|
}
|
|
|
|
completed = false;
|
|
StartForceCloseHandler();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor to fill in start states
|
|
/// </summary>
|
|
/// <param name="waterMetersCount">Number of water meters</param>
|
|
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
|
|
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, bool[] disabled, string closeFormKeys, Unit initialVolumeUnit)
|
|
: this()
|
|
{
|
|
kind = Kind.Start;
|
|
|
|
this.WaterMetersCount = waterMetersCount;
|
|
this.regReaders = regReaders;
|
|
this.disabled = disabled;
|
|
this.closeFormKeys = closeFormKeys;
|
|
|
|
ShuffleTextBoxes();
|
|
|
|
WMStartState = new double[waterMetersCount];
|
|
WMStartStateStr = new string[waterMetersCount];
|
|
|
|
VolumeUnit = initialVolumeUnit;
|
|
unitComboBox.Text = VolumeUnit.ToDescription();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor to fill in start states
|
|
/// </summary>
|
|
/// <param name="waterMetersCount">Number of water meters</param>
|
|
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
|
|
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] wmEndStateStr, bool[] disabled)
|
|
: this()
|
|
{
|
|
kind = Kind.AdvancedStart;
|
|
|
|
this.WaterMetersCount = waterMetersCount;
|
|
this.regReaders = regReaders;
|
|
if (wmEndStateStr == null || wmEndStateStr.Length != waterMetersCount)
|
|
throw (new Exception("Invalid 'wmStartStateStr' argument"));
|
|
this.WMEndStateStr = wmEndStateStr;
|
|
this.disabled = disabled;
|
|
|
|
ShuffleTextBoxes();
|
|
|
|
WMStartState = new double[waterMetersCount];
|
|
WMStartStateStr = new string[waterMetersCount];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor to fill in end states
|
|
/// </summary>
|
|
/// <param name="waterMetersCount">Number of water meters</param>
|
|
/// <param name="wmStartStateStr">Information entered on test start</param>
|
|
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
|
|
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
|
|
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
|
|
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
|
|
public TestStartEndForm(int waterMetersCount, IRegReader[] regReaders, string[] wmStartStateStr, bool[] disabled,
|
|
double refVolume, double errLimLo, double errLimHi, Unit initialVolumeUnit)
|
|
: this()
|
|
{
|
|
kind = Kind.End;
|
|
|
|
this.WaterMetersCount = waterMetersCount;
|
|
this.regReaders = regReaders;
|
|
if (wmStartStateStr == null || wmStartStateStr.Length != waterMetersCount)
|
|
throw (new Exception("Invalid 'wmStartStateStr' argument"));
|
|
this.WMStartStateStr = wmStartStateStr;
|
|
this.disabled = disabled;
|
|
this.refVolume = refVolume;
|
|
this.warningLimLo = 2 * errLimLo;
|
|
this.warningLimHi = 2 * errLimHi;
|
|
this.fixedErrorLimits = (errLimHi > errLimLo);
|
|
|
|
ShuffleTextBoxes();
|
|
|
|
WMStartState = new double[waterMetersCount];
|
|
WMEndState = new double[waterMetersCount];
|
|
WMEndStateStr = new string[waterMetersCount];
|
|
|
|
VolumeUnit = initialVolumeUnit;
|
|
unitComboBox.Text = VolumeUnit.ToDescription();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Make sure the layout of labels/text boxes on the screen
|
|
/// corresponds to the layout of watermeters of the test bench.
|
|
/// </summary>
|
|
void ShuffleTextBoxes()
|
|
{
|
|
if (TextBoxesCount > WaterMetersCount)
|
|
{
|
|
int nrLines = WaterMetersCount / TBF.Data.LineSize;
|
|
int gap = (TextBoxesCount - WaterMetersCount) / nrLines;
|
|
|
|
int dest = 0;
|
|
for (int l = 0; l < nrLines; l++)
|
|
{
|
|
for (int i = 0; i < TBF.Data.LineSize; i++)
|
|
{
|
|
labels[dest] = labels[l * TBF.Data.LineSize + l * gap + i];
|
|
startTextBoxes[dest] = startTextBoxes[l * TBF.Data.LineSize + l * gap + i];
|
|
endTextBoxes[dest] = endTextBoxes[l * TBF.Data.LineSize + l * gap + i];
|
|
exclamations[dest] = exclamations[l * TBF.Data.LineSize + l * gap + i];
|
|
dest++;
|
|
}
|
|
}
|
|
TextBoxesCount = WaterMetersCount;
|
|
}
|
|
}
|
|
|
|
private void TestStartEndForm_Load(object sender, EventArgs e)
|
|
{
|
|
Localize();
|
|
|
|
//Height = 115 + 90 * WaterMetersCount;
|
|
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
{
|
|
if (i < WaterMetersCount)
|
|
{
|
|
labels[i].Visible = startTextBoxes[i].Visible = endTextBoxes[i].Visible = true;
|
|
}
|
|
}
|
|
|
|
if (kind == Kind.End)
|
|
{
|
|
/// End of test
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
{
|
|
if (((i < disabled.Length) && disabled[i]) || ((i < regReaders.Length) && (regReaders[i] == null)))
|
|
{
|
|
endTextBoxes[i].Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
if (WMStartStateStr != null && i < WMStartStateStr.Length)
|
|
{
|
|
startTextBoxes[i].Text = WMStartStateStr[i];
|
|
}
|
|
|
|
endTextBoxes[i].Enabled = true;
|
|
activeTextBoxes.Add(endTextBoxes[i]);
|
|
activeWmNrs.Add(i);
|
|
}
|
|
}
|
|
}
|
|
else if (kind == Kind.Start || kind == Kind.AdvancedStart)
|
|
{
|
|
/// Start of test
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
{
|
|
if (((i < disabled.Length) && disabled[i]) || ((i < regReaders.Length) && (regReaders[i] == null)))
|
|
{
|
|
startTextBoxes[i].Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
startTextBoxes[i].Enabled = true;
|
|
activeTextBoxes.Add(startTextBoxes[i]);
|
|
activeWmNrs.Add(i);
|
|
|
|
if ((kind == Kind.AdvancedStart) && (WMEndStateStr != null) && (i < WMEndStateStr.Length) && (!string.IsNullOrEmpty(WMEndStateStr[i])))
|
|
{
|
|
startTextBoxes[i].Text = WMEndStateStr[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((activeTextBoxes.Count > 0) && (activeWmNrs.Count > 0))
|
|
{
|
|
activeTextBoxes[0].Focus();
|
|
largeTextBox.Text = string.Format("{0}: {1}", activeWmNrs[0] + 1, string.Empty);
|
|
}
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
Text = Strings.Water_Meter_States;
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
{
|
|
labels[i].Text = (i + 1).ToString();
|
|
}
|
|
startLabel.Text = startLabel2.Text = Strings.Start;
|
|
endLabel.Text = endLabel2.Text = Strings.End;
|
|
okButton.Text = Strings.OkBtnText;
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs eArgs)
|
|
{
|
|
for (int i = 0; i < Math.Min(WaterMetersCount, TextBoxesCount); i++)
|
|
{
|
|
double startVol, endVol;
|
|
|
|
if (kind == Kind.End)
|
|
{
|
|
if (endTextBoxes[i].Visible &&
|
|
endTextBoxes[i].Enabled &&
|
|
Utils.TryParseUDouble(startTextBoxes[i].Text, out startVol) &&
|
|
Utils.TryParseUDouble(endTextBoxes[i].Text, out endVol))
|
|
{
|
|
WMStartState[i] = Units.ConvertFrom(VolumeUnit, startVol);
|
|
WMEndState[i] = Units.ConvertFrom(VolumeUnit, endVol);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (startTextBoxes[i].Visible &&
|
|
startTextBoxes[i].Enabled &&
|
|
Utils.TryParseUDouble(startTextBoxes[i].Text, out startVol))
|
|
{
|
|
WMStartStateStr[i] = startTextBoxes[i].Text;
|
|
WMStartState[i] = Units.ConvertFrom(VolumeUnit, startVol);
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
|
|
/// <summary>
|
|
/// Calculate the approximate error and verify whether it is within limits.
|
|
/// Make an exclamation mark visible if out of range.
|
|
/// Similar event handler is implemented for all endTextBoxes (1..24).
|
|
/// </summary>
|
|
private void ProcEndTextChanged(object sender, EventArgs e, TextBox endTBox)
|
|
{
|
|
int wmIx = -1;
|
|
for (int i = 0; i < endTextBoxes.Length; i++)
|
|
{
|
|
if (endTextBoxes[i] == endTBox)
|
|
{
|
|
wmIx = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (wmIx < 0 || wmIx >= TextBoxesCount) return;
|
|
|
|
double startVol, endVol;
|
|
|
|
if (Utils.TryParseUDouble(startTextBoxes[wmIx].Text, out startVol) &&
|
|
Utils.TryParseUDouble(endTextBoxes[wmIx].Text, out endVol))
|
|
{
|
|
double startState = Units.ConvertFrom(VolumeUnit, startVol);
|
|
double endState = Units.ConvertFrom(VolumeUnit, endVol);
|
|
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
|
largeExclamationLabel.Visible =
|
|
exclamations[wmIx].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
|
}
|
|
else
|
|
{
|
|
largeExclamationLabel.Visible =
|
|
exclamations[wmIx].Visible = !string.IsNullOrEmpty(endTextBoxes[wmIx].Text);
|
|
}
|
|
|
|
largeTextBox.Text = string.Format("{0}: {1}", wmIx + 1, endTextBoxes[wmIx].Text);
|
|
}
|
|
|
|
private void endTextBox1_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox1); }
|
|
private void endTextBox2_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox2); }
|
|
private void endTextBox3_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox3); }
|
|
private void endTextBox4_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox4); }
|
|
private void endTextBox5_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox5); }
|
|
private void endTextBox6_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox6); }
|
|
private void endTextBox7_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox7); }
|
|
private void endTextBox8_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox8); }
|
|
private void endTextBox9_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox9); }
|
|
private void endTextBox10_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox10); }
|
|
private void endTextBox11_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox11); }
|
|
private void endTextBox12_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox12); }
|
|
private void endTextBox13_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox13); }
|
|
private void endTextBox14_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox14); }
|
|
private void endTextBox15_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox15); }
|
|
private void endTextBox16_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox16); }
|
|
private void endTextBox17_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox17); }
|
|
private void endTextBox18_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox18); }
|
|
private void endTextBox19_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox19); }
|
|
private void endTextBox20_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox20); }
|
|
private void endTextBox21_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox21); }
|
|
private void endTextBox22_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox22); }
|
|
private void endTextBox23_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox23); }
|
|
private void endTextBox24_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox24); }
|
|
|
|
private void endTextBox1_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox1); }
|
|
private void endTextBox2_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox2); }
|
|
private void endTextBox3_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox3); }
|
|
private void endTextBox4_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox4); }
|
|
private void endTextBox5_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox5); }
|
|
private void endTextBox6_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox6); }
|
|
private void endTextBox7_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox7); }
|
|
private void endTextBox8_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox8); }
|
|
private void endTextBox9_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox9); }
|
|
private void endTextBox10_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox10); }
|
|
private void endTextBox11_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox11); }
|
|
private void endTextBox12_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox12); }
|
|
private void endTextBox13_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox13); }
|
|
private void endTextBox14_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox14); }
|
|
private void endTextBox15_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox15); }
|
|
private void endTextBox16_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox16); }
|
|
private void endTextBox17_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox17); }
|
|
private void endTextBox18_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox18); }
|
|
private void endTextBox19_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox19); }
|
|
private void endTextBox20_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox20); }
|
|
private void endTextBox21_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox21); }
|
|
private void endTextBox22_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox22); }
|
|
private void endTextBox23_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox23); }
|
|
private void endTextBox24_MouseClick(object sender, MouseEventArgs e) { ProcEndTextChanged(sender, e, endTextBox24); }
|
|
|
|
/// <summary>
|
|
/// Process a key press within any enabled text boxe
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
/// <param name="currentFocusOwner">TextBox control which received the event</param>
|
|
private void ProcKeyPress(object sender, KeyPressEventArgs e, TextBox currentFocusOwner)
|
|
{
|
|
if (!string.IsNullOrEmpty(closeFormKeys))
|
|
{
|
|
/// Close the form if any 'close form key' was pressed
|
|
for (int ix = 0; ix < closeFormKeys.Length; ix++)
|
|
{
|
|
if (e.KeyChar == closeFormKeys[ix])
|
|
{
|
|
okButton_Click(sender, e);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (e.KeyChar == '\r')
|
|
{
|
|
/// Process <enter> key ..... Next text field
|
|
if (activeTextBoxes.Count < 2) return; /// There is just one enabled textbox
|
|
|
|
for (int i = 0; i < activeTextBoxes.Count; i++)
|
|
{
|
|
if (activeTextBoxes[i] == currentFocusOwner)
|
|
{
|
|
/// Change focus to the next enabled text box
|
|
int newTBIdx = (i + 1) % activeTextBoxes.Count;
|
|
activeTextBoxes[newTBIdx].Focus();
|
|
largeTextBox.Text = string.Format("{0}: {1}", activeWmNrs[newTBIdx] + 1, activeTextBoxes[newTBIdx].Text);
|
|
largeExclamationLabel.Visible = false;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void startTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox1); }
|
|
private void startTextBox2_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox2); }
|
|
private void startTextBox3_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox3); }
|
|
private void startTextBox4_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox4); }
|
|
private void startTextBox5_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox5); }
|
|
private void startTextBox6_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox6); }
|
|
private void startTextBox7_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox7); }
|
|
private void startTextBox8_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox8); }
|
|
private void startTextBox9_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox9); }
|
|
private void startTextBox10_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox10); }
|
|
private void startTextBox11_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox11); }
|
|
private void startTextBox12_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox12); }
|
|
private void startTextBox13_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox13); }
|
|
private void startTextBox14_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox14); }
|
|
private void startTextBox15_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox15); }
|
|
private void startTextBox16_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox16); }
|
|
private void startTextBox17_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox17); }
|
|
private void startTextBox18_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox18); }
|
|
private void startTextBox19_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox19); }
|
|
private void startTextBox20_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox20); }
|
|
private void startTextBox21_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox21); }
|
|
private void startTextBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox22); }
|
|
private void startTextBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox23); }
|
|
private void startTextBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox24); }
|
|
|
|
private void endTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox1); }
|
|
private void endTextBox2_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox2); }
|
|
private void endTextBox3_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox3); }
|
|
private void endTextBox4_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox4); }
|
|
private void endTextBox5_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox5); }
|
|
private void endTextBox6_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox6); }
|
|
private void endTextBox7_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox7); }
|
|
private void endTextBox8_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox8); }
|
|
private void endTextBox9_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox9); }
|
|
private void endTextBox10_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox10); }
|
|
private void endTextBox11_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox11); }
|
|
private void endTextBox12_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox12); }
|
|
private void endTextBox13_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox13); }
|
|
private void endTextBox14_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox14); }
|
|
private void endTextBox15_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox15); }
|
|
private void endTextBox16_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox16); }
|
|
private void endTextBox17_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox17); }
|
|
private void endTextBox18_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox18); }
|
|
private void endTextBox19_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox19); }
|
|
private void endTextBox20_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox20); }
|
|
private void endTextBox21_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox21); }
|
|
private void endTextBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox22); }
|
|
private void endTextBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox23); }
|
|
private void endTextBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox24); }
|
|
|
|
|
|
private void ProcStartTextChanged(object sender, EventArgs e, TextBox startTBox)
|
|
{
|
|
for (int i = 0; i < startTextBoxes.Length; i++)
|
|
{
|
|
if (startTextBoxes[i] == startTBox)
|
|
{
|
|
largeTextBox.Text = string.Format("{0}: {1}", i + 1, startTextBoxes[i].Text);
|
|
largeExclamationLabel.Visible = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void startTextBox1_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox1); }
|
|
private void startTextBox2_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox2); }
|
|
private void startTextBox3_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox3); }
|
|
private void startTextBox4_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox4); }
|
|
private void startTextBox5_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox5); }
|
|
private void startTextBox6_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox6); }
|
|
private void startTextBox7_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox7); }
|
|
private void startTextBox8_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox8); }
|
|
private void startTextBox9_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox9); }
|
|
private void startTextBox10_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox10); }
|
|
private void startTextBox11_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox11); }
|
|
private void startTextBox12_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox12); }
|
|
private void startTextBox13_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox13); }
|
|
private void startTextBox14_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox14); }
|
|
private void startTextBox15_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox15); }
|
|
private void startTextBox16_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox16); }
|
|
private void startTextBox17_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox17); }
|
|
private void startTextBox18_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox18); }
|
|
private void startTextBox19_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox19); }
|
|
private void startTextBox20_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox20); }
|
|
private void startTextBox21_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox21); }
|
|
private void startTextBox22_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox22); }
|
|
private void startTextBox23_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox23); }
|
|
private void startTextBox24_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox24); }
|
|
|
|
private void startTextBox1_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox1); }
|
|
private void startTextBox2_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox2); }
|
|
private void startTextBox3_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox3); }
|
|
private void startTextBox4_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox4); }
|
|
private void startTextBox5_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox5); }
|
|
private void startTextBox6_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox6); }
|
|
private void startTextBox7_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox7); }
|
|
private void startTextBox8_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox8); }
|
|
private void startTextBox9_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox9); }
|
|
private void startTextBox10_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox10); }
|
|
private void startTextBox11_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox11); }
|
|
private void startTextBox12_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox12); }
|
|
private void startTextBox13_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox13); }
|
|
private void startTextBox14_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox14); }
|
|
private void startTextBox15_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox15); }
|
|
private void startTextBox16_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox16); }
|
|
private void startTextBox17_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox17); }
|
|
private void startTextBox18_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox18); }
|
|
private void startTextBox19_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox19); }
|
|
private void startTextBox20_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox20); }
|
|
private void startTextBox21_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox21); }
|
|
private void startTextBox22_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox22); }
|
|
private void startTextBox23_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox23); }
|
|
private void startTextBox24_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox24); }
|
|
|
|
private void unitComboBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
unitComboBox_SelectedIndexChanged(sender, e);
|
|
}
|
|
|
|
private void unitComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
var newUnit = Units.FromDescription(unitComboBox.Text);
|
|
|
|
if (Units.IsVolume(newUnit))
|
|
{
|
|
VolumeUnit = newUnit;
|
|
|
|
if (kind == Kind.End)
|
|
{
|
|
for (int i = 0; i < TextBoxesCount; i++)
|
|
{
|
|
double startVol, endVol;
|
|
|
|
if (Utils.TryParseUDouble(startTextBoxes[i].Text, out startVol) &&
|
|
Utils.TryParseUDouble(endTextBoxes[i].Text, out endVol))
|
|
{
|
|
double startState = Units.ConvertFrom(VolumeUnit, startVol);
|
|
double endState = Units.ConvertFrom(VolumeUnit, endVol);
|
|
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
|
exclamations[i].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
|
}
|
|
else
|
|
{
|
|
exclamations[i].Visible = !string.IsNullOrEmpty(endTextBoxes[i].Text);
|
|
}
|
|
}
|
|
|
|
largeTextBox.Text = string.Empty;
|
|
largeExclamationLabel.Visible = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|