Skip to content

Commit

Permalink
[fix] 修复历史天气无法显示破纪录温度的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zxbmmmmmmmmm committed Jul 22, 2024
1 parent b5857f4 commit 281372b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,14 @@ public static int Subtract(this int num1,int num2)
{
return num1 - num2;
}

public static int Max(this int num1, int num2)
{
return Math.Max(num1, num2);
}
public static int Min(this int num1, int num2)
{
return Math.Min(num1, num2);
}
}

10 changes: 5 additions & 5 deletions FluentWeather.Uwp/Controls/HistoricalWeatherGauge.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
Margin="24,0"
x:DefaultBindMode="OneWay"
LabelStep="1"
MaxValue="{x:Bind HistoricalDailyWeather.HistoricalMaxTemperature}"
MinValue="{x:Bind HistoricalDailyWeather.HistoricalMinTemperature}"
MaxValue="{x:Bind converters1:ConverterMethods.Max(HistoricalDailyWeather.HistoricalMaxTemperature,WeatherToday.MaxTemperature)}"
MinValue="{x:Bind converters1:ConverterMethods.Min(HistoricalDailyWeather.HistoricalMinTemperature,WeatherToday.MinTemperature)}"
TickStep="1"
Visibility="{x:Bind HistoricalDailyWeather, Converter={StaticResource NullToVisibilityConverter}}">
<dv:RadLinearGauge.TickTemplate>
Expand Down Expand Up @@ -150,9 +150,9 @@


<!-- 今日天气 指示条 -->
<dv:SegmentedLinearGaugeIndicator dv:RadLinearGauge.IndicatorOffset="12" Value="{x:Bind HistoricalDailyWeather.HistoricalMaxTemperature}">
<dv:SegmentedLinearGaugeIndicator dv:RadLinearGauge.IndicatorOffset="12" Value="{x:Bind converters1:ConverterMethods.Max(WeatherToday.MaxTemperature,HistoricalDailyWeather.HistoricalMaxTemperature)}">
<dv:BarIndicatorSegment
Length="{x:Bind converters1:ConverterMethods.Subtract(WeatherToday.MinTemperature, HistoricalDailyWeather.HistoricalMinTemperature)}"
Length="{x:Bind GetLength3Low(WeatherToday.MinTemperature, HistoricalDailyWeather.HistoricalMinTemperature)}"
Stroke="Transparent"
Thickness="4" />

Expand All @@ -161,7 +161,7 @@
Stroke="{ThemeResource HistoricalWeatherTodayRangeStroke}"
Thickness="4" />
<dv:BarIndicatorSegment
Length="{x:Bind converters1:ConverterMethods.Subtract(HistoricalDailyWeather.HistoricalMaxTemperature, WeatherToday.MaxTemperature)}"
Length="{x:Bind GetLength3High(HistoricalDailyWeather.HistoricalMaxTemperature, WeatherToday.MaxTemperature)}"
Stroke="Transparent"
Thickness="4" />
</dv:SegmentedLinearGaugeIndicator>
Expand Down
16 changes: 16 additions & 0 deletions FluentWeather.Uwp/Controls/HistoricalWeatherGauge.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,21 @@ private async void DownloadDataButton_Click(object sender, RoutedEventArgs e)
{
await DialogManager.OpenDialogAsync(new HistoricalWeatherSetupDialog(Common.Settings.DefaultGeolocation));
}

public bool IsHighTemperatureBreakRecord => WeatherToday?.MaxTemperature > HistoricalDailyWeather?.HistoricalMaxTemperature;
public bool IsLowTemperatureBreakRecord => WeatherToday?.MinTemperature < HistoricalDailyWeather?.HistoricalMinTemperature;

private int GetLength3High(int num1,int num2)
{
if (IsHighTemperatureBreakRecord) return 0;
return num1 - num2;
}

private int GetLength3Low(int num1, int num2)
{
if (IsLowTemperatureBreakRecord) return 0;
return num1 - num2;
}

}
}
6 changes: 3 additions & 3 deletions FluentWeather.Uwp/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
<StaticResource x:Key="InfoBarInformationalSeverityBackgroundBrush" ResourceKey="SystemControlAcrylicElementBrush" />
<SolidColorBrush x:Key="HistoricalWeatherAverageRangeStroke" Color="#80B3B3B3" />
<SolidColorBrush x:Key="HistoricalWeatherBaseRangeStroke" Color="#21BFBFBF" />
<SolidColorBrush x:Key="HistoricalWeatherTodayRangeStroke" Color="#66808080" />
<SolidColorBrush x:Key="HistoricalWeatherHighestLowestPointFill" Color="#FF666666" />
<SolidColorBrush x:Key="HistoricalWeatherTodayRangeStroke" Color="#40BFBFBF" />
<SolidColorBrush x:Key="HistoricalWeatherHighestLowestPointFill" Color="#99B3B3B3" />
<SolidColorBrush x:Key="HistoricalWeatherAveragePointFill" Color="#FFCCCCCC" />
<SolidColorBrush x:Key="HistoricalWeatherTodayPointFill" Color="#FF808080" />
<SolidColorBrush x:Key="HistoricalWeatherTodayPointFill" Color="#B3CCCCCC" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

Expand Down

0 comments on commit 281372b

Please sign in to comment.