private void CheckValues(object sender)
{
var textBox = sender as NumericTextBox;
if (textBox == null) return;
#region If Hexadecimal TextBox
if (textBox.IsHex)
{
if (Convert.ToInt64(textBox.Text.Replace("#", ""), 16) > textBox.MaxValue)
{
textBox.Value = textBox.MaxValue;
return;
}
if (Convert.ToInt64(textBox.Text.Replace("#", ""), 16) < textBox.MinValue)
{
textBox.Value = textBox.MinValue;
return;
}
textBox.Value = Convert.ToInt64(textBox.Text.Replace("#", ""), 16);
return;
}
#endregion
#region If Decimal
if (Convert.ToInt32(textBox.Text) > textBox.MaxValue)
{
textBox.Value = textBox.MaxValue;
return;
}
if (Convert.ToInt32(textBox.Text) < textBox.MinValue)
{
textBox.Value = textBox.MinValue;
return;
}
textBox.Value = Convert.ToInt32(textBox.Text);
#endregion
}