Skip to content

Commit

Permalink
The choice of weather provider will stored in AppSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcapp committed Nov 13, 2019
1 parent d613a6c commit 6c833b6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions MikuWeather_CS/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,22 @@ private Bitmap SwitchBaiduPic(string picName, bool isDay) {

private void CmBaidu_Click(object sender, EventArgs e) {
Update("baidu");
Update_Setting("baidu");
}

private void CmCaiyun_Click(object sender, EventArgs e) {
Update("caiyun");
Update_Setting("caiyun");
}

private static void Update_Setting(string provider) {
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings["provider"] != null)
config.AppSettings.Settings["provider"].Value = provider;
else
config.AppSettings.Settings.Add("provider", provider);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
}
}

0 comments on commit 6c833b6

Please sign in to comment.