/// <summary> /// We check whether we are ok /// </summary> /// <param name="e"></param> protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e) { System.ComponentModel.MaskedTextResultHint hint; int TestPosition; if (e.Text.Length == 1) { this._NewTextIsOk = _mprovider.VerifyChar(e.Text[0], this.CaretIndex, out hint); } else { this._NewTextIsOk = _mprovider.VerifyString(e.Text, out TestPosition, out hint); } base.OnPreviewTextInput(e); }
/// <summary> /// We check whether we are ok /// </summary> /// <param name="e"></param> protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e) { switch (_maskType) { case MaskType.Mask: { System.ComponentModel.MaskedTextResultHint hint; int TestPosition; if (e.Text.Length == 1) { this._NewTextIsOk = _mprovider.VerifyChar(e.Text[0], this.CaretIndex, out hint); } else { this._NewTextIsOk = _mprovider.VerifyString(e.Text, out TestPosition, out hint); } } break; case MaskType.DoubleNumber: { double num = 0; if ((Text == string.Empty) || (Text == "-") || (e.Text == ".")) { this._NewTextIsOk = true; } else { this._NewTextIsOk = double.TryParse(Text + "0", System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out num); } } break; case MaskType.IntegerNumber: { int num = 0; if ((Text == string.Empty) || ((bus == EnumerationSystem.Dec) && (Text == "-"))) { this._NewTextIsOk = true; } else { switch (bus) { case EnumerationSystem.Dec: this._NewTextIsOk = int.TryParse(Text + "0", System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out num); break; case EnumerationSystem.Bin: { this._NewTextIsOk = true; foreach (char ch in Text + "0") { if (!((ch == '0') || (ch == '1'))) { this._NewTextIsOk = false; break; } } } break; case EnumerationSystem.Oct: { this._NewTextIsOk = true; foreach (char ch in Text + "0") { if (!((ch == '0') || (ch == '1') || (ch == '2') || (ch == '3') || (ch == '4') || (ch == '5') || (ch == '6') || (ch == '7'))) { this._NewTextIsOk = false; break; } } } break; case EnumerationSystem.Hex: this._NewTextIsOk = int.TryParse(Text + "0", System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out num); break; } } } break; default: break; } base.OnPreviewTextInput(e); }