Added Custom support for TextType
This commit is contained in:
1 parent
2ced600571
commit
e8ecb7d6be
2 files changed
+16
-1
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
@@ -75,6 +76,16 @@ namespace HandyControl.Controls
|
|||||||
set => SetValue(ShowClearButtonProperty, value);
|
set => SetValue(ShowClearButtonProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty TextTypeCustomRegexPatternProperty = DependencyProperty.Register(
|
||||||
|
"TextTypeCustomRegexPattern", typeof(string), typeof(TextBox), new PropertyMetadata(null));
|
||||||
|
|
||||||
|
public string TextTypeCustomRegexPattern
|
||||||
|
{
|
||||||
|
get => (string)GetValue(TextTypeCustomRegexPatternProperty);
|
||||||
|
set => SetValue(TextTypeCustomRegexPatternProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual bool VerifyData()
|
public virtual bool VerifyData()
|
||||||
{
|
{
|
||||||
OperationResult<bool> result;
|
OperationResult<bool> result;
|
||||||
@@ -89,7 +100,10 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
if (TextType != TextType.Common)
|
if (TextType != TextType.Common)
|
||||||
{
|
{
|
||||||
result = Text.IsKindOf(TextType) ? OperationResult.Success() : OperationResult.Failed(Properties.Langs.Lang.FormatError);
|
if (TextType == TextType.Custom && !string.IsNullOrEmpty(TextTypeCustomRegexPattern))
|
||||||
|
result = Regex.IsMatch(Text, TextTypeCustomRegexPattern) ? OperationResult.Success() : OperationResult.Failed(Properties.Langs.Lang.FormatError);
|
||||||
|
else
|
||||||
|
result = Text.IsKindOf(TextType) ? OperationResult.Success() : OperationResult.Failed(Properties.Langs.Lang.FormatError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,5 +23,6 @@ namespace HandyControl.Data
|
|||||||
Double,
|
Double,
|
||||||
NnDouble,
|
NnDouble,
|
||||||
NpDouble,
|
NpDouble,
|
||||||
|
Custom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user