Skip to content

Commit

Permalink
加入“今天有雨”的天气预报
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed May 25, 2024
1 parent cd50a49 commit 82793c6
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ private void UpdateCastWeathers()
File.WriteAllText(castWeatherFilePath, JsonConvert.SerializeObject(castWeathers, Formatting.Indented));
}

private bool isTodayRainy = false;

private void ShowCastWeathers()
{
if (castWeathers.Count != 0)
Expand All @@ -77,9 +79,16 @@ private void ShowCastWeathers()
if (today == 0) today = 7;
foreach (var castWeather in castWeathers)
{
if (castWeather.week != today && (castWeather.dayweather.Contains("雨") || castWeather.nightweather.Contains("雨")))
if (castWeather.dayweather.Contains("雨") || castWeather.nightweather.Contains("雨"))
{
rainDays += TransformDayOfWeek(castWeather.week) + "、";
if (castWeather.week == today)
{
isTodayRainy = true;
}
else
{
rainDays += TransformDayOfWeek(castWeather.week) + "、";
}
}
}
if (rainDays.Length > 0)
Expand All @@ -91,6 +100,7 @@ private void ShowCastWeathers()
{
LabelWeatherForecast.Content = "未来 " + (castWeathers.Count - 1) + " 天不会下雨";
}
if (isTodayRainy) LabelWeatherForecast.Content = "今天有雨," + LabelWeatherForecast.Content;
}
else
{
Expand Down

0 comments on commit 82793c6

Please sign in to comment.