src/App/Views/Panels/VasttrafikPanel.axaml
+4
-2
diff --git a/src/App/Views/Panels/VasttrafikPanel.axaml b/src/App/Views/Panels/VasttrafikPanel.axaml
index 5169ebb..ba6d9bb 100644
@@ -17,6 +17,7 @@
<Thickness x:Key="spacingTop">0,4,0,0</Thickness>
<Thickness x:Key="spacingRight">0,0,4,0</Thickness>
<Thickness x:Key="spacingAll">4,2</Thickness>
<v:TransportTypeIconConverter x:Key="transportTypeIconConverter" />
</UserControl.Resources>
<UserControl.Styles>
<Style Selector="TextBlock.label">
@@ -64,13 +65,14 @@
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" TextAlignment="Center"
Text="{Binding Name}" />
</Border>
<!-- TODO: Add "Type" icons -->
<PathIcon Grid.Column="1" Data="{Binding Type, Converter={StaticResource transportTypeIconConverter}}" Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}"
Width="{Binding #next.Bounds.Height}" Height="{Binding #next.Bounds.Height}" />
<TextBlock Grid.Column="2" Classes="h2" IsVisible="{Binding Via, Converter={x:Static ObjectConverters.IsNull}}" TextWrapping="Wrap" Text="{Binding Direction}" />
<TextBlock Grid.Column="2" Classes="h2" IsVisible="{Binding Via, Converter={x:Static ObjectConverters.IsNotNull}}" TextWrapping="Wrap">
<Run Text="{Binding Direction}" />
<Span FontSize="16">via <Run Text="{Binding Via}" /></Span>
</TextBlock>
<TextBlock Grid.Column="3" Classes="h2 time" Text="{v:MinutesLeftBinding {Binding Next}, CurrentTime={Binding $parent[UserControl].DataContext.CurrentTime}}" />
<TextBlock Grid.Column="3" Name="next" Classes="h2 time" Text="{v:MinutesLeftBinding {Binding Next}, CurrentTime={Binding $parent[UserControl].DataContext.CurrentTime}}" />
<TextBlock Grid.Column="4" Classes="h2 time" Text="{v:MinutesLeftBinding {Binding NextNext}, CurrentTime={Binding $parent[UserControl].DataContext.CurrentTime}}" />
<Ellipse Grid.Column="5" Width="{Binding #platform.Bounds.Height}" Height="{Binding #platform.Bounds.Height}"
HorizontalAlignment="Center" VerticalAlignment="Top" Margin="{StaticResource spacingTop}"
src/App/Views/Panels/VasttrafikPanel.axaml.cs
+28
-0
diff --git a/src/App/Views/Panels/VasttrafikPanel.axaml.cs b/src/App/Views/Panels/VasttrafikPanel.axaml.cs
index 60eca00..df9c5af 100644
@@ -1,9 +1,12 @@
using System;
using System.Globalization;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Media;
using MMirror.App.ViewModels.Panels;
using MMirror.Integrations.Vasttrafik;
namespace MMirror.App.Views.Panels;
@@ -50,3 +53,28 @@ public sealed class MinutesLeftBinding(BindingBase target)
}),
};
}
public sealed class TransportTypeIconConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
value switch
{
TransportType.Unknown => null,
TransportType.Tram => PathGeometry.Parse(
"M19 15V6.00999C19 4.90999 18.1 4.00999 17 4.00999H13.84L14.77 3.44999C15.09 3.25999 15.09 2.78999 14.77 2.59999L12.27 1.07999C12.19 1.02999 12.1 1.00999 12.01 1.00999C11.92 1.00999 11.83 1.02999 11.75 1.07999L9.25002 2.59999C8.93002 2.78999 8.93002 3.25999 9.25002 3.44999L10.18 4.00999H7.02002C5.92002 4.00999 5.02002 4.89999 5.02002 6.00999V15.01C5.02002 16.99 6.19002 18.69 7.86002 19.5L5.35002 22.01H8.18002L10.18 20.01H13.85L15.85 22.01H18.68L16.17 19.5C17.85 18.69 19.01 16.99 19.01 15.01L19 15ZM12 2.07999L13.54 3.01999L12 3.95999L10.46 3.01999L12 2.07999ZM9.00002 4.99999H15V5.99999H9.00002V4.99999ZM6.50002 14C6.22002 14 6.00002 13.78 6.00002 13.5V7.49999C6.00002 7.21999 6.22002 6.99999 6.50002 6.99999H7.46002L8.69002 14H6.49002H6.50002ZM12 18C11.45 18 11 17.55 11 17C11 16.45 11.45 16 12 16C12.55 16 13 16.45 13 17C13 17.55 12.55 18 12 18ZM9.71002 14L8.48002 6.99999H15.52L14.29 14H9.72002H9.71002ZM15.3 14L16.53 6.99999H17.49C17.77 6.99999 17.99 7.21999 17.99 7.49999V13.5C17.99 13.78 17.77 14 17.49 14H15.29H15.3Z"
),
TransportType.Bus => PathGeometry.Parse(
"M19.24 3.76C19.12 2.75 18.27 2 17.25 2H6.74996C5.72996 2 4.87996 2.75 4.75996 3.76C4.48996 6.12 4.06996 10.86 3.99996 17.97C3.98996 19.08 4.87996 19.99 5.98996 19.99V20.99C5.98996 21.54 6.43996 21.99 6.98996 21.99H7.98996C8.53996 21.99 8.98996 21.54 8.98996 20.99V19.99C10.89 19.99 13.06 19.99 14.99 19.99V20.99C14.99 21.54 15.44 21.99 15.99 21.99H16.99C17.54 21.99 17.99 21.54 17.99 20.99V19.99C19.1 19.99 20 19.07 19.99 17.96C19.92 10.85 19.5 6.12 19.23 3.75L19.24 3.76ZM8.99996 3H15V4H8.99996V3ZM7.49996 18C6.66996 18 5.99996 17.33 5.99996 16.5C5.99996 15.67 6.66996 15 7.49996 15C8.32996 15 8.99996 15.67 8.99996 16.5C8.99996 17.33 8.32996 18 7.49996 18ZM16.5 18C15.67 18 15 17.33 15 16.5C15 15.67 15.67 15 16.5 15C17.33 15 18 15.67 18 16.5C18 17.33 17.33 18 16.5 18ZM18 11.5C18 11.78 17.78 12 17.5 12H6.49996C6.21996 12 5.99996 11.78 5.99996 11.5V11C5.99996 8.68 6.29996 6.35 6.42996 5.42C6.46996 5.17 6.67996 5 6.91996 5H17.08C17.32 5 17.53 5.17 17.57 5.41C17.71 6.17 17.99 8.05 17.99 11V11.5H18Z"
),
TransportType.Ferry => PathGeometry.Parse(
"M12.38 9.13L18.5 11.25V9C18.5 8.45 18.02 8 17.42 8V5C17.42 4.45 16.93 4 16.34 4H13.51L12.86 2.28C12.8 2.11 12.67 2 12.52 2H11.48C11.34 2 11.21 2.11 11.14 2.28L10.49 4H7.66C7.06 4 6.58 4.45 6.58 5V8C5.98 8 5.5 8.45 5.5 9V11.25L11.62 9.13C11.87 9.05 12.14 9.05 12.38 9.13ZM8.5 7V6C8.5 5.72 8.72 5.5 9 5.5H15C15.28 5.5 15.5 5.72 15.5 6V7C15.5 7.28 15.28 7.5 15 7.5H9C8.72 7.5 8.5 7.28 8.5 7Z M19.92 16.41C19.55 16.63 19.28 16.8 18.66 16.8C18.51 16.8 18.38 16.79 18.27 16.77L19.95 13.5C20.09 13.23 19.95 12.91 19.68 12.8L12.35 10.12C12.13 10.04 11.88 10.04 11.66 10.12L4.33004 12.8C4.05004 12.9 3.92004 13.23 4.06004 13.5L5.74004 16.77C5.62004 16.79 5.49004 16.8 5.34004 16.8C4.73004 16.8 4.46004 16.64 4.09004 16.41C4.07004 16.4 4.04004 16.38 4.01004 16.37V18.17C4.35004 18.3 4.77004 18.4 5.34004 18.4C6.39004 18.4 6.96004 18.06 7.42004 17.79C7.79004 17.57 8.06004 17.4 8.67004 17.4C9.28004 17.4 9.55004 17.56 9.92004 17.79C10.38 18.06 10.94 18.4 12 18.4C13.06 18.4 13.62 18.06 14.08 17.79C14.45 17.57 14.72 17.4 15.34 17.4C15.96 17.4 16.22 17.56 16.6 17.79C17.06 18.06 17.62 18.4 18.68 18.4C19.25 18.4 19.67 18.3 20.02 18.16V16.36C20.02 16.36 19.96 16.39 19.94 16.41H19.92Z M18.66 20.4C18.05 20.4 17.78 20.24 17.4 20.01C16.94 19.74 16.38 19.4 15.32 19.4C14.26 19.4 13.7 19.74 13.24 20.01C12.87 20.23 12.6 20.4 11.99 20.4C11.38 20.4 11.11 20.24 10.74 20.01C10.28 19.74 9.72 19.4 8.66 19.4C7.6 19.4 7.04 19.74 6.58 20.01C6.21 20.23 5.94 20.4 5.33 20.4C4.72 20.4 4.45 20.24 4.08 20.01C4.06 20 4.03 19.98 4 19.97V21.77C4.34 21.9 4.76 22 5.33 22C6.38 22 6.95 21.66 7.41 21.39C7.78 21.17 8.05 21 8.66 21C9.27 21 9.54 21.16 9.91 21.39C10.37 21.66 10.93 22 11.99 22C13.05 22 13.61 21.66 14.07 21.39C14.44 21.17 14.71 21 15.33 21C15.95 21 16.21 21.16 16.59 21.39C17.05 21.66 17.61 22 18.67 22C19.24 22 19.66 21.9 20.01 21.76V19.96C20.01 19.96 19.95 19.99 19.93 20.01C19.56 20.23 19.29 20.4 18.67 20.4H18.66Z"
),
TransportType.Train => PathGeometry.Parse(
"M8.09 19.25L5.34 22H8.17L10.23 19.94C10.49 19.97 10.74 20 11.01 20H13.01C13.27 20 13.53 19.98 13.79 19.94L15.85 22H18.68L15.93 19.25C17.77 18.23 19.02 16.26 19.02 14V4C19.02 2.9 18.12 2 17.02 2H7C5.9 2 5 2.9 5 4V14C5 16.26 6.25 18.22 8.09 19.25ZM8 16.5C7.45 16.5 7 16.05 7 15.5C7 14.95 7.45 14.5 8 14.5C8.55 14.5 9 14.95 9 15.5C9 16.05 8.55 16.5 8 16.5ZM16 16.5C15.45 16.5 15 16.05 15 15.5C15 14.95 15.45 14.5 16 14.5C16.55 14.5 17 14.95 17 15.5C17 16.05 16.55 16.5 16 16.5ZM12.5 4H16.91C17.22 4 17.45 4.28 17.4 4.58L16.57 9.58C16.53 9.82 16.32 10 16.08 10H12.5V4ZM13.5 15.5C13.5 16.33 12.83 17 12 17C11.17 17 10.5 16.33 10.5 15.5C10.5 14.67 11.17 14 12 14C12.83 14 13.5 14.67 13.5 15.5ZM7.09 4H11.5V10H7.92C7.68 10 7.47 9.82 7.43 9.58L6.6 4.58C6.55 4.28 6.78 4 7.09 4Z"
),
_ => value,
};
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
throw new NotSupportedException();
}