From d23bc99f3d8f3c72bb1da0c44eebd671cf307fe6 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Tue, 16 Sep 2025 14:18:29 +0200 Subject: [PATCH] Added MapControl.UiTools.MapLayerInfo --- MapUiTools/Avalonia/MapLayerInfo.xaml | 44 +++++++++++++ .../Avalonia/MapUiTools.Avalonia.csproj | 11 ++++ .../Shared/HyperlinkText.cs | 4 +- MapUiTools/Shared/MapLayerInfo.xaml.cs | 34 ++++++++++ .../Shared/ProgressVisibilityConverter.cs | 45 +++++++++++++ MapUiTools/UWP/MapLayerInfo.xaml | 44 +++++++++++++ MapUiTools/WPF/MapLayerInfo.xaml | 42 ++++++++++++ MapUiTools/WinUI/MapLayerInfo.xaml | 44 +++++++++++++ SampleApps/AvaloniaApp/AvaloniaApp.csproj | 5 -- SampleApps/AvaloniaApp/MainWindow.axaml | 37 +++-------- .../Shared/MapHeadingToVisibilityConverter.cs | 44 +++++++++++++ SampleApps/Shared/ValueConverters.cs | 65 ------------------- SampleApps/UniversalApp/MainPage.xaml | 18 +---- SampleApps/WinUiApp/MainWindow.xaml | 18 +---- SampleApps/WpfApplication/MainWindow.xaml | 34 +++------- .../WpfApplication/WpfApplication.csproj | 4 -- 16 files changed, 332 insertions(+), 161 deletions(-) create mode 100644 MapUiTools/Avalonia/MapLayerInfo.xaml rename {SampleApps => MapUiTools}/Shared/HyperlinkText.cs (98%) create mode 100644 MapUiTools/Shared/MapLayerInfo.xaml.cs create mode 100644 MapUiTools/Shared/ProgressVisibilityConverter.cs create mode 100644 MapUiTools/UWP/MapLayerInfo.xaml create mode 100644 MapUiTools/WPF/MapLayerInfo.xaml create mode 100644 MapUiTools/WinUI/MapLayerInfo.xaml create mode 100644 SampleApps/Shared/MapHeadingToVisibilityConverter.cs delete mode 100644 SampleApps/Shared/ValueConverters.cs diff --git a/MapUiTools/Avalonia/MapLayerInfo.xaml b/MapUiTools/Avalonia/MapLayerInfo.xaml new file mode 100644 index 00000000..220bc54e --- /dev/null +++ b/MapUiTools/Avalonia/MapLayerInfo.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj b/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj index e6b6c648..4a55596f 100644 --- a/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj +++ b/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj @@ -10,11 +10,22 @@ + + + + + + + MSBuild:Compile + + + + diff --git a/SampleApps/Shared/HyperlinkText.cs b/MapUiTools/Shared/HyperlinkText.cs similarity index 98% rename from SampleApps/Shared/HyperlinkText.cs rename to MapUiTools/Shared/HyperlinkText.cs index 91c9f809..b9763f2d 100644 --- a/SampleApps/Shared/HyperlinkText.cs +++ b/MapUiTools/Shared/HyperlinkText.cs @@ -16,7 +16,7 @@ using System.Windows.Controls; using System.Windows.Documents; #endif -namespace SampleApplication +namespace MapControl.UiTools { public static class HyperlinkText { @@ -43,7 +43,7 @@ namespace SampleApplication var link = new Hyperlink { NavigateUri = uri }; link.Inlines.Add(new Run { Text = match.Groups[1].Value }); -#if !WINUI && !UWP +#if WPF link.ToolTip = uri.ToString(); link.RequestNavigate += (s, e) => diff --git a/MapUiTools/Shared/MapLayerInfo.xaml.cs b/MapUiTools/Shared/MapLayerInfo.xaml.cs new file mode 100644 index 00000000..b81c2bf3 --- /dev/null +++ b/MapUiTools/Shared/MapLayerInfo.xaml.cs @@ -0,0 +1,34 @@ +#if WPF +using System.Windows; +using System.Windows.Controls; +#elif UWP +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +#elif WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +#else +using Avalonia.Controls; +using DependencyProperty = Avalonia.AvaloniaProperty; +using FrameworkElement = Avalonia.Controls.Control; +#endif + +namespace MapControl.UiTools +{ + public partial class MapLayerInfo : UserControl + { + public static readonly DependencyProperty MapLayerProperty = + DependencyPropertyHelper.Register(nameof(MapLayer), null); + + public FrameworkElement MapLayer + { + get => (FrameworkElement)GetValue(MapLayerProperty); + set => SetValue(MapLayerProperty, value); + } + + public MapLayerInfo() + { + InitializeComponent(); + } + } +} diff --git a/MapUiTools/Shared/ProgressVisibilityConverter.cs b/MapUiTools/Shared/ProgressVisibilityConverter.cs new file mode 100644 index 00000000..4a7b6823 --- /dev/null +++ b/MapUiTools/Shared/ProgressVisibilityConverter.cs @@ -0,0 +1,45 @@ +using System; +using System.Globalization; +#if WPF +using System.Windows; +using System.Windows.Data; +#elif UWP +using Windows.UI.Xaml; +using Windows.UI.Xaml.Data; +#elif WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Data; +#else +using Avalonia.Data.Converters; +#endif + +namespace MapControl.UiTools +{ + internal partial class ProgressVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + var visible = (double)value < 1d; +#if AVALONIA + return visible; +#else + return visible ? Visibility.Visible : Visibility.Collapsed; +#endif + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return Convert(value, targetType, parameter, culture.ToString()); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/MapUiTools/UWP/MapLayerInfo.xaml b/MapUiTools/UWP/MapLayerInfo.xaml new file mode 100644 index 00000000..392325f7 --- /dev/null +++ b/MapUiTools/UWP/MapLayerInfo.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MapUiTools/WPF/MapLayerInfo.xaml b/MapUiTools/WPF/MapLayerInfo.xaml new file mode 100644 index 00000000..033b91ae --- /dev/null +++ b/MapUiTools/WPF/MapLayerInfo.xaml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MapUiTools/WinUI/MapLayerInfo.xaml b/MapUiTools/WinUI/MapLayerInfo.xaml new file mode 100644 index 00000000..bb1519dc --- /dev/null +++ b/MapUiTools/WinUI/MapLayerInfo.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleApps/AvaloniaApp/AvaloniaApp.csproj b/SampleApps/AvaloniaApp/AvaloniaApp.csproj index 73f6d731..6450d35c 100644 --- a/SampleApps/AvaloniaApp/AvaloniaApp.csproj +++ b/SampleApps/AvaloniaApp/AvaloniaApp.csproj @@ -17,10 +17,6 @@ - - - - Always @@ -37,7 +33,6 @@ - diff --git a/SampleApps/AvaloniaApp/MainWindow.axaml b/SampleApps/AvaloniaApp/MainWindow.axaml index 0c1d576f..777c966b 100644 --- a/SampleApps/AvaloniaApp/MainWindow.axaml +++ b/SampleApps/AvaloniaApp/MainWindow.axaml @@ -1,6 +1,5 @@ - - - - - - - - - - - - - - - - - - - + + @@ -223,9 +201,14 @@ diff --git a/SampleApps/Shared/MapHeadingToVisibilityConverter.cs b/SampleApps/Shared/MapHeadingToVisibilityConverter.cs new file mode 100644 index 00000000..4f288aca --- /dev/null +++ b/SampleApps/Shared/MapHeadingToVisibilityConverter.cs @@ -0,0 +1,44 @@ +using System; +using System.Globalization; +#if WPF +using System.Windows; +using System.Windows.Data; +#elif UWP +using Windows.UI.Xaml; +using Windows.UI.Xaml.Data; +#elif WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Data; +#else +using Avalonia.Data.Converters; +#endif + +namespace SampleApplication +{ + public class MapHeadingToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { +#if AVALONIA + return (double)value != 0d; +#else + return (double)value != 0d ? Visibility.Visible : Visibility.Collapsed; +#endif + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return Convert(value, targetType, parameter, culture.ToString()); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return ConvertBack(value, targetType, parameter, culture.ToString()); + } + } +} \ No newline at end of file diff --git a/SampleApps/Shared/ValueConverters.cs b/SampleApps/Shared/ValueConverters.cs deleted file mode 100644 index 346e6830..00000000 --- a/SampleApps/Shared/ValueConverters.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.ComponentModel; -using System.Globalization; -#if WINUI -using Microsoft.UI.Xaml.Data; -#elif UWP -using Windows.UI.Xaml.Data; -#elif AVALONIA -using Avalonia.Data.Converters; -#endif - -namespace SampleApplication -{ - public class DoubleTriggerConverter : IValueConverter - { - public double Trigger { get; set; } - public object TriggerValue { get; set; } - public object DefaultValue { get; set; } - - public object Convert(object value, Type targetType, object parameter, string language) - { - var converter = TypeDescriptor.GetConverter(targetType); - - return (double)value == Trigger ? converter.ConvertFrom(TriggerValue) : converter.ConvertFrom(DefaultValue); - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return Convert(value, targetType, parameter, ""); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return ConvertBack(value, targetType, parameter, ""); - } - } - - public class MapHeadingToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return (double)value != 0d; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return Convert(value, targetType, parameter, ""); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return ConvertBack(value, targetType, parameter, ""); - } - } -} \ No newline at end of file diff --git a/SampleApps/UniversalApp/MainPage.xaml b/SampleApps/UniversalApp/MainPage.xaml index fc933ceb..697306b3 100644 --- a/SampleApps/UniversalApp/MainPage.xaml +++ b/SampleApps/UniversalApp/MainPage.xaml @@ -168,21 +168,7 @@ FontFamily="Consolas" Margin="4,2" Visibility="Collapsed"/> - - - - - - - - - - - - - + - + diff --git a/SampleApps/WinUiApp/MainWindow.xaml b/SampleApps/WinUiApp/MainWindow.xaml index 348f7691..7ec3715f 100644 --- a/SampleApps/WinUiApp/MainWindow.xaml +++ b/SampleApps/WinUiApp/MainWindow.xaml @@ -193,21 +193,7 @@ FontFamily="Consolas" Margin="4,2" Visibility="Collapsed"/> - - - - - - - - - - - - - + - + diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index 9179cc68..6193cf94 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -170,23 +170,7 @@ - - - - - - - - - + - - - + + + + + + + diff --git a/SampleApps/WpfApplication/WpfApplication.csproj b/SampleApps/WpfApplication/WpfApplication.csproj index 038517b7..15ec6537 100644 --- a/SampleApps/WpfApplication/WpfApplication.csproj +++ b/SampleApps/WpfApplication/WpfApplication.csproj @@ -12,10 +12,6 @@ - - - - Always