117 lines
3.8 KiB
C#
117 lines
3.8 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.TestMethods.Adjustment
|
|
{
|
|
public partial class WMErrorsForm : Form, GenericDevices.IHasCompleted
|
|
{
|
|
/// <summary> Number of text boxes for serial numbers </summary>
|
|
public readonly int WaterMetersCount;
|
|
|
|
Entities.TestResult tr;
|
|
|
|
// 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 WMErrorsForm(int waterMetersCount)
|
|
{
|
|
this.WaterMetersCount = waterMetersCount;
|
|
InitializeComponent();
|
|
completed = false;
|
|
tr = null;
|
|
|
|
/// Attach to 'AdjustmentInProgress' handler
|
|
UiBridge.Bridge.AdjustmentInProgressHandler += delegate(object sender, UiBridge.AdjustmentInProgressEventArgs args)
|
|
{
|
|
if (InvokeRequired)
|
|
{
|
|
Invoke(new EventHandler<UiBridge.AdjustmentInProgressEventArgs>(OnAdjustmentInProgress), sender, args);
|
|
}
|
|
else OnAdjustmentInProgress(sender, args);
|
|
};
|
|
}
|
|
|
|
/// <summary> Parameterless constructor for 3 watermeters </summary>
|
|
public WMErrorsForm()
|
|
: this(Program.WMsCount)
|
|
{
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
Text = Strings.Water_Meter_States;
|
|
groupBox1.Text = Strings.Water_Meter + " 1";
|
|
groupBox2.Text = Strings.Water_Meter + " 2";
|
|
groupBox3.Text = Strings.Water_Meter + " 3";
|
|
groupBox4.Text = Strings.Water_Meter + " 4";
|
|
groupBox5.Text = Strings.Water_Meter + " 5";
|
|
groupBox6.Text = Strings.Water_Meter + " 6";
|
|
wmErrorLabel1.Text = Strings.Error_pct;
|
|
wmErrorLabel2.Text = Strings.Error_pct;
|
|
wmErrorLabel3.Text = Strings.Error_pct;
|
|
wmErrorLabel4.Text = Strings.Error_pct;
|
|
wmErrorLabel5.Text = Strings.Error_pct;
|
|
wmErrorLabel6.Text = Strings.Error_pct;
|
|
okButton.Text = Strings.OkBtnText;
|
|
}
|
|
|
|
private void CycleEndForm_Load(object sender, EventArgs e)
|
|
{
|
|
Localize();
|
|
|
|
Height = 50 + 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;
|
|
|
|
wmErrorTextBox1.Text = "---";
|
|
wmErrorTextBox2.Text = "---";
|
|
wmErrorTextBox3.Text = "---";
|
|
wmErrorTextBox4.Text = "---";
|
|
wmErrorTextBox5.Text = "---";
|
|
wmErrorTextBox6.Text = "---";
|
|
}
|
|
|
|
void OnAdjustmentInProgress(object sender, UiBridge.AdjustmentInProgressEventArgs args)
|
|
{
|
|
tr = args.TestResult;
|
|
}
|
|
|
|
void Redraw()
|
|
{
|
|
if (tr != null)
|
|
{
|
|
if (WaterMetersCount >= 1) wmErrorTextBox1.Text = tr.Meters[0].VolumeErrorPct.ToString("F1");
|
|
if (WaterMetersCount >= 2) wmErrorTextBox2.Text = tr.Meters[1].VolumeErrorPct.ToString("F1");
|
|
if (WaterMetersCount >= 3) wmErrorTextBox3.Text = tr.Meters[2].VolumeErrorPct.ToString("F1");
|
|
if (WaterMetersCount >= 4) wmErrorTextBox4.Text = tr.Meters[3].VolumeErrorPct.ToString("F1");
|
|
if (WaterMetersCount >= 5) wmErrorTextBox5.Text = tr.Meters[4].VolumeErrorPct.ToString("F1");
|
|
if (WaterMetersCount >= 6) wmErrorTextBox6.Text = tr.Meters[5].VolumeErrorPct.ToString("F1");
|
|
}
|
|
Invalidate(new Rectangle(380, 30, 330, 500));
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
completed = true;
|
|
Close();
|
|
}
|
|
|
|
private void WMErrorsForm_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|