diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Converters/TelefoneToVisibilityConverter.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Converters/TelefoneToVisibilityConverter.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Converters/TelefoneToVisibilityConverter.cs b/Decompiler/Gestor.Application.Converters/TelefoneToVisibilityConverter.cs new file mode 100644 index 0000000..7f228fb --- /dev/null +++ b/Decompiler/Gestor.Application.Converters/TelefoneToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Globalization; +using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Application.Converters; + +public class TelefoneToVisibilityConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null || (string)value == "") + { + return (object)(Visibility)0; + } + return (object)(Visibility)(Regex.Match((string)value, "^[0-9]{4} [0-9]{3} [0-9]{4}$").Success ? 2 : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return value; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} |