添加Nlog,添加CheckBox demo
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -11,6 +12,15 @@ namespace AntdUIDemo.Utils
|
||||
{
|
||||
public static void UpdateAppSetting(string key, string value)
|
||||
{
|
||||
// 获取配置文件路径
|
||||
string configFilePath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
||||
|
||||
// 检查配置文件是否存在
|
||||
if (!File.Exists(configFilePath))
|
||||
{
|
||||
// 如果文件不存在,可以选择创建默认的配置文件
|
||||
CreateDefaultConfigFile(configFilePath);
|
||||
}
|
||||
// 获取当前配置文件
|
||||
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
|
||||
@@ -31,5 +41,22 @@ namespace AntdUIDemo.Utils
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
}
|
||||
|
||||
private static void CreateDefaultConfigFile(string configFilePath)
|
||||
{
|
||||
// 创建一个新的配置文件,并写入默认的appSettings
|
||||
var configXml = @"<?xml version='1.0' encoding='utf-8' ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key='ColorMode' value='Auto' />
|
||||
<add key='Animation' value='True' />
|
||||
<add key='ShadowEnabled' value='True' />
|
||||
<add key='ScrollBarHide' value='False' />
|
||||
<add key='ShowInWindow' value='True' />
|
||||
<add key='ShowOffset' value='0' />
|
||||
</appSettings>
|
||||
</configuration>";
|
||||
|
||||
File.WriteAllText(configFilePath, configXml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AntdUIDemo.Utils
|
||||
{
|
||||
public static class LoggerHelper
|
||||
{
|
||||
public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user