Refactoring : TestBenchFramework --> TBF ver. 2.18.789
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.TestWizard
|
||||
{
|
||||
public partial class Roi1 : Form
|
||||
{
|
||||
RoiData roiData;
|
||||
|
||||
const int StylesCount = 3;
|
||||
int styleIdx; /// 0 .. StylesCount - 1
|
||||
|
||||
|
||||
public Roi1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public Roi1(bool first, bool last, RoiData roiData)
|
||||
: this()
|
||||
{
|
||||
this.roiData = roiData;
|
||||
|
||||
Text = "Pointer/arrow style";
|
||||
teethCount.Text = "Teeth count";
|
||||
|
||||
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 Roi1_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (roiData == null) return;
|
||||
|
||||
RefreshWizardPage();
|
||||
}
|
||||
|
||||
void RefreshWizardPage()
|
||||
{
|
||||
teetgCountTextBox.Text = roiData.TeethCount.ToString();
|
||||
styleIdx = roiData.StyleIdx;
|
||||
LoadImageAndUpdateFwBwBtns();
|
||||
nextButton.Enabled = IsFormValid();
|
||||
}
|
||||
|
||||
void LoadImageAndUpdateFwBwBtns()
|
||||
{
|
||||
switch (styleIdx)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
stylePictureBox.Image = new Bitmap(TBF.Properties.Resources.RoiStyle1);
|
||||
break;
|
||||
case 1:
|
||||
stylePictureBox.Image = new Bitmap(TBF.Properties.Resources.RoiStyle2);
|
||||
break;
|
||||
case 2:
|
||||
stylePictureBox.Image = new Bitmap(TBF.Properties.Resources.RoiStyle3);
|
||||
break;
|
||||
}
|
||||
|
||||
fwButton.Enabled = styleIdx < StylesCount - 1;
|
||||
bwButton.Enabled = styleIdx > 0;
|
||||
}
|
||||
|
||||
void UpdateTest()
|
||||
{
|
||||
roiData.StyleIdx = styleIdx;
|
||||
roiData.TeethCount = int.Parse(teetgCountTextBox.Text);
|
||||
}
|
||||
|
||||
bool IsFormValid()
|
||||
{
|
||||
int teethCnt;
|
||||
return int.TryParse(teetgCountTextBox.Text, out teethCnt)
|
||||
&& teethCnt > 0 && teethCnt <= 20
|
||||
&& styleIdx >= 0 && styleIdx < StylesCount
|
||||
&& (styleIdx == 2 || teethCnt == 1);
|
||||
}
|
||||
|
||||
private void backButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Retry;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void nextButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (roiData != 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();
|
||||
}
|
||||
|
||||
private void bwButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (styleIdx > 0) styleIdx--;
|
||||
LoadImageAndUpdateFwBwBtns();
|
||||
nextButton.Enabled = IsFormValid();
|
||||
}
|
||||
|
||||
private void fwButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (styleIdx < StylesCount - 1) styleIdx++;
|
||||
LoadImageAndUpdateFwBwBtns();
|
||||
nextButton.Enabled = IsFormValid();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user