From 8da77b7a150a2da0a3dfc4a26845935a76aeee9d Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Wed, 29 May 2024 17:19:03 +0200 Subject: [PATCH] Avalonia sample application --- SampleApps/AvaloniaApp/MainWindow.axaml.cs | 24 ++++++---------------- SampleApps/Shared/ValueConverters.cs | 15 ++++++++++++++ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/SampleApps/AvaloniaApp/MainWindow.axaml.cs b/SampleApps/AvaloniaApp/MainWindow.axaml.cs index ccfea697..b2e4ee98 100644 --- a/SampleApps/AvaloniaApp/MainWindow.axaml.cs +++ b/SampleApps/AvaloniaApp/MainWindow.axaml.cs @@ -68,32 +68,20 @@ namespace SampleApplication } }); } + + AddTestLayers(); } + partial void AddTestLayers(); + private void OnMapDoubleTapped(object sender, TappedEventArgs e) { - if (e.Source == map) - { - map.TargetCenter = map.ViewToLocation(e.GetPosition(map)); - } + map.TargetCenter = map.ViewToLocation(e.GetPosition(map)); } - private void ResetHeadingButtonClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e) + private void ResetHeadingButtonClick(object sender, Avalonia.Interactivity.RoutedEventArgs e) { map.TargetHeading = 0d; } } - - public class MapHeadingToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return (double)value != 0d; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotSupportedException(); - } - } } diff --git a/SampleApps/Shared/ValueConverters.cs b/SampleApps/Shared/ValueConverters.cs index c2009bb7..73ec6e4a 100644 --- a/SampleApps/Shared/ValueConverters.cs +++ b/SampleApps/Shared/ValueConverters.cs @@ -5,6 +5,8 @@ using System.Globalization; using Microsoft.UI.Xaml.Data; #elif UWP using Windows.UI.Xaml.Data; +#elif AVALONIA +using Avalonia.Data.Converters; #endif namespace SampleApplication @@ -37,4 +39,17 @@ namespace SampleApplication return ConvertBack(value, targetType, parameter, ""); } } + + public class MapHeadingToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (double)value != 0d; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } } \ No newline at end of file