From a0cc772e3de31fc11962a5ceec29fc58554fca09 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 02 一月 2025 02:54:21 +0800
Subject: [PATCH] 10331 【越南】【英语】【BT】【砍树】境界修改
---
Utility/UIHelper.cs | 68 ++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/Utility/UIHelper.cs b/Utility/UIHelper.cs
index e3efa2b..a4d666f 100644
--- a/Utility/UIHelper.cs
+++ b/Utility/UIHelper.cs
@@ -21,6 +21,49 @@
public static readonly string no_breaking_space = "\u00A0"; //Text鏂囨湰妗嗚緭鍏ョ┖鏍艰嚜鍔ㄦ崲琛岄棶棰� 鏇挎崲缂栫爜
+
+ //涓嶉渶瑕佹彁鍙栫炕璇戠殑鏂囨湰
+ private static readonly string[] numbers = new string[] { "闆�", "涓�", "浜�", "涓�", "鍥�", "浜�", "鍏�", "涓�", "鍏�", "涔�" };
+ private static readonly string[] units = new string[] { "鍗�", "鐧�", "鍗�", "涓�" };
+
+ //鏁板瓧杞腑鏂�(鍙仛灏忔暟瀛�)锛屾捣澶栫増鏈皟鐢ㄦ敼鍑芥暟鍒囨崲鐗堟湰璇风洿鎺ヨ繑鍥炴暟瀛�
+ public static string ChineseNumber(int number)
+ {
+ if (number == 0)
+ return numbers[0];
+
+ string result = "";
+ int unitPlace = 1; // 浣嶆暟锛�1 琛ㄧず鍗佷綅锛�2 琛ㄧず鐧句綅锛�3 琛ㄧず鍗冧綅锛�4 琛ㄧず涓囦綅
+ bool needZero = false; // 鏄惁闇�瑕佹坊鍔� '闆�'
+
+ while (number > 0)
+ {
+ int part = number % 10;
+ if (part != 0)
+ {
+ if (needZero)
+ result = StringUtility.Contact(numbers[0] + result);
+
+ result = numbers[part] + (unitPlace == 1 ? "" : units[unitPlace - 2]) + result; // 鍗曚綅鍙湪鍗併�佺櫨銆佸崈銆佷竾鍐呴儴浣跨敤
+ needZero = false;
+ }
+ else
+ {
+ needZero = true;
+ }
+
+ number /= 10;
+ unitPlace++;
+ }
+ if (result.StartsWith("涓�鍗�"))
+ {
+ result = result.Substring(1);
+ }
+
+ return result;
+ }
+
+
#region UI閫氱敤
public static void SetIconWithMoneyType(this Image _image, int moneyType)
{
@@ -342,6 +385,31 @@
}
}
+ // 杞寲澶ф暟鍊煎甫鍗曚綅鐨勬樉绀猴紝濡傛灉灏忎簬200000鍒欐樉绀哄師鍊硷紝鍚﹀垯鏄剧ず澶ф暟鍊�
+ public static string ReplaceLargeNumEx(double num)
+ {
+ if (num < 200000)
+ {
+ //鏍规嵁鐣岄潰鐨勬樉绀哄亣瀹氬�� 200000锛屽彲鏍规嵁瀹為檯鎯呭喌璋冩暣
+ return GetNumFormat(num);
+ }
+ else
+ {
+ return ReplaceLargeNum(num);
+ }
+ }
+
+ //鏄剧ず鏈�澶氫袱浣嶅皬鏁帮紝骞舵寜鍦板尯鏄剧ず鏍煎紡
+ // 濡備腑鏂囩敤F2 鏄剧ず 1111.34锛岃嫳鏂囩敤N2 鏄剧ず 1,111.34锛堝甫閫楀彿锛�
+ public static string GetNumFormat(double num)
+ {
+ if (num == (int)num)
+ {
+ return num.ToString("F0");
+ }
+ return num.ToString("F2").TrimEnd('0').TrimEnd('.');
+ }
+
public static float ReplacePercentage(float num, int isPer, int decimals = 1)
{
--
Gitblit v1.8.0