1、优化LOG显示与引用

2、添加PMA工具,工具内容待完善
3、修复流程树显示
4、添加开源项目,优化UI空间
5、其他BUG更改
This commit is contained in:
liu.wenjie
2021-11-23 15:51:37 +08:00
parent 47f77f5e64
commit a24dda2525
474 changed files with 91916 additions and 6429 deletions

View File

@@ -0,0 +1,52 @@
// ***********************************************************************
// 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
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://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; }
}
}

View File

@@ -0,0 +1,515 @@
// ***********************************************************************
// 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
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://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;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
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))]
[ProvideProperty("VerificationErrorMsg", typeof(Control))]
[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
{
get { return errorTipsBackColor; }
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
{
get { return errorTipsForeColor; }
set { errorTipsForeColor = value; }
}
private int autoCloseErrorTipsTime = 3000;
[Browsable(true), Category("自定义属性"), Description("自动关闭提示事件当值为0时不自动关闭"), Localizable(true)]
public int AutoCloseErrorTipsTime
{
get { return autoCloseErrorTipsTime; }
set
{
if (value < 0)
return;
autoCloseErrorTipsTime = value;
}
}
#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()
{
container.Add(this);
}
#endregion
#region English:Specifies whether this object can provide its extender properties to the specified object.
/// <summary>
/// 指定此对象是否可以将其扩展程序属性提供给指定的对象。
/// </summary>
/// <param name="extendee">要接收扩展程序属性的 <see cref="T:System.Object" />。</param>
/// <returns>如果此对象可以扩展程序属性提供给指定对象,则为 true否则为 false。</returns>
public bool CanExtend(object extendee)
{
if (extendee is TextBoxBase || extendee is UCTextBoxEx || extendee is ComboBox || extendee is UCCombox)
{
return true;
}
return false;
}
#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)
{
if (m_controlCache.ContainsKey(control))
{
return m_controlCache[control];
}
else
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;
}
#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)
{
if (m_controlRegexCache.ContainsKey(control))
{
return m_controlRegexCache[control];
}
else
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;
}
#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)
{
if (m_controlRequiredCache.ContainsKey(control))
return m_controlRequiredCache[control];
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;
}
#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)
{
if (m_controlMsgCache.ContainsKey(control))
return m_controlMsgCache[control];
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;
}
#endregion
#region English:Verification
/// <summary>
/// 功能描述:验证 English:Verification result processing
/// 作  者:HZH
/// 创建日期:2019-09-28 09:02:49
/// 任务编号:POS
/// </summary>
/// <param name="c">c</param>
/// <returns>返回值</returns>
public bool Verification(Control c)
{
bool bln = true;
if (m_controlCache.ContainsKey(c))
{
var vm = m_controlCache[c];
string strRegex = "";
string strErrMsg = "";
#region English:Get regular or error prompts
if (vm == VerificationModel.Custom)
{
//自定义正则
if (m_controlRegexCache.ContainsKey(c))
{
strRegex = m_controlRegexCache[c];
strErrMsg = "不正确的输入";
}
}
else
{
//获取默认正则和错误提示
Type type = vm.GetType(); //获取类型
MemberInfo[] memberInfos = type.GetMember(vm.ToString());
if (memberInfos.Length > 0)
{
var atts = memberInfos[0].GetCustomAttributes(typeof(VerificationAttribute), false);
if (atts.Length > 0)
{
var va = ((VerificationAttribute)atts[0]);
strErrMsg = va.ErrorMsg;
strRegex = va.Regex;
}
}
}
#endregion
#region English:Value
string strValue = "";
if (c is TextBoxBase)
{
strValue = (c as TextBoxBase).Text;
}
else if (c is UCTextBoxEx)
{
strValue = (c as UCTextBoxEx).InputText;
}
else if (c is ComboBox)
{
var cbo = (c as ComboBox);
if (cbo.DropDownStyle == ComboBoxStyle.DropDownList)
{
strValue = cbo.SelectedItem == null ? "" : cbo.SelectedValue.ToString();
}
else
{
strValue = cbo.Text;
}
}
else if (c is UCCombox)
{
strValue = (c as UCCombox).SelectedText;
}
#endregion
//自定义错误信息
if (m_controlMsgCache.ContainsKey(c) && !string.IsNullOrEmpty(m_controlMsgCache[c]))
strErrMsg = m_controlMsgCache[c];
//检查必填项
if (m_controlRequiredCache.ContainsKey(c) && m_controlRequiredCache[c])
{
if (string.IsNullOrEmpty(strValue))
{
VerControl(new VerificationEventArgs()
{
VerificationModel = vm,
Regex = strRegex,
ErrorMsg = "不能为空",
IsVerifySuccess = false,
Required = true,
VerificationControl = c
});
bln = false;
return false;
}
}
//验证正则
if (!string.IsNullOrEmpty(strValue))
{
if (!string.IsNullOrEmpty(strRegex))
{
if (!Regex.IsMatch(strValue, strRegex))
{
VerControl(new VerificationEventArgs()
{
VerificationModel = vm,
Regex = strRegex,
ErrorMsg = strErrMsg,
IsVerifySuccess = false,
Required = m_controlRequiredCache.ContainsKey(c) && m_controlRequiredCache[c],
VerificationControl = c
});
bln = false;
return false;
}
}
}
//没有问题出发一个成功信息
VerControl(new VerificationEventArgs()
{
VerificationModel = vm,
Regex = strRegex,
ErrorMsg = strErrMsg,
IsVerifySuccess = true,
Required = m_controlRequiredCache.ContainsKey(c) && m_controlRequiredCache[c],
VerificationControl = c
});
}
return bln;
}
#endregion
#region English:Verification
/// <summary>
/// 功能描述:验证 English:Verification
/// 作  者:HZH
/// 创建日期:2019-09-27 17:54:38
/// 任务编号:POS
/// </summary>
/// <returns>返回值</returns>
public bool Verification()
{
bool bln = true;
foreach (var item in m_controlCache)
{
Control c = item.Key;
if (!Verification(c))
{
bln = false;
}
}
return bln;
}
#endregion
#region English:Verification result processing
/// <summary>
/// 功能描述:验证结果处理 English:Verification result processing
/// 作  者:HZH
/// 创建日期:2019-09-27 17:54:59
/// 任务编号:POS
/// </summary>
/// <param name="e">e</param>
private void VerControl(VerificationEventArgs e)
{
//如果成功则移除失败提示
if (e.IsVerifySuccess)
{
if (m_controlTips.ContainsKey(e.VerificationControl))
{
m_controlTips[e.VerificationControl].Close();
m_controlTips.Remove(e.VerificationControl);
}
}
//触发事件
if (Verificationed != null)
{
Verificationed(e);
if (e.IsProcessed)//如果已处理,则不再向下执行
{
return;
}
}
//如果失败则显示提示
if (!e.IsVerifySuccess)
{
if (m_controlTips.ContainsKey(e.VerificationControl))
{
m_controlTips[e.VerificationControl].StrMsg = e.ErrorMsg;
}
else
{
var tips = Forms.FrmAnchorTips.ShowTips(e.VerificationControl, e.ErrorMsg, background: errorTipsBackColor, foreColor: errorTipsForeColor, autoCloseTime: autoCloseErrorTipsTime, blnTopMost: false);
tips.FormClosing += tips_FormClosing;
m_controlTips[e.VerificationControl] = tips;
}
}
}
void tips_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (var item in m_controlTips)
{
if (item.Value == sender)
{
m_controlTips.Remove(item.Key);
break;
}
}
}
#endregion
/// <summary>
/// 关闭所有错误提示
/// </summary>
public void CloseErrorTips()
{
for (int i = 0; i < 1; )
{
try
{
foreach (var item in m_controlTips)
{
if (item.Value != null && !item.Value.IsDisposed)
{
item.Value.Close();
}
}
}
catch
{
continue;
}
i++;
}
m_controlTips.Clear();
}
/// <summary>
/// 关闭指定验证控件的提示
/// </summary>
/// <param name="verificationControl">验证控件.</param>
public void CloseErrorTips(Control verificationControl)
{
if (m_controlTips.ContainsKey(verificationControl))
{
if (m_controlTips[verificationControl] != null && !m_controlTips[verificationControl].IsDisposed)
{
m_controlTips[verificationControl].Close();
}
}
}
}
}

