Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void widthTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && e.KeyChar != I3AsciiChars.Backspace && e.KeyChar != I3AsciiChars.Delete)
            {
                if ((Control.ModifierKeys & (Keys.Alt | Keys.Control)) == Keys.None)
                {
                    e.Handled = true;

                    I3NativeMethods.MessageBeep(0 /*MB_OK*/);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handler for the editors TextBox.KeyPress event
        /// </summary>
        /// <param name="sender">The object that raised the event</param>
        /// <param name="e">A KeyPressEventArgs that contains the event data</param>
        protected virtual void OnTextBoxKeyPress(object sender, KeyPressEventArgs e)
        {
            char enter  = I3AsciiChars.CarriageReturn;
            char escape = I3AsciiChars.Escape;
            char tab    = I3AsciiChars.HorizontalTab;

            NumberFormatInfo info = CultureInfo.CurrentCulture.NumberFormat;

            string decimalSeparator = info.NumberDecimalSeparator;
            string groupSeparator   = info.NumberGroupSeparator;
            string negativeSign     = info.NegativeSign;
            string character        = e.KeyChar.ToString();

            if ((!char.IsDigit(e.KeyChar) && !character.Equals(decimalSeparator) && !character.Equals(groupSeparator)) &&
                !character.Equals(negativeSign) && (e.KeyChar != tab))
            {
                if ((Control.ModifierKeys & (Keys.Alt | Keys.Control)) == Keys.None)
                {
                    e.Handled = true;

                    if (e.KeyChar == enter)
                    {
                        if (this.EditingTable != null)
                        {
                            this.EditingTable.StopEditing();
                        }
                    }
                    else if (e.KeyChar == escape)
                    {
                        if (this.EditingTable != null)
                        {
                            this.EditingTable.CancelEditing();
                        }
                    }
                    else
                    {
                        I3NativeMethods.MessageBeep(0 /*MB_OK*/);
                    }
                }
            }
            else
            {
                this.userEdit = true;
            }
        }