From faff79e9c65ea36016801c54cb48eff7b9d3be60 Mon Sep 17 00:00:00 2001
From: status102 <102887808+status102@users.noreply.github.com>
Date: Mon, 24 Feb 2025 23:38:51 +0800
Subject: [PATCH] =?UTF-8?q?feat(wpf):=20Wpf=E6=97=A7Config=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0int=E8=AF=BB=E5=8F=96=20(#11987)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/MaaWpfGui/Helper/ConfigurationHelper.cs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/MaaWpfGui/Helper/ConfigurationHelper.cs b/src/MaaWpfGui/Helper/ConfigurationHelper.cs
index 1e5c2373a7..3f26bb370f 100644
--- a/src/MaaWpfGui/Helper/ConfigurationHelper.cs
+++ b/src/MaaWpfGui/Helper/ConfigurationHelper.cs
@@ -72,6 +72,18 @@ namespace MaaWpfGui.Helper
return defaultValue;
}
+ ///
+ /// Get a configuration value
+ ///
+ /// The config key
+ /// The default value to return if the key is not existed
+ /// The config value
+ public static int GetValue(string key, int defaultValue)
+ {
+ var value = GetValue(key, defaultValue.ToString());
+ return int.TryParse(value, out var result) ? result : defaultValue;
+ }
+
public static string GetGlobalValue(string key, string defaultValue)
{
var hasValue = _globalKvs.TryGetValue(key, out var value);
@@ -148,6 +160,8 @@ namespace MaaWpfGui.Helper
return result;
}
+ public static bool ContainsKey(string key, bool isGlobal = false) => isGlobal ? _globalKvs.ContainsKey(key) : _kvs.ContainsKey(key);
+
///
/// Deletes a configuration
///