Esempio n. 1
0
 protected override void OnKeyUp(KeyEventArgs e)
 {
     base.OnKeyUp(e);
     if (this.AutoSeparateDigits && (InputBoxValidationHelper.KeyIsDigit(e.KeyCode) || e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete))
     {
         try
         {
             int selectionStart = this.SelectionStart;
             int commaCount1    = this.Text.Substring(0, selectionStart).Where(t => t == CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator[0]).Count();
             base.Text = Njit.Common.Helpers.NumbersHelper.InsertComma(this.Text);
             int commaCount2 = this.Text.Substring(0, selectionStart > this.Text.Length ? this.Text.Length : selectionStart).Where(t => t == CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator[0]).Count();
             if (commaCount2 > commaCount1)
             {
                 selectionStart++;
             }
             else if (commaCount2 < commaCount1)
             {
                 selectionStart--;
             }
             this.SelectionStart = selectionStart;
         }
         catch { }
     }
     InputBoxValidationHelper.FormatTextValueAfterKeyUp(this, e.KeyCode);
 }
Esempio n. 2
0
        public void CheckValidation(CancelEventArgs e)
        {
            string errorText;

            if (!InputBoxValidationHelper.CheckValidation(this, out errorText))
            {
                this.SetError(errorText, true);
                e.Cancel = true;
            }
        }
Esempio n. 3
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            toolTip.Hide(this);
            if (ReplaceArabicCharsWithPersianChars)
            {
                Njit.Common.PublicMethods.FixArabicChars(e);
            }
            string errorText;

            if (!InputBoxValidationHelper.CheckKeyPressed(e.KeyChar, this, out errorText))
            {
                e.KeyChar = Convert.ToChar(0);
                SetError(errorText, false);
            }
            base.OnKeyPress(e);
        }
Esempio n. 4
0
 private string FormatInputText(string value)
 {
     if (string.IsNullOrEmpty(value))
     {
         return(value);
     }
     if (this.ReplaceArabicCharsWithPersianChars)
     {
         value = Njit.Common.PublicMethods.FixArabicChars(value);
     }
     value = InputBoxValidationHelper.FormatTextValueWithInputType(this, value);
     if (this.AutoSeparateDigits)
     {
         value = Njit.Common.Helpers.NumbersHelper.InsertComma(value);
     }
     return(value);
 }
Esempio n. 5
0
 protected override void OnKeyUp(KeyEventArgs e)
 {
     base.OnKeyUp(e);
     if (this.AutoSeparateDigits && InputBoxValidationHelper.KeyIsDigit(e.KeyCode))
     {
         try
         {
             int selectionStart = this.SelectionStart;
             int commaCount1    = this.Text.Substring(0, selectionStart).Where(t => t == CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator[0]).Count();
             base.Text = Njit.Common.Helpers.NumbersHelper.InsertComma(this.Text);
             int commaCount2 = this.Text.Substring(0, selectionStart).Where(t => t == CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator[0]).Count();
             if (commaCount2 > commaCount1)
             {
                 selectionStart++;
             }
             this.SelectionStart = selectionStart;
         }
         catch { }
     }
 }