/// /// Copyright (c) 2013-2015 Sensus Metering Systems /// using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Config.Entities; using TBF.Resources; namespace TBF.TestWizard { public partial class PressureSelection : Form { Test test; public PressureSelection() { InitializeComponent(); } public PressureSelection(bool first, bool last, Test test) : this() { this.test = test; Text = Strings.Pressure_selection; pressureLoLabel.Text = Strings.Pressure_lo_bar; pressureHiLabel.Text = Strings.Pressure_hi_bar; durationLabel.Text = Strings.Duration_s; backButton.Text = Strings.BackBtnText; nextButton.Text = Strings.NextBtnText; cancelButton.Text = Strings.CancelBtnText; if (first) backButton.Visible = false; if (last) nextButton.Text = Strings.FinishBtnText; } private void FlowSelection_Load(object sender, EventArgs e) { if (test == null) return; RefreshWizardPage(); } void RefreshWizardPage() { pressureLoTextBox.Text = 1.0f.ToString(); /// TODO: replace constants pressureHiTextBox.Text = 2.0f.ToString(); durationTextBox.Text = 10.ToString(); nextButton.Enabled = IsFormValid(); } void UpdateTest() { /// TODO: complete //test.Qfrom = Utils.ParseUFloat(pressureLoTextBox.Text); //test.Qto = Utils.ParseUFloat(pressureHiTextBox.Text); //test.TstTime = int.Parse(durationTextBox.Text); } bool IsFormValid() { float dummy; int iDummy; return Utils.TryParseUFloat(pressureLoTextBox.Text, out dummy) && Utils.TryParseUFloat(pressureHiTextBox.Text, out dummy) && int.TryParse(durationTextBox.Text, out iDummy); } private void backButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.Retry; Close(); } private void nextButton_Click(object sender, EventArgs e) { if (test != null && IsFormValid()) { UpdateTest(); DialogResult = DialogResult.OK; Close(); } else { DialogResult = DialogResult.None; } } private void cancelButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); } private void anyTextBox_TextChanged(object sender, EventArgs e) { nextButton.Enabled = IsFormValid(); } } }