This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppConfig.cs
81 lines (70 loc) · 2.8 KB
/
AppConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ITMHelper
{
static class AppConfig
{
public static string FontFamily
{
get { return ConfigurationManager.AppSettings["FontFamily"]; }
set { updateAppSetting("FontFamily", value); }
}
public static float FontSize
{
get { return float.Parse(ConfigurationManager.AppSettings["FontSize"]); }
set { updateAppSetting("FontSize", value.ToString()); }
}
public static int FontStyle
{
get { return int.Parse(ConfigurationManager.AppSettings["FontStyle"]); }
set { updateAppSetting("FontStyle", value.ToString()); }
}
public static string FontColor
{
get { return ConfigurationManager.AppSettings["FontColor"]; }
set { updateAppSetting("FontColor", value); }
}
public static string FontOutlineColor
{
get { return ConfigurationManager.AppSettings["FontOutlineColor"]; }
set { updateAppSetting("FontOutlineColor", value); }
}
public static float FontOutlineWidth
{
get { return float.Parse(ConfigurationManager.AppSettings["FontOutlineWidth"]); }
set { updateAppSetting("FontOutlineWidth", value.ToString("F1")); }
}
public static int DisplayIndex
{
get { return int.Parse(ConfigurationManager.AppSettings["DisplayIndex"]); }
set { updateAppSetting("DisplayIndex", value.ToString()); }
}
public static float DisplayPositionX
{
get { return float.Parse(ConfigurationManager.AppSettings["DisplayPositionX"]); }
set { updateAppSetting("DisplayPositionX", value.ToString("F3")); }
}
public static float DisplayPositionY
{
get { return float.Parse(ConfigurationManager.AppSettings["DisplayPositionY"]); }
set { updateAppSetting("DisplayPositionY", value.ToString("F3")); }
}
public static float LyricsTimeOffset
{
get { return float.Parse(ConfigurationManager.AppSettings["LyricsTimeOffset"]); }
set { updateAppSetting("LyricsTimeOffset", value.ToString("F2")); }
}
private static void updateAppSetting(string key, string value)
{
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
settings[key].Value = value;
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
}
}
}