Exemplo n.º 1
0
        private void Txt_LostFocus(object sender, EventArgs e)
        {
            SetWaterMark();
            if (_isSetWaterMark)
            {
                return;
            }
            var vt = VerifyManager.GetVerifyType(this);

            if (vt == null)
            {
                return;
            }
            var result = vt.Verify(this);

            if (result)
            {
                _hasError = false;
                HideToolTip();
                _changBorderColor = false;
                BorderColor       = _defaultBorderColor;
                _changBorderColor = true;
            }
            else
            {
                _changBorderColor = false;
                BorderColor       = Color.Red;
                _changBorderColor = true;
                _hasError         = true;
                ShowToolTip();
            }
            Invalidate();
        }
Exemplo n.º 2
0
 private void ShowToolTip()
 {
     if (!ShowError || !_hasError)
     {
         return;
     }
     if (_toolTip == null)
     {
         _toolTip = new ToolTip();
     }
     //_toolTip.SetToolTip(this, );
     _toolTip.Show(VerifyManager.GetVerifyMessage(this), this, Size.Width, 0, 3000);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 验证是否通过
        /// </summary>
        /// <param name="showError">是否显示错误信息</param>
        /// <returns>验证结果(true为通过,false为不通过)</returns>
        public bool Verify(bool showError = false)
        {
            var result = VerifyManager.Verify(this);

            if (result)
            {
                _hasError = false;
                HideToolTip();
                _changBorderColor = false;
                BorderColor       = _defaultBorderColor;
                _changBorderColor = true;
            }
            else
            {
                _changBorderColor = false;
                BorderColor       = Color.Red;
                _changBorderColor = true;
                _hasError         = true;
                ShowToolTip();
            }
            Invalidate();
            return(result);
        }
Exemplo n.º 4
0
 private void ZjxlText_TextChanged(object sender, EventArgs e)
 {
     //base.OnTextChanged(e);
     _changBorderColor = false;
     BorderColor       = _defaultBorderColor;
     _changBorderColor = true;
     if (!_isSetWaterMark)
     {
         var vt = VerifyManager.GetVerifyType(this);
         if (vt != null)
         {
             var result = vt.InputtingVerify(this);
             if (!result)
             {
                 Caption = _oldValue;
                 ZjxlText.SelectionStart = ZjxlText.Text.Length;
             }
         }
     }
     _oldValue = Caption;
     Invalidate();
     OnTextChanged();
 }
Exemplo n.º 5
0
 /// <summary>
 /// 是否包含错误信息
 /// </summary>
 public bool HasError()
 {
     return(VerifyManager.Verify(this));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 是否包含错误信息
 /// </summary>
 public bool InputtingVerify(bool showError = false)
 {
     return(VerifyManager.Verify(this));
 }