feat: 完善 PortProxy 图形化管理工具
This commit is contained in:
14
PortProxyTool.Wpf/Rules/PortValidationRule.cs
Normal file
14
PortProxyTool.Wpf/Rules/PortValidationRule.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace PortProxyTool.Wpf.Rules;
|
||||
|
||||
public class PortValidationRule : ValidationRule
|
||||
{
|
||||
public override ValidationResult Validate(object? value, CultureInfo cultureInfo)
|
||||
{
|
||||
if (value is not string strValue) return new ValidationResult(false, "请输入有效的数字");
|
||||
if (string.IsNullOrEmpty(strValue) || ushort.TryParse(strValue, out _)) return ValidationResult.ValidResult;
|
||||
return new ValidationResult(false, "请输入有效的数字");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user