View File

@@ -0,0 +1,68 @@
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-27
//
// ***********************************************************************
// <copyright file="VerificationEventArgs.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://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;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class VerificationEventArgs.
/// Implements the <see cref="System.EventArgs" />
/// </summary>
/// <seealso cref="System.EventArgs" />
public class VerificationEventArgs : EventArgs
{
/// <summary>
/// Gets or sets the verification control.
/// </summary>
/// <value>The verification control.</value>
public Control VerificationControl { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [verify success].
/// </summary>
/// <value><c>true</c> if [verify success]; otherwise, <c>false</c>.</value>
public bool IsVerifySuccess { get; set; }
/// <summary>
/// Gets or sets the verification model.
/// </summary>
/// <value>The verification model.</value>
public VerificationModel VerificationModel { get; set; }
/// <summary>
/// 是否已处理如果为true则不再使用默认验证提示功能
/// </summary>
/// <value><c>true</c> if this instance is processed; otherwise, <c>false</c>.</value>
public bool IsProcessed { get; set; }
/// <summary>
/// Gets or sets 正则表达式
/// </summary>
/// <value>The custom regex.</value>
public string Regex { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="VerificationEventArgs"/> is required.
/// </summary>
/// <value><c>true</c> if required; otherwise, <c>false</c>.</value>
public bool Required { get; set; }
/// <summary>
/// Gets or sets the error MSG.
/// </summary>
/// <value>The error MSG.</value>
public string ErrorMsg { get; set; }
}
}

View File

@@ -0,0 +1,100 @@
// ***********************************************************************
// 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
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://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;
using System.Text;
namespace HZH_Controls.Controls
{
/// <summary>
/// 验证规则
/// </summary>
public enum VerificationModel
{
/// <summary>
/// 无
/// </summary>
[Description("无"), VerificationAttribute()]
None = 1,
/// <summary>
/// 任意字母数字下划线
/// </summary>
[Description("任意字母数字下划线"), VerificationAttribute(@"^[a-zA-Z_0-1]*$", "线")]
AnyChar = 2,
/// <summary>
/// 任意数字
/// </summary>
[Description("任意数字"), VerificationAttribute(@"^[\-\+]?\d+(\.\d+)?$", "")]
Number = 4,
/// <summary>
/// 非负数
/// </summary>
[Description("非负数"), VerificationAttribute(@"^(\+)?\d+(\.\d+)?$", "请输入非负数")]
UnsignNumber = 8,
/// <summary>
/// 正数
/// </summary>
[Description("正数"), VerificationAttribute(@"(\+)?([1-9][0-9]*(\.\d{1,2})?)|(0\.\d{1,2})", "")]
PositiveNumber = 16,
/// <summary>
/// 整数
/// </summary>
[Description("整数"), VerificationAttribute(@"^[\+\-]?\d+$", "")]
Integer = 32,
/// <summary>
/// 非负整数
/// </summary>
[Description("非负整数"), VerificationAttribute(@"^(\+)?\d+$", "请输入非负整数")]
UnsignIntegerNumber = 64,
/// <summary>
/// 正整数
/// </summary>
[Description("正整数"), VerificationAttribute(@"^[0-9]*[1-9][0-9]*$", "")]
PositiveIntegerNumber = 128,
/// <summary>
/// 邮箱
/// </summary>
[Description("邮箱"), VerificationAttribute(@"^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$", "")]
Email = 256,
/// <summary>
/// 手机
/// </summary>
[Description("手机"), VerificationAttribute(@"^(\+?86)?1\d{10}$", "请输入正确的手机号")]
Phone = 512,
/// <summary>
/// IP
/// </summary>
[Description("IP"), VerificationAttribute(@"(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))", "IP地址")]
IP = 1024,
/// <summary>
/// Url
/// </summary>
[Description("Url"), VerificationAttribute(@"^[a-zA-z]+://(//w+(-//w+)*)(//.(//w+(-//w+)*))*(//?//S*)?$", "请输入正确的网址")]
URL = 2048,
/// <summary>
/// 身份证号
/// </summary>
[Description("身份证号"), VerificationAttribute(@"^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$", "")]
IDCardNo = 4096,
/// <summary>
/// 正则验证
/// </summary>
[Description("自定义正则表达式"), VerificationAttribute()]
Custom = 8192,
}
}