/// /// 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 methods; public MethodSelection() { InitializeComponent(); } public MethodSelection(bool first, bool last, Test test, IList 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(); } } }