tbf/TestBenchFramework/TestWizard/FlowSelection.cs
2014-07-28 09:56:40 +02:00

99 lines
2.0 KiB
C#

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 TBF.Resources;
namespace TBF.TestWizard
{
public partial class FlowSelection : Form
{
Entities.Test test;
public FlowSelection()
{
InitializeComponent();
}
public FlowSelection(Entities.Test test)
: this()
{
this.test = test;
}
private void FlowSelection_Load(object sender, EventArgs e)
{
if (test == null) return;
backButton.Visible = false;
Text = Strings.Flow_selection;
testNameLabel.Text = Strings.Test_name;
qFromLabel.Text = Strings.Q_from_m3h;
qToLabel.Text = Strings.Q_to_m3h;
backButton.Text = Strings.BackBtnText;
nextButton.Text = Strings.NextBtnText;
cancelButton.Text = Strings.CancelBtnText;
RefreshWizardPage();
}
void RefreshWizardPage()
{
testNameTextBox.Text = test.Name;
qFromTextBox.Text = test.Qfrom.ToString();
qToTextBox.Text = test.Qto.ToString();
nextButton.Enabled = IsFormValid();
}
void UpdateTest()
{
test.Name = testNameTextBox.Text;
test.Qfrom = Utils.ParseUFloat(qFromTextBox.Text);
test.Qto = Utils.ParseUFloat(qToTextBox.Text);
}
bool IsFormValid()
{
float dummy;
return Utils.TryParseUFloat(qFromTextBox.Text, out dummy) &&
Utils.TryParseUFloat(qToTextBox.Text, out dummy);
}
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();
}
}
}