Ram Search - Attempt some input validation on the Leave event on all text boxes

This commit is contained in:
andres.delikat 2011-02-21 03:05:12 +00:00
parent 94fd588191
commit c46c80e094
3 changed files with 59 additions and 8 deletions

View File

@ -562,6 +562,7 @@
this.NumberOfChangesBox.Name = "NumberOfChangesBox";
this.NumberOfChangesBox.Size = new System.Drawing.Size(65, 20);
this.NumberOfChangesBox.TabIndex = 6;
this.NumberOfChangesBox.Leave += new System.EventHandler(this.NumberOfChangesBox_Leave);
//
// SpecificAddressBox
//
@ -572,6 +573,7 @@
this.SpecificAddressBox.Name = "SpecificAddressBox";
this.SpecificAddressBox.Size = new System.Drawing.Size(65, 20);
this.SpecificAddressBox.TabIndex = 5;
this.SpecificAddressBox.Leave += new System.EventHandler(this.SpecificAddressBox_Leave);
//
// SpecificValueBox
//
@ -581,6 +583,7 @@
this.SpecificValueBox.Name = "SpecificValueBox";
this.SpecificValueBox.Size = new System.Drawing.Size(65, 20);
this.SpecificValueBox.TabIndex = 4;
this.SpecificValueBox.Leave += new System.EventHandler(this.SpecificValueBox_Leave);
//
// NumberOfChangesRadio
//
@ -654,6 +657,7 @@
this.DifferentByBox.Name = "DifferentByBox";
this.DifferentByBox.Size = new System.Drawing.Size(50, 20);
this.DifferentByBox.TabIndex = 9;
this.DifferentByBox.Leave += new System.EventHandler(this.DifferentByBox_Leave);
//
// DifferentByRadio
//

View File

@ -24,7 +24,6 @@ namespace BizHawk.MultiClient
//Implement Auto-Search
//Impelment File handling
//Implement Preview search
//Run Trim() on specific/number/differentby boxes after user enters data, then don't do that when running the Get function, do other forms of input validation
string systemID = "NULL";
List<Watch> searchList = new List<Watch>();
@ -689,7 +688,7 @@ namespace BizHawk.MultiClient
bool i = InputValidate.IsValidSignedNumber(SpecificValueBox.Text);
if (!i) return -1;
return int.Parse(SpecificValueBox.Text.Trim());
return int.Parse(SpecificValueBox.Text);
}
private int GetSpecificAddress()
@ -697,7 +696,7 @@ namespace BizHawk.MultiClient
bool i = InputValidate.IsValidHexNumber(SpecificAddressBox.Text);
if (!i) return -1;
return int.Parse(SpecificAddressBox.Text.Trim(), NumberStyles.HexNumber);
return int.Parse(SpecificAddressBox.Text, NumberStyles.HexNumber);
}
private int GetDifferentBy()
@ -711,7 +710,7 @@ namespace BizHawk.MultiClient
return -1;
}
else
return int.Parse(DifferentByBox.Text.Trim());
return int.Parse(DifferentByBox.Text);
}
private bool DoSpecificAddress()
@ -788,7 +787,7 @@ namespace BizHawk.MultiClient
bool i = InputValidate.IsValidUnsignedNumber(NumberOfChangesBox.Text);
if (!i) return -1;
return int.Parse(NumberOfChangesBox.Text.ToUpper().Trim());
return int.Parse(NumberOfChangesBox.Text);
}
private bool DoNumberOfChanges()
@ -954,5 +953,53 @@ namespace BizHawk.MultiClient
else
AutoSearchCheckBox.BackColor = this.BackColor;
}
private void SpecificValueBox_Leave(object sender, EventArgs e)
{
SpecificValueBox.Text = SpecificValueBox.Text.Replace(" ", "");
if (!InputValidate.IsValidSignedNumber(SpecificValueBox.Text))
{
SpecificValueBox.Focus();
SpecificValueBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid decimal value", SpecificValueBox, 5000);
}
}
private void SpecificAddressBox_Leave(object sender, EventArgs e)
{
SpecificAddressBox.Text = SpecificAddressBox.Text.Replace(" ", "");
if (!InputValidate.IsValidHexNumber(SpecificAddressBox.Text))
{
SpecificAddressBox.Focus();
SpecificAddressBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid hexadecimal value", SpecificAddressBox, 5000);
}
}
private void NumberOfChangesBox_Leave(object sender, EventArgs e)
{
NumberOfChangesBox.Text = NumberOfChangesBox.Text.Replace(" ", "");
if (!InputValidate.IsValidUnsignedNumber(NumberOfChangesBox.Text))
{
NumberOfChangesBox.Focus();
NumberOfChangesBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid unsigned decimal value", NumberOfChangesBox, 5000);
}
}
private void DifferentByBox_Leave(object sender, EventArgs e)
{
DifferentByBox.Text = DifferentByBox.Text.Replace(" ", "");
if (!InputValidate.IsValidUnsignedNumber(DifferentByBox.Text))
{
DifferentByBox.Focus();
DifferentByBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid unsigned decimal value", DifferentByBox, 5000);
}
}
}
}

View File

@ -171,9 +171,6 @@
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>259, 17</value>
</metadata>
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>358, 17</value>
</metadata>
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@ -205,6 +202,9 @@
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>358, 17</value>
</metadata>
<data name="DataSizetoolStripSplitButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8