Ram Poke - better input validation on text boxes
This commit is contained in:
parent
de39858cb9
commit
98643b0599
|
@ -71,6 +71,7 @@
|
|||
this.AddressBox.TabIndex = 2;
|
||||
this.AddressBox.Text = "0000";
|
||||
this.AddressBox.Leave += new System.EventHandler(this.AddressBox_Leave);
|
||||
this.AddressBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.AddressBox_KeyPress);
|
||||
//
|
||||
// DataTypeGroupBox
|
||||
//
|
||||
|
@ -241,6 +242,7 @@
|
|||
this.ValueBox.TabIndex = 11;
|
||||
this.ValueBox.Text = "0000";
|
||||
this.ValueBox.Leave += new System.EventHandler(this.ValueBox_Leave);
|
||||
this.ValueBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ValueBox_KeyPress);
|
||||
//
|
||||
// RamPoke
|
||||
//
|
||||
|
|
|
@ -195,5 +195,46 @@ namespace BizHawk.MultiClient
|
|||
t.Show("Must be a valid unsigned decimal value", ValueBox, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
private asigned GetDataType()
|
||||
{
|
||||
if (SignedRadio.Checked)
|
||||
return asigned.UNSIGNED;
|
||||
if (UnsignedRadio.Checked)
|
||||
return asigned.SIGNED;
|
||||
if (HexRadio.Checked)
|
||||
return asigned.HEX;
|
||||
|
||||
return asigned.UNSIGNED; //Just in case
|
||||
}
|
||||
|
||||
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (e.KeyChar == '\b') return;
|
||||
|
||||
if (!InputValidate.IsValidHexNumber(e.KeyChar))
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void ValueBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (e.KeyChar == '\b') return;
|
||||
|
||||
switch (GetDataType())
|
||||
{
|
||||
case asigned.UNSIGNED:
|
||||
if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
|
||||
e.Handled = true;
|
||||
break;
|
||||
case asigned.SIGNED:
|
||||
if (!InputValidate.IsValidSignedNumber(e.KeyChar))
|
||||
e.Handled = true;
|
||||
break;
|
||||
case asigned.HEX:
|
||||
if (!InputValidate.IsValidHexNumber(e.KeyChar))
|
||||
e.Handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1550,7 +1550,6 @@ namespace BizHawk.MultiClient
|
|||
e.Handled = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SpecificAddressBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
|
|
Loading…
Reference in New Issue