From 79bb3d4c86a2caa12c98c0e5895e90e6e777876c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AB=E5=9F=8Evia?= Date: Wed, 31 Jul 2024 18:53:41 +0800 Subject: [PATCH] feature/add comma to InputLimits --- .../Panuon.WPF.UI/Enums/InputLimits.cs | 2 ++ .../Panuon.WPF.UI/Helpers/TextBoxHelper.cs | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Enums/InputLimits.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Enums/InputLimits.cs index 8ea35723..a76c0052 100644 --- a/SourceCode/SharedResources/Panuon.WPF.UI/Enums/InputLimits.cs +++ b/SourceCode/SharedResources/Panuon.WPF.UI/Enums/InputLimits.cs @@ -19,5 +19,7 @@ public enum InputLimits MultipleSpaces = 512, Dash = 1024, Underline = 2048, + Comma = 4096, + MultipleCommas = 8192, } } diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/TextBoxHelper.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/TextBoxHelper.cs index 5d921584..6971c40a 100644 --- a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/TextBoxHelper.cs +++ b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/TextBoxHelper.cs @@ -444,16 +444,20 @@ private static void TextBox_PreviewTextInput(object sender, TextCompositionEvent && inputChar >= 65 && inputChar <= 90) || (inputLimit.HasFlag(InputLimits.Point) && inputChar == '.' && !text.Contains(".")) || - (inputLimit.HasFlag(InputLimits.At) - && inputChar == '@' && !text.Contains("@")) || (inputLimit.HasFlag(InputLimits.MultiplePoints) && inputChar == '.') || + (inputLimit.HasFlag(InputLimits.At) + && inputChar == '@' && !text.Contains("@")) || (inputLimit.HasFlag(InputLimits.MultipleAts) && inputChar == '@') || - (inputLimit.HasFlag(InputLimits.Dash) + (inputLimit.HasFlag(InputLimits.Dash) && inputChar == '-') || - (inputLimit.HasFlag(InputLimits.Underline) - && inputChar == '_')) + (inputLimit.HasFlag(InputLimits.Underline) + && inputChar == '_') || + (inputLimit.HasFlag(InputLimits.Comma) + && inputChar == ',' && !text.Contains(",")) || + (inputLimit.HasFlag(InputLimits.MultipleCommas) + && inputChar == ',') ) { text += inputChar; }