LynnaLab.SpinButtonHexadecimal.OnInput C# (CSharp) Method

OnInput() protected method

protected OnInput ( double &value ) : int
value double
return int
        protected override int OnInput(out double value)
        {
            string text = Text.Trim();
            bool success = false;
            value = Value;
            // Try a decimal
            try {
                value = Convert.ToInt32(text);
                success = true;
            }
            catch (Exception) {
            }
            // Try a hex number
            try {
                if (text.Length > 0 && text[0] == '$') {
                    value = Convert.ToInt32(text.Substring(1),16);
                    success = true;
                }
            }
            catch (Exception) {
            }
            // Try a negative hex number
            try {
                if (text.Length > 1 && text[0] == '-' && text[1] == '$') {
                    value = -Convert.ToInt32(text.Substring(2),16);
                    success = true;
                }
            }
            catch (Exception) {
            }
            if (!success)
                value = Value;
            return 1;
        }