Skip to content

Commit

Permalink
Not using Baidu data source
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcapp committed Aug 14, 2023
1 parent 5f2802c commit c790ef6
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion MikuWeather_CS/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<appSettings>
<add key="apikey_baidu" value="edUWu66ddGavrmj9a6vcsa75" />
<add key="apikey_caiyun" value="XX3OXGV581TJoQNP" />
<add key="provider" value="baidu" />
<add key="provider" value="caiyun" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
Expand Down
26 changes: 11 additions & 15 deletions MikuWeather_CS/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System;
using MikuWeather.Properties;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
using MikuWeather.Properties;
using System.Drawing.Text;

namespace MikuWeather {
public partial class Form1 : Form {
// ReSharper disable once FieldCanBeMadeReadOnly.Local
private readonly FormShow _frmShow = new FormShow();

private string _city;
private string _coor;
private DateTime _sunrise;
private DateTime _sunset;
Expand All @@ -34,7 +34,6 @@ private void Form1_Load(object sender, EventArgs e) {
Size.Width, Size.Height);

var dictLocation = DataQuery.GetLocation();
_city = dictLocation["city"];
_coor = dictLocation["coor"];
var dictAstro = DataQuery.GetAstro_Caiyun(_coor);
var sunrise = dictAstro["sunrise"];
Expand All @@ -43,7 +42,8 @@ private void Form1_Load(object sender, EventArgs e) {
_sunset = DateTime.ParseExact(sunset, "HH:mm", CultureInfo.CurrentCulture);
cmWebsite.Text = @" 🔗 我们的Github仓库";
cmExit.Text = @" ✖ 退出";
_provider = ConfigurationManager.AppSettings["provider"];
//_provider = ConfigurationManager.AppSettings["provider"];
_provider = "caiyun";
Update(_provider);
}

Expand All @@ -69,11 +69,10 @@ private void CmExit_Click(object sender, EventArgs e) {
}

private void Update(string provider) {
switch (provider)
{
switch (provider) {
case "caiyun":
cmCaiyun.Enabled = false;
cmBaidu.Enabled = true;
cmBaidu.Enabled = false;
cmCaiyun.Text = @" ✔ 彩云天气API";
cmBaidu.Text = @" ⭕ 百度车联网API";
break;
Expand All @@ -96,7 +95,7 @@ private void Update(string provider) {
switch (provider) {
case "baidu":
bool isDay;
dict = DataQuery.UpdateData_Baidu(_city);
dict = DataQuery.UpdateData_Baidu(_coor);
string todayPicUrl;
string tomorrowPicUrl;
if (nowDt >= _sunrise && nowDt < _sunset) {
Expand All @@ -107,8 +106,7 @@ private void Update(string provider) {
todayWeather = dict["today weather"];
tomorrowWeather = dict["tomorrow weather"];
isDay = true;
}
else {
} else {
todayPicUrl = dict["today night pic url"];
tomorrowPicUrl = dict["tomorrow night pic url"];
isDay = false;
Expand Down Expand Up @@ -178,8 +176,7 @@ private static Bitmap SwitchCaiyunPic(string weather, bool isDay) {
return Resources.雨_日;
case "":
return Resources.雪_日;
}
else
} else
switch (weather) {
case "":
case "大风":
Expand Down Expand Up @@ -223,8 +220,7 @@ private Bitmap SwitchBaiduPic(string picName, bool isDay) {
case "leizhenyu.png":
case "leizhenyubanyoubingbao.png":
return Resources.雷阵雨_日;
}
else
} else
switch (picName) {
case "qing.png":
return Resources.晴_夜;
Expand Down
Loading

0 comments on commit c790ef6

Please sign in to comment.