diff --git a/MapControl/Shared/AutoEquirectangularProjection.cs b/MapControl/Shared/AutoEquirectangularProjection.cs index 138521f1..0543ce5c 100644 --- a/MapControl/Shared/AutoEquirectangularProjection.cs +++ b/MapControl/Shared/AutoEquirectangularProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/AzimuthalEquidistantProjection.cs b/MapControl/Shared/AzimuthalEquidistantProjection.cs index a541130b..41142480 100644 --- a/MapControl/Shared/AzimuthalEquidistantProjection.cs +++ b/MapControl/Shared/AzimuthalEquidistantProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/AzimuthalProjection.cs b/MapControl/Shared/AzimuthalProjection.cs index 6c7094f8..02d66b91 100644 --- a/MapControl/Shared/AzimuthalProjection.cs +++ b/MapControl/Shared/AzimuthalProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if WINDOWS_UWP +#if WINUI || WINDOWS_UWP using Windows.Foundation; #else using System.Windows; diff --git a/MapControl/Shared/BindingHelper.cs b/MapControl/Shared/BindingHelper.cs index 24c78e32..cd12509a 100644 --- a/MapControl/Shared/BindingHelper.cs +++ b/MapControl/Shared/BindingHelper.cs @@ -1,8 +1,11 @@ -// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control -// © 2021 Clemens Fischer +// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control +// © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Data; +#elif WINDOWS_UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Data; #else @@ -12,7 +15,7 @@ using System.Windows.Data; namespace MapControl { - internal static class PropertyHelper + internal static class BindingHelper { public static Binding GetBinding(this object sourceObject, string sourceProperty) { diff --git a/MapControl/Shared/BingMapsTileLayer.cs b/MapControl/Shared/BingMapsTileLayer.cs index fda71967..a126d67c 100644 --- a/MapControl/Shared/BingMapsTileLayer.cs +++ b/MapControl/Shared/BingMapsTileLayer.cs @@ -7,7 +7,9 @@ using System.Diagnostics; using System.Globalization; using System.Linq; using System.Xml.Linq; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +#elif WINDOWS_UWP using Windows.UI.Xaml; #else using System.Windows; diff --git a/MapControl/Shared/EquirectangularProjection.cs b/MapControl/Shared/EquirectangularProjection.cs index 5511589a..6701bd2b 100644 --- a/MapControl/Shared/EquirectangularProjection.cs +++ b/MapControl/Shared/EquirectangularProjection.cs @@ -4,7 +4,7 @@ using System; using System.Globalization; -#if WINDOWS_UWP +#if WINUI || WINDOWS_UWP using Windows.Foundation; #else using System.Windows; diff --git a/MapControl/Shared/GnomonicProjection.cs b/MapControl/Shared/GnomonicProjection.cs index bad9be00..9c5683c3 100644 --- a/MapControl/Shared/GnomonicProjection.cs +++ b/MapControl/Shared/GnomonicProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/HyperlinkText.cs b/MapControl/Shared/HyperlinkText.cs index c92c6071..7a5ff3bb 100644 --- a/MapControl/Shared/HyperlinkText.cs +++ b/MapControl/Shared/HyperlinkText.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Documents; +#elif WINDOWS_UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Documents; @@ -43,7 +47,7 @@ namespace MapControl var link = new Hyperlink { NavigateUri = uri }; link.Inlines.Add(new Run { Text = match.Groups[1].Value }); -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP link.ToolTip = uri.ToString(); link.RequestNavigate += (s, e) => diff --git a/MapControl/Shared/ImageLoader.cs b/MapControl/Shared/ImageLoader.cs index a47d35dd..4fad9340 100644 --- a/MapControl/Shared/ImageLoader.cs +++ b/MapControl/Shared/ImageLoader.cs @@ -8,7 +8,10 @@ using System.Diagnostics; using System.Linq; using System.Net.Http; using System.Threading.Tasks; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Imaging; +#elif WINDOWS_UWP using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Imaging; #else diff --git a/MapControl/Shared/Intersections.cs b/MapControl/Shared/Intersections.cs index ce17ef55..738f4d79 100644 --- a/MapControl/Shared/Intersections.cs +++ b/MapControl/Shared/Intersections.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if WINDOWS_UWP +#if WINUI || WINDOWS_UWP using Windows.Foundation; #else using System.Windows; diff --git a/MapControl/Shared/MapBase.cs b/MapControl/Shared/MapBase.cs index 6988a940..c5d19a3a 100644 --- a/MapControl/Shared/MapBase.cs +++ b/MapControl/Shared/MapBase.cs @@ -3,7 +3,12 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Animation; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; @@ -216,7 +221,6 @@ namespace MapControl public double ViewScale { get { return (double)GetValue(ViewScaleProperty); } - private set { SetViewScale(value); } } /// @@ -731,7 +735,7 @@ namespace MapControl } } - ViewScale = ViewTransform.Scale; + SetViewScale(ViewTransform.Scale); OnViewportChanged(new ViewportChangedEventArgs(projectionChanged, Center.Longitude - centerLongitude)); diff --git a/MapControl/Shared/MapGraticule.cs b/MapControl/Shared/MapGraticule.cs index 4bb0ed6f..38ac37e8 100644 --- a/MapControl/Shared/MapGraticule.cs +++ b/MapControl/Shared/MapGraticule.cs @@ -3,7 +3,9 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +#elif WINDOWS_UWP using Windows.UI.Xaml; #else using System.Windows; diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index fff0061c..99170f22 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -6,7 +6,13 @@ using System; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Animation; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/MapControl/Shared/MapItemsControl.cs b/MapControl/Shared/MapItemsControl.cs index d411f182..ac8791ef 100644 --- a/MapControl/Shared/MapItemsControl.cs +++ b/MapControl/Shared/MapItemsControl.cs @@ -3,7 +3,12 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Data; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/MapControl/Shared/MapOverlay.cs b/MapControl/Shared/MapOverlay.cs index 345343f7..cbdc2be5 100644 --- a/MapControl/Shared/MapOverlay.cs +++ b/MapControl/Shared/MapOverlay.cs @@ -2,7 +2,10 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml.Media; +using Windows.UI.Text; +#elif WINDOWS_UWP using Windows.UI.Text; using Windows.UI.Xaml.Media; #else diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs index 72e62a04..3fd14ede 100644 --- a/MapControl/Shared/MapPanel.cs +++ b/MapControl/Shared/MapPanel.cs @@ -4,7 +4,12 @@ using System; using System.Linq; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/MapControl/Shared/MapPath.cs b/MapControl/Shared/MapPath.cs index 87cd5a17..d6d938c4 100644 --- a/MapControl/Shared/MapPath.cs +++ b/MapControl/Shared/MapPath.cs @@ -2,7 +2,10 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Media; #else diff --git a/MapControl/Shared/MapPolygon.cs b/MapControl/Shared/MapPolygon.cs index 4cb38f41..ff137694 100644 --- a/MapControl/Shared/MapPolygon.cs +++ b/MapControl/Shared/MapPolygon.cs @@ -4,11 +4,13 @@ using System.Collections.Generic; using System.Linq; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Media; #else -using System.ComponentModel; using System.Windows; using System.Windows.Media; #endif @@ -28,7 +30,7 @@ namespace MapControl /// Gets or sets the Locations that define the polygon points. /// #if !WINDOWS_UWP - [TypeConverter(typeof(LocationCollectionConverter))] + [System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))] #endif public IEnumerable Locations { diff --git a/MapControl/Shared/MapPolyline.cs b/MapControl/Shared/MapPolyline.cs index 3eec8805..57d48895 100644 --- a/MapControl/Shared/MapPolyline.cs +++ b/MapControl/Shared/MapPolyline.cs @@ -4,11 +4,13 @@ using System.Collections.Generic; using System.Linq; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Media; #else -using System.ComponentModel; using System.Windows; using System.Windows.Media; #endif @@ -28,7 +30,7 @@ namespace MapControl /// Gets or sets the Locations that define the polyline points. /// #if !WINDOWS_UWP - [TypeConverter(typeof(LocationCollectionConverter))] + [System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))] #endif public IEnumerable Locations { diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs index d45b99f5..a80208be 100644 --- a/MapControl/Shared/MapProjection.cs +++ b/MapControl/Shared/MapProjection.cs @@ -4,7 +4,7 @@ using System; using System.Globalization; -#if WINDOWS_UWP +#if WINUI || WINDOWS_UWP using Windows.Foundation; #else using System.Windows; diff --git a/MapControl/Shared/MapScale.cs b/MapControl/Shared/MapScale.cs index 54b5d4c5..9edb88fe 100644 --- a/MapControl/Shared/MapScale.cs +++ b/MapControl/Shared/MapScale.cs @@ -3,7 +3,13 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Shapes; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index faa75314..133f37d0 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; diff --git a/MapControl/Shared/MapTileLayerBase.cs b/MapControl/Shared/MapTileLayerBase.cs index 94cb909e..c496d15e 100644 --- a/MapControl/Shared/MapTileLayerBase.cs +++ b/MapControl/Shared/MapTileLayerBase.cs @@ -4,7 +4,11 @@ using System; using System.Collections.Generic; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; @@ -61,7 +65,7 @@ namespace MapControl updateTimer = new DispatcherTimer { Interval = UpdateInterval }; updateTimer.Tick += (s, e) => Update(false); -#if WINDOWS_UWP +#if WINUI || WINDOWS_UWP MapPanel.InitMapElement(this); #endif } diff --git a/MapControl/Shared/OrthographicProjection.cs b/MapControl/Shared/OrthographicProjection.cs index 316f8e88..b5a57b23 100644 --- a/MapControl/Shared/OrthographicProjection.cs +++ b/MapControl/Shared/OrthographicProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/StereographicProjection.cs b/MapControl/Shared/StereographicProjection.cs index 74f92b54..defb63ea 100644 --- a/MapControl/Shared/StereographicProjection.cs +++ b/MapControl/Shared/StereographicProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/Tile.cs b/MapControl/Shared/Tile.cs index 8b0b7ab0..42f6f6e4 100644 --- a/MapControl/Shared/Tile.cs +++ b/MapControl/Shared/Tile.cs @@ -2,7 +2,12 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Animation; +#elif WINDOWS_UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; diff --git a/MapControl/Shared/TileSource.cs b/MapControl/Shared/TileSource.cs index e0829365..1f1f738c 100644 --- a/MapControl/Shared/TileSource.cs +++ b/MapControl/Shared/TileSource.cs @@ -4,10 +4,11 @@ using System; using System.Threading.Tasks; -#if WINDOWS_UWP +#if WINUI +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.UI.Xaml.Media; #else -using System.ComponentModel; using System.Windows.Media; #endif @@ -17,7 +18,7 @@ namespace MapControl /// Provides the download Uri or ImageSource of map tiles. /// #if !WINDOWS_UWP - [TypeConverter(typeof(TileSourceConverter))] + [System.ComponentModel.TypeConverter(typeof(TileSourceConverter))] #endif public class TileSource { diff --git a/MapControl/WPF/TypeConverters.WPF.cs b/MapControl/Shared/TypeConverters.cs similarity index 100% rename from MapControl/WPF/TypeConverters.WPF.cs rename to MapControl/Shared/TypeConverters.cs diff --git a/MapControl/Shared/ViewTransform.cs b/MapControl/Shared/ViewTransform.cs index a110f52f..78144ced 100644 --- a/MapControl/Shared/ViewTransform.cs +++ b/MapControl/Shared/ViewTransform.cs @@ -3,7 +3,10 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml.Media; #else diff --git a/MapControl/Shared/WebMercatorProjection.cs b/MapControl/Shared/WebMercatorProjection.cs index c03fa7f5..9b87a982 100644 --- a/MapControl/Shared/WebMercatorProjection.cs +++ b/MapControl/Shared/WebMercatorProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/WmsImageLayer.cs b/MapControl/Shared/WmsImageLayer.cs index fffcffe2..e62f5636 100644 --- a/MapControl/Shared/WmsImageLayer.cs +++ b/MapControl/Shared/WmsImageLayer.cs @@ -8,7 +8,11 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Xml.Linq; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; diff --git a/MapControl/Shared/WmtsCapabilities.cs b/MapControl/Shared/WmtsCapabilities.cs index 09a2437d..752e745c 100644 --- a/MapControl/Shared/WmtsCapabilities.cs +++ b/MapControl/Shared/WmtsCapabilities.cs @@ -8,7 +8,7 @@ using System.Globalization; using System.Linq; using System.Xml.Linq; using System.Threading.Tasks; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/WmtsTileLayer.cs b/MapControl/Shared/WmtsTileLayer.cs index 942a2553..1dc4cd74 100644 --- a/MapControl/Shared/WmtsTileLayer.cs +++ b/MapControl/Shared/WmtsTileLayer.cs @@ -6,7 +6,10 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; #else diff --git a/MapControl/Shared/WmtsTileMatrix.cs b/MapControl/Shared/WmtsTileMatrix.cs index 463bb4ba..1802147d 100644 --- a/MapControl/Shared/WmtsTileMatrix.cs +++ b/MapControl/Shared/WmtsTileMatrix.cs @@ -2,7 +2,7 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/Shared/WmtsTileMatrixLayer.cs b/MapControl/Shared/WmtsTileMatrixLayer.cs index 010fd523..a25fbbb7 100644 --- a/MapControl/Shared/WmtsTileMatrixLayer.cs +++ b/MapControl/Shared/WmtsTileMatrixLayer.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; -#if WINDOWS_UWP +#if WINUI +using Windows.Foundation; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +#elif WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; diff --git a/MapControl/Shared/WorldMercatorProjection.cs b/MapControl/Shared/WorldMercatorProjection.cs index 0efbe4f4..0ef618bf 100644 --- a/MapControl/Shared/WorldMercatorProjection.cs +++ b/MapControl/Shared/WorldMercatorProjection.cs @@ -3,7 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -#if !WINDOWS_UWP +#if !WINUI && !WINDOWS_UWP using System.Windows; #endif diff --git a/MapControl/UWP/Animatable.UWP.cs b/MapControl/UWP/Animatable.UWP.cs index ffcb3828..87802bec 100644 --- a/MapControl/UWP/Animatable.UWP.cs +++ b/MapControl/UWP/Animatable.UWP.cs @@ -2,8 +2,13 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media.Animation; +#else using Windows.UI.Xaml; using Windows.UI.Xaml.Media.Animation; +#endif namespace MapControl { diff --git a/MapControl/UWP/ImageLoader.UWP.cs b/MapControl/UWP/ImageLoader.UWP.cs index 211ad202..28447f16 100644 --- a/MapControl/UWP/ImageLoader.UWP.cs +++ b/MapControl/UWP/ImageLoader.UWP.cs @@ -8,8 +8,13 @@ using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.Streams; +#if WINUI +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Imaging; +#else using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Imaging; +#endif namespace MapControl { diff --git a/MapControl/UWP/Map.UWP.cs b/MapControl/UWP/Map.UWP.cs index 19863661..cfefdcb5 100644 --- a/MapControl/UWP/Map.UWP.cs +++ b/MapControl/UWP/Map.UWP.cs @@ -3,8 +3,13 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Input; +#else using Windows.UI.Xaml; using Windows.UI.Xaml.Input; +#endif namespace MapControl { diff --git a/MapControl/UWP/MapBase.UWP.cs b/MapControl/UWP/MapBase.UWP.cs index 945f1599..94235566 100644 --- a/MapControl/UWP/MapBase.UWP.cs +++ b/MapControl/UWP/MapBase.UWP.cs @@ -2,10 +2,15 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -using Windows.Foundation; +#if WINUI +using Microsoft.UI; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +#else using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; +#endif namespace MapControl { @@ -43,7 +48,11 @@ namespace MapControl internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register( "CenterPoint", typeof(Windows.Foundation.Point), typeof(MapBase), - new PropertyMetadata(new Windows.Foundation.Point(), (o, e) => ((MapBase)o).CenterPointPropertyChanged((Windows.Foundation.Point)e.NewValue))); + new PropertyMetadata(new Windows.Foundation.Point(), (o, e) => + { + var center = (Windows.Foundation.Point)e.NewValue; + ((MapBase)o).CenterPointPropertyChanged(new Location(center.Y, center.X)); + })); public MapBase() { @@ -52,26 +61,23 @@ namespace MapControl style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.White))); Style = style; - SizeChanged += (s, e) => - { - Clip = new RectangleGeometry - { - Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height) - }; + SizeChanged += OnSizeChanged; + } - ResetTransformCenter(); - UpdateTransform(); + private void OnSizeChanged(object sender, SizeChangedEventArgs e) + { + Clip = new RectangleGeometry + { + Rect = new Windows.Foundation.Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height) }; + + ResetTransformCenter(); + UpdateTransform(); } private void SetViewScale(double scale) { SetValue(ViewScaleProperty, scale); } - - private void CenterPointPropertyChanged(Windows.Foundation.Point center) - { - CenterPointPropertyChanged(new Location(center.Y, center.X)); - } } } diff --git a/MapControl/UWP/MapContentControl.UWP.cs b/MapControl/UWP/MapContentControl.UWP.cs index db26c3c1..6b921947 100644 --- a/MapControl/UWP/MapContentControl.UWP.cs +++ b/MapControl/UWP/MapContentControl.UWP.cs @@ -2,8 +2,13 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +#else using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +#endif namespace MapControl { diff --git a/MapControl/UWP/MapGraticule.UWP.cs b/MapControl/UWP/MapGraticule.UWP.cs index 67fad11e..2bb4fe82 100644 --- a/MapControl/UWP/MapGraticule.UWP.cs +++ b/MapControl/UWP/MapGraticule.UWP.cs @@ -4,9 +4,15 @@ using System; using Windows.Foundation; +#if WINUI +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Shapes; +#else using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Shapes; +#endif namespace MapControl { diff --git a/MapControl/UWP/MapItemsControl.UWP.cs b/MapControl/UWP/MapItemsControl.UWP.cs index 6a045233..ef07a625 100644 --- a/MapControl/UWP/MapItemsControl.UWP.cs +++ b/MapControl/UWP/MapItemsControl.UWP.cs @@ -3,9 +3,15 @@ // Licensed under the Microsoft Public License (Ms-PL) using Windows.System; +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Input; +#else using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; +#endif namespace MapControl { diff --git a/MapControl/UWP/MapOverlay.UWP.cs b/MapControl/UWP/MapOverlay.UWP.cs index 81b8daf9..d66b0b81 100644 --- a/MapControl/UWP/MapOverlay.UWP.cs +++ b/MapControl/UWP/MapOverlay.UWP.cs @@ -2,9 +2,16 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +#if WINUI +using Microsoft.UI.Text; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +using Windows.UI.Text; +#else using Windows.UI.Text; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; +#endif namespace MapControl { diff --git a/MapControl/UWP/MapPanel.UWP.cs b/MapControl/UWP/MapPanel.UWP.cs index a2382e3e..d444439e 100644 --- a/MapControl/UWP/MapPanel.UWP.cs +++ b/MapControl/UWP/MapPanel.UWP.cs @@ -2,8 +2,13 @@ // © 2021 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +#else using Windows.UI.Xaml; using Windows.UI.Xaml.Media; +#endif namespace MapControl { @@ -36,7 +41,7 @@ namespace MapControl } else { - // Workaround for missing property value inheritance in UWP. + // Workaround for missing property value inheritance. // Loaded and Unloaded handlers set and clear the ParentMap property value. element.Loaded += (s, e) => GetParentMap(element); diff --git a/MapControl/UWP/MapPath.UWP.cs b/MapControl/UWP/MapPath.UWP.cs index 285d9a36..82c36928 100644 --- a/MapControl/UWP/MapPath.UWP.cs +++ b/MapControl/UWP/MapPath.UWP.cs @@ -6,9 +6,15 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using Windows.Foundation; +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Shapes; +#else using Windows.UI.Xaml; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Shapes; +#endif namespace MapControl { @@ -19,7 +25,7 @@ namespace MapControl MapPanel.InitMapElement(this); } - #region Methods used only by derived classes MapPolyline and MapPolygon +#region Methods used only by derived classes MapPolyline and MapPolygon protected void DataCollectionPropertyChanged(DependencyPropertyChangedEventArgs e) { @@ -113,6 +119,6 @@ namespace MapControl } } - #endregion +#endregion } } diff --git a/MapControl/UWP/Matrix.UWP.cs b/MapControl/UWP/Matrix.UWP.cs index 3c6a06de..69d0168e 100644 --- a/MapControl/UWP/Matrix.UWP.cs +++ b/MapControl/UWP/Matrix.UWP.cs @@ -3,6 +3,11 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; +#if WINUI +using XamlMedia = Microsoft.UI.Xaml.Media; +#else +using XamlMedia = Windows.UI.Xaml.Media; +#endif namespace MapControl { @@ -28,9 +33,9 @@ namespace MapControl OffsetY = offsetY; } - public static implicit operator Windows.UI.Xaml.Media.Matrix(Matrix m) + public static implicit operator XamlMedia.Matrix(Matrix m) { - return new Windows.UI.Xaml.Media.Matrix(m.M11, m.M12, m.M21, m.M22, m.OffsetX, m.OffsetY); + return new XamlMedia.Matrix(m.M11, m.M12, m.M21, m.M22, m.OffsetX, m.OffsetY); } public Point Transform(Point p) diff --git a/MapControl/UWP/Properties/AssemblyInfo.cs b/MapControl/UWP/Properties/AssemblyInfo.cs index 847ab20f..9843175e 100644 --- a/MapControl/UWP/Properties/AssemblyInfo.cs +++ b/MapControl/UWP/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2021 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("5.6.0")] -[assembly: AssemblyFileVersion("5.6.0")] +[assembly: AssemblyVersion("6.0.0")] +[assembly: AssemblyFileVersion("6.0.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/UWP/Tile.UWP.cs b/MapControl/UWP/Tile.UWP.cs index 9afb3bd8..58337673 100644 --- a/MapControl/UWP/Tile.UWP.cs +++ b/MapControl/UWP/Tile.UWP.cs @@ -3,10 +3,17 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; +#if WINUI +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Imaging; +#else using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Imaging; +#endif namespace MapControl { diff --git a/MapControl/UWP/TileImageLoader.UWP.cs b/MapControl/UWP/TileImageLoader.UWP.cs index ceec6e1b..6e87189f 100644 --- a/MapControl/UWP/TileImageLoader.UWP.cs +++ b/MapControl/UWP/TileImageLoader.UWP.cs @@ -6,8 +6,13 @@ using System; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; using Windows.Storage; +#if WINUI +using Microsoft.System; +using Microsoft.UI.Xaml.Media; +#else using Windows.UI.Core; using Windows.UI.Xaml.Media; +#endif namespace MapControl { @@ -60,7 +65,7 @@ namespace MapControl { var tcs = new TaskCompletionSource(); - await tile.Image.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async () => + async void callback() { try { @@ -71,9 +76,18 @@ namespace MapControl { tcs.SetException(ex); } - }); - - await tcs.Task.ConfigureAwait(false); // wait until image loading in the UI thread is completed + } +#if WINUI + if (!tile.Image.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, callback)) + { + // not sure if this can ever happen, but just in case: reset tile.Pending and complete tcs + tile.Pending = true; + tcs.SetResult(null); + } +#else + _ = tile.Image.Dispatcher.RunAsync(CoreDispatcherPriority.Low, callback); +#endif + _ = await tcs.Task.ConfigureAwait(false); // wait until image loading in the UI thread is completed } } } diff --git a/MapControl/WPF/MapBase.WPF.cs b/MapControl/WPF/MapBase.WPF.cs index c2dccf94..055ad513 100644 --- a/MapControl/WPF/MapBase.WPF.cs +++ b/MapControl/WPF/MapBase.WPF.cs @@ -4,7 +4,6 @@ using System.Windows; using System.Windows.Controls; -using System.Windows.Media; namespace MapControl { @@ -49,8 +48,12 @@ namespace MapControl public static readonly DependencyProperty ViewScaleProperty = ViewScalePropertyKey.DependencyProperty; private static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register( - "CenterPoint", typeof(Point), typeof(MapBase), - new PropertyMetadata(new Point(), (o, e) => ((MapBase)o).CenterPointPropertyChanged((Point)e.NewValue))); + "CenterPoint", typeof(Point), typeof(MapBase), new PropertyMetadata(new Point(), + (o, e) => + { + var center = (Point)e.NewValue; + ((MapBase)o).CenterPointPropertyChanged(new Location(center.Y, center.X)); + })); static MapBase() { @@ -70,10 +73,5 @@ namespace MapControl { SetValue(ViewScalePropertyKey, scale); } - - private void CenterPointPropertyChanged(Point center) - { - CenterPointPropertyChanged(new Location(center.Y, center.X)); - } } } diff --git a/MapControl/WPF/MapControl.WPF.csproj b/MapControl/WPF/MapControl.WPF.csproj index 7028976e..d64da77b 100644 --- a/MapControl/WPF/MapControl.WPF.csproj +++ b/MapControl/WPF/MapControl.WPF.csproj @@ -1,5 +1,4 @@  - net5.0-windows;netcoreapp3.1;net48;net462 true @@ -9,7 +8,7 @@ ..\..\MapControl.snk false XAML Map Control - 5.6.0 + 6.0.0 XAML Map Control Library Clemens Fischer Copyright © 2021 Clemens Fischer @@ -34,7 +33,7 @@ - + diff --git a/MapControl/Shared/PolygonCollection.cs b/MapControl/WPF/PolygonCollection.WPF.cs similarity index 100% rename from MapControl/Shared/PolygonCollection.cs rename to MapControl/WPF/PolygonCollection.WPF.cs diff --git a/MapControl/WinUI/MapControl.WinUI.csproj b/MapControl/WinUI/MapControl.WinUI.csproj new file mode 100644 index 00000000..b71d4fdc --- /dev/null +++ b/MapControl/WinUI/MapControl.WinUI.csproj @@ -0,0 +1,41 @@ + + + net5.0-windows10.0.19041 + 10.0.17763.0 + MapControl + win10-x86;win10-x64;win10-arm64 + true + ..\..\MapControl.snk + false + XAML Map Control + 6.0.0 + XAML Map Control Library + Clemens Fischer + Copyright © 2021 Clemens Fischer + false + XAML.MapControl + + + + WINUI + + + + WINUI + + + + + + + + + + + + + + + + + diff --git a/SampleApps/UniversalApp/MainPage.xaml.cs b/SampleApps/UniversalApp/MainPage.xaml.cs index d2084b5e..2fb6a06c 100644 --- a/SampleApps/UniversalApp/MainPage.xaml.cs +++ b/SampleApps/UniversalApp/MainPage.xaml.cs @@ -47,7 +47,7 @@ namespace UniversalApp private void SeamarksChecked(object sender, RoutedEventArgs e) { - map.Children.Insert(map.Children.IndexOf(mapGraticule), ViewModel.MapLayers.SeamarksLayer); + map.Children.Insert(map.Children.IndexOf(graticule), ViewModel.MapLayers.SeamarksLayer); } private void SeamarksUnchecked(object sender, RoutedEventArgs e) diff --git a/SampleApps/UniversalApp/Properties/AssemblyInfo.cs b/SampleApps/UniversalApp/Properties/AssemblyInfo.cs index 07c95b20..c91b783c 100644 --- a/SampleApps/UniversalApp/Properties/AssemblyInfo.cs +++ b/SampleApps/UniversalApp/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2021 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("5.6.0")] -[assembly: AssemblyFileVersion("5.6.0")] +[assembly: AssemblyVersion("6.0.0")] +[assembly: AssemblyFileVersion("6.0.0")] [assembly: AssemblyConfiguration("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/WpfApplication.csproj b/SampleApps/WpfApplication/WpfApplication.csproj index 57393d24..2e576f1d 100644 --- a/SampleApps/WpfApplication/WpfApplication.csproj +++ b/SampleApps/WpfApplication/WpfApplication.csproj @@ -1,12 +1,11 @@  - WinExe net5.0-windows;net48 true WpfApplication XAML Map Control - 5.6.0 + 6.0.0 XAML Map Control WPF Sample Application Clemens Fischer Copyright © 2021 Clemens Fischer