115 lines
2.5 KiB
C#
115 lines
2.5 KiB
C#
///
|
|
/// 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 MethodSelection : Form
|
|
{
|
|
Test test;
|
|
IList<BenchControl.GenericDevices.ITestMethod> methods;
|
|
|
|
public MethodSelection()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public MethodSelection(bool first, bool last,
|
|
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()
|
|
{
|
|
bool methodOK = testMethodComboBox.Items.Contains(testMethodComboBox.Text);
|
|
return Utils.IsGoodFName(testNameTextBox.Text) && methodOK;
|
|
}
|
|
|
|
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 testNameTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
nextButton.Enabled = IsFormValid();
|
|
}
|
|
|
|
private void testMethodComboBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
nextButton.Enabled = IsFormValid();
|
|
}
|
|
}
|
|
}
|