Skip to content

Commit

Permalink
[fix] 修复台风追踪不显示的问题
Browse files Browse the repository at this point in the history
修复UI异常
  • Loading branch information
zxbmmmmmmmmm committed Jul 22, 2024
1 parent 8d76ec4 commit 558c841
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
36 changes: 18 additions & 18 deletions FluentWeather.Uwp/Controls/Dialogs/TyphoonDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
<maps:MapItemsControl x:Name="MapItemsTyphoonNow" ItemsSource="{x:Bind Typhoons, Mode=OneWay}">
<maps:MapItemsControl.ItemTemplate>
<DataTemplate x:DataType="models:TyphoonBase">
<Grid Margin="-19,-32,0,0" maps:MapControl.Location="{x:Bind local:TyphoonDialog.GetGeoPoint(Now.Latitude, Now.Longitude)}">
<Grid Margin="-8" maps:MapControl.Location="{x:Bind local:TyphoonDialog.GetGeoPoint(Now.Latitude, Now.Longitude)}">
<controls1:DropShadowPanel
Margin="0,-16,0,0"
Margin="0,12,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BlurRadius="12"
Expand All @@ -74,9 +74,9 @@
</controls1:DropShadowPanel>

<controls1:DropShadowPanel
Margin="-2,24,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
BlurRadius="24"
IsMasked="True"
OffsetX="0"
Expand All @@ -94,8 +94,8 @@
<maps:MapItemsControl x:Name="MapItemsTyphoonTrack" ItemsSource="{x:Bind Tracks, Mode=OneWay}">
<maps:MapItemsControl.ItemTemplate>
<DataTemplate x:DataType="models:TyphoonTrackBase">
<Button
x:Name="mapItemButton"
<Button
x:Name="MapItemButton"
Width="20"
Height="20"
Margin="-10,-10,0,0"
Expand All @@ -107,13 +107,13 @@
<Ellipse
Width="5"
Height="5"
Fill="#CCFFFFFF" />
Fill="#80FFFFFF" />
<Button.Flyout>
<Flyout AllowFocusOnInteraction="True">
<StackPanel>
<TextBlock Style="{ThemeResource SubtitleTextBlockStyle}">
<Run Text="{x:Bind Type}" />
<Run Text="(" /><Run Text="{x:Bind Type, Converter={StaticResource TyphoonTypeToDescriptionConverter}}" /><Run Text=")" />
<Run Text="(" /><Run Text="{x:Bind local:TyphoonDialog.TyphoonTypeToDescription(Type)}" /><Run Text=")" />
</TextBlock>
<TextBlock Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" Text="{x:Bind Time}" />
<TextBlock Margin="0,4,0,0">
Expand Down Expand Up @@ -151,7 +151,7 @@
Background="{ThemeResource ButtonAcrylic}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
ItemsSource="{x:Bind Typhoons, Mode=OneWay}"
SelectedItem="{x:Bind _selected, Mode=TwoWay}"
SelectedItem="{x:Bind Selected, Mode=TwoWay}"
SelectionChanged="SegmentedControl_SelectionChanged">
<controls:Segmented.ItemTemplate>
<DataTemplate x:DataType="models:TyphoonBase">
Expand All @@ -166,34 +166,34 @@
Background="{ThemeResource ButtonAcrylic}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="4"
CornerRadius="4" x:DefaultBindMode="OneWay"
Visibility="{x:Bind SegmentedControl.SelectedItem, Converter={StaticResource NullToVisibilityConverter}, Mode=OneWay}">
<StackPanel Spacing="4" Visibility="{x:Bind SegmentedControl.SelectedItem, Converter={StaticResource NullToVisibilityConverter}, Mode=OneWay}">
<TextBlock Style="{ThemeResource TitleTextBlockStyle}">
<Run Text="{x:Bind _selected.Name}" />
<Run Text="{x:Bind Selected.Name}" />
<Run
FontSize="16"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
Text="{x:Bind local:TyphoonDialog.TyphoonTypeToDescription(_selected.Now.Type)}" />
Text="{x:Bind local:TyphoonDialog.TyphoonTypeToDescription(Selected.Now.Type)}" />
</TextBlock>
<StackPanel Orientation="Horizontal" Spacing="16">
<TextBlock>
<Run Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" Text="最大风速" />
<LineBreak /><Run FontSize="16" Text="{x:Bind _selected.Now.WindSpeed}" />
<LineBreak /><Run FontSize="16" Text="{x:Bind Selected.Now.WindSpeed}" />
<Run Text="m/s" />
</TextBlock>
<TextBlock>
<TextBlock Visibility="{x:Bind Selected.Now.MoveSpeed,Converter={StaticResource NullToVisibilityConverter}}">
<Run Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" Text="移动速度" />
<LineBreak /><Run FontSize="16" Text="{x:Bind _selected.Now.MoveSpeed}" />
<LineBreak /><Run FontSize="16" Text="{x:Bind Selected.Now.MoveSpeed}" />
<Run Text="km/h" />
</TextBlock>
<TextBlock>
<Run Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" Text="气压" />
<LineBreak /><Run FontSize="16" Text="{x:Bind _selected.Now.Pressure}" />
<LineBreak /><Run FontSize="16" Text="{x:Bind Selected.Now.Pressure}" />
<Run Text="kPa" />
</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="4">
<StackPanel Margin="0,12,0,0" Orientation="Horizontal" Spacing="8">
<Rectangle
Width="10"
Height="10"
Expand Down
15 changes: 8 additions & 7 deletions FluentWeather.Uwp/Controls/Dialogs/TyphoonDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public TyphoonDialog()
private ObservableCollection<TyphoonTrackBase> _tracks = new();
[ObservableProperty]
private ObservableCollection<TyphoonBase> _typhoons = new();
[ObservableProperty]
private TyphoonBase _selected;
public async void GetTyphoons()
{
Expand Down Expand Up @@ -131,7 +132,7 @@ public void ShowTrackRoute(TyphoonBase typhoon)
{
Path = new Geopath(path),
StrokeThickness = 2,
StrokeColor = Colors.Yellow,
StrokeColor = Color.FromArgb(160, 255, 255, 0),
};
TyphoonMap.MapElements.Add(line);
}
Expand All @@ -153,7 +154,7 @@ public void ShowForecastRoute(TyphoonBase typhoon)
{
Path = new Geopath(path),
StrokeThickness = 3,
StrokeColor = Colors.Red,
StrokeColor = Color.FromArgb(200, 255, 0, 0),
StrokeDashed = true
};
TyphoonMap.MapElements.Add(line);
Expand All @@ -168,7 +169,7 @@ public MapPolygon GetCircleMapPolygon(BasicGeoposition originalLocation, double
double longitude = originalLocation.Longitude * Math.PI / 180.0;
// double x = radius / 3956; // Miles
double x = radius / 6371000; // Meters
for (int i = 0; i <= 360; i += 10) // <-- you can modify this incremental to adjust the polygon.
for (int i = 0; i <= 360; i += 3) // <-- you can modify this incremental to adjust the polygon.
{
double aRads = i * Math.PI / 180.0;
double latRadians = Math.Asin(Math.Sin(latitude) * Math.Cos(x) + Math.Cos(latitude) * Math.Sin(x) * Math.Cos(aRads));
Expand Down Expand Up @@ -208,16 +209,16 @@ public void ShowWarningLines()
{
Path = new Geopath(locations24),
StrokeThickness = 2,
StrokeColor = Color.FromArgb(180, 255, 255, 0),
StrokeColor = Color.FromArgb(150, 255, 255, 0),
}; var line48 = new MapPolyline()
{
Path = new Geopath(locations48),
StrokeThickness = 2,
StrokeDashed = true,
StrokeColor = Color.FromArgb(160, 255, 255, 0),
StrokeColor = Color.FromArgb(120, 255, 255, 0),
};
var text24 = new TextBlock { TextWrapping = TextWrapping.Wrap, Text = "24小时警戒线" ,Foreground = new SolidColorBrush(Color.FromArgb(180, 255, 255, 0)) };
var text48 = new TextBlock { TextWrapping = TextWrapping.Wrap, Text = "48小时警戒线", Foreground = new SolidColorBrush(Color.FromArgb(160, 255, 255, 0)) };
var text24 = new TextBlock { TextWrapping = TextWrapping.Wrap, Text = "24小时警戒线" ,Foreground = new SolidColorBrush(Color.FromArgb(150, 255, 255, 0)) };
var text48 = new TextBlock { TextWrapping = TextWrapping.Wrap, Text = "48小时警戒线", Foreground = new SolidColorBrush(Color.FromArgb(120, 255, 255, 0)) };

TyphoonMap.MapElements.Add(line24);
TyphoonMap.MapElements.Add(line48);
Expand Down

0 comments on commit 558c841

Please sign in to comment.