tbf/TestBenchFramework/TestWizard/MethodSelection.cs
Milan Hanajik b07c7c5c9d PMaxTest and LeakTest methods implemented, added to the project
Order of two new test wizard dialog exchanged
Pressure Selection wizard dialog added
2015-02-19 15:54:55 +01:00

110 lines
2.3 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 MethodSelection : Form
{
Entities.Test test;
IList<BenchControl.GenericDevices.ITestMethod> methods;
public MethodSelection()
{
InitializeComponent();
}
public MethodSelection(bool first, bool last,
Entities.Test test,
IList<BenchControl.GenericDevices.ITestMethod> methods)
: this()
{
this.test = test;
this.methods = methods;
Text = Strings.Method_selection;
testNameLabel.Text = Strings.Test_name;
testMethodLabel.Text = Strings.Test_method;
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 MethodSelection_Load(object sender, EventArgs e)
{
if (test == null) return;
foreach (var method in methods) testMethodComboBox.Items.Add(method.Cfg.Name);
RefreshWizardPage();
}
void RefreshWizardPage()
{
testNameTextBox.Text = test.Name;
nextButton.Enabled = IsFormValid();
}
void UpdateTest()
{
test.Name = testNameTextBox.Text;
if (testMethodComboBox.Items.Contains(testMethodComboBox.Text))
{
test.Method = testMethodComboBox.Text;
}
}
bool IsFormValid()
{
return testMethodComboBox.Items.Contains(testMethodComboBox.Text);
}
private void backButton_Click(object sender, EventArgs e)
{
if (test != null && IsFormValid()) UpdateTest();
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 testMethodComboBox_TextChanged(object sender, EventArgs e)
{
nextButton.Enabled = IsFormValid();
}
private void sensorsComboBox_TextChanged(object sender, EventArgs e)
{
nextButton.Enabled = IsFormValid();
}
}
}