From fae8ac5584d434fa0ab1fd2f57026320fa65550d Mon Sep 17 00:00:00 2001 From: sanji Date: Wed, 6 Dec 2023 12:14:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E6=95=B0=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Converters/InputNumberConverter.cs | 41 ++++++++++++++++--- BBWY.Client/GlobalContext.cs | 2 +- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/BBWY.Client/Converters/InputNumberConverter.cs b/BBWY.Client/Converters/InputNumberConverter.cs index ce9c2890..3c7e2f50 100644 --- a/BBWY.Client/Converters/InputNumberConverter.cs +++ b/BBWY.Client/Converters/InputNumberConverter.cs @@ -1,4 +1,5 @@ -using System; +using MathNet.Numerics; +using System; using System.Globalization; using System.Windows; using System.Windows.Data; @@ -16,14 +17,44 @@ namespace BBWY.Client.Converters { string strValue = value as string; if (string.IsNullOrEmpty(strValue)) + { return null; + } decimal result; - var dotIndex = strValue.IndexOf('.'); - if (dotIndex == strValue.Length - 1 || - (dotIndex != -1 && strValue.EndsWith("0")) || - !decimal.TryParse(strValue, out result)) + if (strValue.IndexOf('.') == strValue.Length - 1 || (strValue.IndexOf('0') == strValue.Length - 1 && strValue.IndexOf('.') != -1) || !decimal.TryParse(strValue, out result)) + { return DependencyProperty.UnsetValue; + } return result; + + //if (string.IsNullOrEmpty(strValue)) + // return DependencyProperty.UnsetValue; + //if (strValue.EndsWith(".")) + // return DependencyProperty.UnsetValue; + //decimal result = 0M; + //var dotIndex = strValue.IndexOf('.'); + //if (dotIndex == -1) + // decimal.TryParse(strValue, out result); + //else + //{ + // //var intValueStr = strValue.Substring(0, dotIndex); + // var decimalValueStr = strValue.Substring(dotIndex + 1); + + // var n = 1M; + // if (decimalValueStr.Length == 1) + // n = 1.0M; + // if (decimalValueStr.Length == 2) + // n = 1.00M; + // if (decimalValueStr.Length == 3) + // n = 1.000M; + // if (decimalValueStr.Length == 4) + // n = 1.0000M; + // if (decimal.TryParse(strValue, out result)) + // result = decimal.Round(result * n, decimalValueStr.Length); + // else + // return DependencyProperty.UnsetValue; + //} + //return result; } } } diff --git a/BBWY.Client/GlobalContext.cs b/BBWY.Client/GlobalContext.cs index 2d42d82e..b3ad8edc 100644 --- a/BBWY.Client/GlobalContext.cs +++ b/BBWY.Client/GlobalContext.cs @@ -13,7 +13,7 @@ namespace BBWY.Client { ShopServiceGroupList = new List(); ShopServiceGroupLowerList = new List(); - ClientVersion = "10214"; + ClientVersion = "10215"; }