Habanero.Faces.Win.TextBoxMapperStrategyWin.IsValidCharacter C# (CSharp) Method

IsValidCharacter() private method

Indicates if the given character being typed is valid, based on the text already entered in the textbox. For instance, if the property type is an integer, this method will return false for a non-numeric character (apart from a negative sign).
private IsValidCharacter ( char character ) : bool
character char The character being input
return bool
        internal bool IsValidCharacter(char character)
        {
            if (BoProp == null) return true;
            if (TextBoxControl == null) return true;

            if (BoProp.PropertyType.IsInteger())
            {
                if ((character < '0' || character > '9') && character != 8 && character != '-')
                {
                    return false;
                }
                if (character == '-' && TextBoxControl.SelectionStart != 0)
                {
                    return false;
                }
            }
            else if (BoProp.PropertyType.IsDecimal())
            {
                if ((character < '0' || character > '9') && character != '.' && character != 8 && character != '-')
                {
                    return false;
                }
                if (character == '.' && TextBoxControl.Text.Contains("."))
                {
                    return false;
                }
                // In fact the char is valid, but we want the event to get handled in order to prevent double dots
                if (character == '.' && TextBoxControl.SelectionStart == 0)
                {
                    TextBoxControl.Text = "0." + TextBoxControl.Text;
                    TextBoxControl.SelectionStart = 2;
                    TextBoxControl.SelectionLength = 0;
                    return false;
                }
                if (character == '-' && TextBoxControl.SelectionStart != 0)
                {
                    return false;
                }
            }
            return true;
        }
    }