Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 330d7297
由
HZH
编写于
2019-09-28 09:33:20 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
验证
1 个父辈
7707ae4c
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
156 行增加
和
3 行删除
HZH_Controls/HZH_Controls/Controls/Verification/VerificationAttribute.cs
HZH_Controls/HZH_Controls/Controls/Verification/VerificationComponent.cs
HZH_Controls/HZH_Controls/Controls/Verification/VerificationModel.cs
HZH_Controls/HZH_Controls/Controls/Verification/VerificationAttribute.cs
查看文件 @
330d729
using
System
;
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-27
//
// ***********************************************************************
// <copyright file="VerificationAttribute.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class VerificationAttribute.
/// Implements the <see cref="System.Attribute" />
/// </summary>
/// <seealso cref="System.Attribute" />
public
class
VerificationAttribute
:
Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="VerificationAttribute"/> class.
/// </summary>
/// <param name="strRegex">The string regex.</param>
/// <param name="strErrorMsg">The string error MSG.</param>
public
VerificationAttribute
(
string
strRegex
=
""
,
string
strErrorMsg
=
""
)
{
Regex
=
strRegex
;
ErrorMsg
=
strErrorMsg
;
}
/// <summary>
/// Gets or sets the regex.
/// </summary>
/// <value>The regex.</value>
public
string
Regex
{
get
;
set
;
}
/// <summary>
/// Gets or sets the error MSG.
/// </summary>
/// <value>The error MSG.</value>
public
string
ErrorMsg
{
get
;
set
;
}
}
...
...
HZH_Controls/HZH_Controls/Controls/Verification/VerificationComponent.cs
查看文件 @
330d729
using
System
;
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-27
//
// ***********************************************************************
// <copyright file="VerificationComponent.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Drawing
;
...
...
@@ -10,6 +25,13 @@ using System.Windows.Forms;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class VerificationComponent.
/// Implements the <see cref="System.ComponentModel.Component" />
/// Implements the <see cref="System.ComponentModel.IExtenderProvider" />
/// </summary>
/// <seealso cref="System.ComponentModel.Component" />
/// <seealso cref="System.ComponentModel.IExtenderProvider" />
[
ProvideProperty
(
"VerificationModel"
,
typeof
(
Control
))]
[
ProvideProperty
(
"VerificationCustomRegex"
,
typeof
(
Control
))]
[
ProvideProperty
(
"VerificationRequired"
,
typeof
(
Control
))]
...
...
@@ -17,18 +39,47 @@ namespace HZH_Controls.Controls
[
DefaultEvent
(
"Verificationed"
)]
public
class
VerificationComponent
:
Component
,
IExtenderProvider
{
/// <summary>
/// Delegate VerificationedHandle
/// </summary>
/// <param name="e">The <see cref="VerificationEventArgs"/> instance containing the event data.</param>
public
delegate
void
VerificationedHandle
(
VerificationEventArgs
e
);
/// <summary>
/// Occurs when [verificationed].
/// </summary>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"验证事件"
),
Localizable
(
true
)]
public
event
VerificationedHandle
Verificationed
;
/// <summary>
/// The m control cache
/// </summary>
Dictionary
<
Control
,
VerificationModel
>
m_controlCache
=
new
Dictionary
<
Control
,
VerificationModel
>();
/// <summary>
/// The m control regex cache
/// </summary>
Dictionary
<
Control
,
string
>
m_controlRegexCache
=
new
Dictionary
<
Control
,
string
>();
/// <summary>
/// The m control required cache
/// </summary>
Dictionary
<
Control
,
bool
>
m_controlRequiredCache
=
new
Dictionary
<
Control
,
bool
>();
/// <summary>
/// The m control MSG cache
/// </summary>
Dictionary
<
Control
,
string
>
m_controlMsgCache
=
new
Dictionary
<
Control
,
string
>();
/// <summary>
/// The m control tips
/// </summary>
Dictionary
<
Control
,
Forms
.
FrmAnchorTips
>
m_controlTips
=
new
Dictionary
<
Control
,
Forms
.
FrmAnchorTips
>();
/// <summary>
/// The error tips back color
/// </summary>
private
Color
errorTipsBackColor
=
Color
.
FromArgb
(
255
,
77
,
58
);
/// <summary>
/// Gets or sets the color of the error tips back.
/// </summary>
/// <value>The color of the error tips back.</value>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"错误提示背景色"
),
Localizable
(
true
)]
public
Color
ErrorTipsBackColor
{
...
...
@@ -36,8 +87,15 @@ namespace HZH_Controls.Controls
set
{
errorTipsBackColor
=
value
;
}
}
/// <summary>
/// The error tips fore color
/// </summary>
private
Color
errorTipsForeColor
=
Color
.
White
;
/// <summary>
/// Gets or sets the color of the error tips fore.
/// </summary>
/// <value>The color of the error tips fore.</value>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"错误提示文字颜色"
),
Localizable
(
true
)]
public
Color
ErrorTipsForeColor
{
...
...
@@ -46,11 +104,18 @@ namespace HZH_Controls.Controls
}
#
region
构造函数
English
:
Constructor
/// <summary>
/// Initializes a new instance of the <see cref="VerificationComponent"/> class.
/// </summary>
public
VerificationComponent
()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="VerificationComponent"/> class.
/// </summary>
/// <param name="container">The container.</param>
public
VerificationComponent
(
IContainer
container
)
:
this
()
{
...
...
@@ -75,6 +140,11 @@ namespace HZH_Controls.Controls
#
endregion
#
region
验证规则
English
:
Validation
rule
/// <summary>
/// Gets the verification model.
/// </summary>
/// <param name="control">The control.</param>
/// <returns>VerificationModel.</returns>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"验证规则"
),
DisplayName
(
"VerificationModel"
),
Localizable
(
true
)]
public
VerificationModel
GetVerificationModel
(
Control
control
)
{
...
...
@@ -86,6 +156,11 @@ namespace HZH_Controls.Controls
return
VerificationModel
.
None
;
}
/// <summary>
/// Sets the verification model.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="vm">The vm.</param>
public
void
SetVerificationModel
(
Control
control
,
VerificationModel
vm
)
{
m_controlCache
[
control
]
=
vm
;
...
...
@@ -93,6 +168,11 @@ namespace HZH_Controls.Controls
#
endregion
#
region
自定义正则
English
:
Custom
Rules
/// <summary>
/// Gets the verification custom regex.
/// </summary>
/// <param name="control">The control.</param>
/// <returns>System.String.</returns>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"自定义验证正则表达式"
),
DisplayName
(
"VerificationCustomRegex"
),
Localizable
(
true
)]
public
string
GetVerificationCustomRegex
(
Control
control
)
{
...
...
@@ -104,6 +184,11 @@ namespace HZH_Controls.Controls
return
""
;
}
/// <summary>
/// Sets the verification custom regex.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="strRegex">The string regex.</param>
public
void
SetVerificationCustomRegex
(
Control
control
,
string
strRegex
)
{
m_controlRegexCache
[
control
]
=
strRegex
;
...
...
@@ -111,6 +196,11 @@ namespace HZH_Controls.Controls
#
endregion
#
region
必填
English
:
Must
fill
/// <summary>
/// Gets the verification required.
/// </summary>
/// <param name="control">The control.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"是否必填项"
),
DisplayName
(
"VerificationRequired"
),
Localizable
(
true
)]
public
bool
GetVerificationRequired
(
Control
control
)
{
...
...
@@ -119,6 +209,11 @@ namespace HZH_Controls.Controls
return
false
;
}
/// <summary>
/// Sets the verification required.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="blnRequired">if set to <c>true</c> [BLN required].</param>
public
void
SetVerificationRequired
(
Control
control
,
bool
blnRequired
)
{
m_controlRequiredCache
[
control
]
=
blnRequired
;
...
...
@@ -126,6 +221,11 @@ namespace HZH_Controls.Controls
#
endregion
#
region
提示信息
English
:
Prompt
information
/// <summary>
/// Gets the verification error MSG.
/// </summary>
/// <param name="control">The control.</param>
/// <returns>System.String.</returns>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"验证错误提示信息,当为空时则使用默认提示信息"
),
DisplayName
(
"VerificationErrorMsg"
),
Localizable
(
true
)]
public
string
GetVerificationErrorMsg
(
Control
control
)
{
...
...
@@ -134,6 +234,11 @@ namespace HZH_Controls.Controls
return
""
;
}
/// <summary>
/// Sets the verification error MSG.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="strErrorMsg">The string error MSG.</param>
public
void
SetVerificationErrorMsg
(
Control
control
,
string
strErrorMsg
)
{
m_controlMsgCache
[
control
]
=
strErrorMsg
;
...
...
HZH_Controls/HZH_Controls/Controls/Verification/VerificationModel.cs
查看文件 @
330d729
using
System
;
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-27
//
// ***********************************************************************
// <copyright file="VerificationModel.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Linq
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论