Version 6.0: Added WinUI

This commit is contained in:
Clemens 2021-06-14 21:41:37 +02:00
parent 4fc8594563
commit c215e1fb61
57 changed files with 287 additions and 90 deletions

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if WINDOWS_UWP #if WINUI || WINDOWS_UWP
using Windows.Foundation; using Windows.Foundation;
#else #else
using System.Windows; using System.Windows;

View file

@ -1,8 +1,11 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control // XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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;
using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Data;
#else #else
@ -12,7 +15,7 @@ using System.Windows.Data;
namespace MapControl namespace MapControl
{ {
internal static class PropertyHelper internal static class BindingHelper
{ {
public static Binding GetBinding(this object sourceObject, string sourceProperty) public static Binding GetBinding(this object sourceObject, string sourceProperty)
{ {

View file

@ -7,7 +7,9 @@ using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
#if WINDOWS_UWP #if WINUI
using Microsoft.UI.Xaml;
#elif WINDOWS_UWP
using Windows.UI.Xaml; using Windows.UI.Xaml;
#else #else
using System.Windows; using System.Windows;

View file

@ -4,7 +4,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
#if WINDOWS_UWP #if WINUI || WINDOWS_UWP
using Windows.Foundation; using Windows.Foundation;
#else #else
using System.Windows; using System.Windows;

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -5,7 +5,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; 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;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents; using Windows.UI.Xaml.Documents;
@ -43,7 +47,7 @@ namespace MapControl
var link = new Hyperlink { NavigateUri = uri }; var link = new Hyperlink { NavigateUri = uri };
link.Inlines.Add(new Run { Text = match.Groups[1].Value }); link.Inlines.Add(new Run { Text = match.Groups[1].Value });
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
link.ToolTip = uri.ToString(); link.ToolTip = uri.ToString();
link.RequestNavigate += (s, e) => link.RequestNavigate += (s, e) =>

View file

@ -8,7 +8,10 @@ using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; 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;
using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Imaging;
#else #else

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if WINDOWS_UWP #if WINUI || WINDOWS_UWP
using Windows.Foundation; using Windows.Foundation;
#else #else
using System.Windows; using System.Windows;

View file

@ -3,7 +3,12 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; 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.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
@ -216,7 +221,6 @@ namespace MapControl
public double ViewScale public double ViewScale
{ {
get { return (double)GetValue(ViewScaleProperty); } get { return (double)GetValue(ViewScaleProperty); }
private set { SetViewScale(value); }
} }
/// <summary> /// <summary>
@ -731,7 +735,7 @@ namespace MapControl
} }
} }
ViewScale = ViewTransform.Scale; SetViewScale(ViewTransform.Scale);
OnViewportChanged(new ViewportChangedEventArgs(projectionChanged, Center.Longitude - centerLongitude)); OnViewportChanged(new ViewportChangedEventArgs(projectionChanged, Center.Longitude - centerLongitude));

View file

@ -3,7 +3,9 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if WINDOWS_UWP #if WINUI
using Microsoft.UI.Xaml;
#elif WINDOWS_UWP
using Windows.UI.Xaml; using Windows.UI.Xaml;
#else #else
using System.Windows; using System.Windows;

View file

@ -6,7 +6,13 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; 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.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;

View file

@ -3,7 +3,12 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; 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.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;

View file

@ -2,7 +2,10 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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.Text;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#else #else

View file

@ -4,7 +4,12 @@
using System; using System;
using System.Linq; 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.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;

View file

@ -2,7 +2,10 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#else #else

View file

@ -4,11 +4,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; 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;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#else #else
using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
#endif #endif
@ -28,7 +30,7 @@ namespace MapControl
/// Gets or sets the Locations that define the polygon points. /// Gets or sets the Locations that define the polygon points.
/// </summary> /// </summary>
#if !WINDOWS_UWP #if !WINDOWS_UWP
[TypeConverter(typeof(LocationCollectionConverter))] [System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
#endif #endif
public IEnumerable<Location> Locations public IEnumerable<Location> Locations
{ {

View file

@ -4,11 +4,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; 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;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#else #else
using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
#endif #endif
@ -28,7 +30,7 @@ namespace MapControl
/// Gets or sets the Locations that define the polyline points. /// Gets or sets the Locations that define the polyline points.
/// </summary> /// </summary>
#if !WINDOWS_UWP #if !WINDOWS_UWP
[TypeConverter(typeof(LocationCollectionConverter))] [System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
#endif #endif
public IEnumerable<Location> Locations public IEnumerable<Location> Locations
{ {

View file

@ -4,7 +4,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
#if WINDOWS_UWP #if WINUI || WINDOWS_UWP
using Windows.Foundation; using Windows.Foundation;
#else #else
using System.Windows; using System.Windows;

View file

@ -3,7 +3,13 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; 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.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;

View file

@ -5,7 +5,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; 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.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;

View file

@ -4,7 +4,11 @@
using System; using System;
using System.Collections.Generic; 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;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
@ -61,7 +65,7 @@ namespace MapControl
updateTimer = new DispatcherTimer { Interval = UpdateInterval }; updateTimer = new DispatcherTimer { Interval = UpdateInterval };
updateTimer.Tick += (s, e) => Update(false); updateTimer.Tick += (s, e) => Update(false);
#if WINDOWS_UWP #if WINUI || WINDOWS_UWP
MapPanel.InitMapElement(this); MapPanel.InitMapElement(this);
#endif #endif
} }

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -2,7 +2,12 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;

View file

@ -4,10 +4,11 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
#if WINDOWS_UWP #if WINUI
using Microsoft.UI.Xaml.Media;
#elif WINDOWS_UWP
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#else #else
using System.ComponentModel;
using System.Windows.Media; using System.Windows.Media;
#endif #endif
@ -17,7 +18,7 @@ namespace MapControl
/// Provides the download Uri or ImageSource of map tiles. /// Provides the download Uri or ImageSource of map tiles.
/// </summary> /// </summary>
#if !WINDOWS_UWP #if !WINDOWS_UWP
[TypeConverter(typeof(TileSourceConverter))] [System.ComponentModel.TypeConverter(typeof(TileSourceConverter))]
#endif #endif
public class TileSource public class TileSource
{ {

View file

@ -3,7 +3,10 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if WINDOWS_UWP #if WINUI
using Windows.Foundation;
using Microsoft.UI.Xaml.Media;
#elif WINDOWS_UWP
using Windows.Foundation; using Windows.Foundation;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#else #else

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -8,7 +8,11 @@ using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; 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.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;

View file

@ -8,7 +8,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -6,7 +6,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
#if WINDOWS_UWP #if WINUI
using Windows.Foundation;
using Microsoft.UI.Xaml;
#elif WINDOWS_UWP
using Windows.Foundation; using Windows.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
#else #else

View file

@ -2,7 +2,7 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -5,7 +5,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; 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.Foundation;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;

View file

@ -3,7 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if !WINDOWS_UWP #if !WINUI && !WINDOWS_UWP
using System.Windows; using System.Windows;
#endif #endif

View file

@ -2,8 +2,13 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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;
using Windows.UI.Xaml.Media.Animation; using Windows.UI.Xaml.Media.Animation;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -8,8 +8,13 @@ using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks; using System.Threading.Tasks;
using Windows.Storage; using Windows.Storage;
using Windows.Storage.Streams; 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;
using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Imaging;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -3,8 +3,13 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Input;
#else
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Input;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -2,10 +2,15 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#endif
namespace MapControl namespace MapControl
{ {
@ -43,7 +48,11 @@ namespace MapControl
internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register( internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register(
"CenterPoint", typeof(Windows.Foundation.Point), typeof(MapBase), "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() public MapBase()
{ {
@ -52,26 +61,23 @@ namespace MapControl
style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.White))); style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.White)));
Style = style; Style = style;
SizeChanged += (s, e) => SizeChanged += OnSizeChanged;
{ }
Clip = new RectangleGeometry
{
Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height)
};
ResetTransformCenter(); private void OnSizeChanged(object sender, SizeChangedEventArgs e)
UpdateTransform(); {
Clip = new RectangleGeometry
{
Rect = new Windows.Foundation.Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height)
}; };
ResetTransformCenter();
UpdateTransform();
} }
private void SetViewScale(double scale) private void SetViewScale(double scale)
{ {
SetValue(ViewScaleProperty, scale); SetValue(ViewScaleProperty, scale);
} }
private void CenterPointPropertyChanged(Windows.Foundation.Point center)
{
CenterPointPropertyChanged(new Location(center.Y, center.X));
}
} }
} }

View file

@ -2,8 +2,13 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -4,9 +4,15 @@
using System; using System;
using Windows.Foundation; 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.Controls;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes; using Windows.UI.Xaml.Shapes;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -3,9 +3,15 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using Windows.System; 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;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Input;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -2,9 +2,16 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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.Text;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -2,8 +2,13 @@
// © 2021 Clemens Fischer // © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // 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;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#endif
namespace MapControl namespace MapControl
{ {
@ -36,7 +41,7 @@ namespace MapControl
} }
else 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. // Loaded and Unloaded handlers set and clear the ParentMap property value.
element.Loaded += (s, e) => GetParentMap(element); element.Loaded += (s, e) => GetParentMap(element);

View file

@ -6,9 +6,15 @@ using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using Windows.Foundation; 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;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes; using Windows.UI.Xaml.Shapes;
#endif
namespace MapControl namespace MapControl
{ {
@ -19,7 +25,7 @@ namespace MapControl
MapPanel.InitMapElement(this); 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) protected void DataCollectionPropertyChanged(DependencyPropertyChangedEventArgs e)
{ {
@ -113,6 +119,6 @@ namespace MapControl
} }
} }
#endregion #endregion
} }
} }

View file

@ -3,6 +3,11 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; using System;
#if WINUI
using XamlMedia = Microsoft.UI.Xaml.Media;
#else
using XamlMedia = Windows.UI.Xaml.Media;
#endif
namespace MapControl namespace MapControl
{ {
@ -28,9 +33,9 @@ namespace MapControl
OffsetY = offsetY; 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) public Point Transform(Point p)

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2021 Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2021 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("5.6.0")] [assembly: AssemblyVersion("6.0.0")]
[assembly: AssemblyFileVersion("5.6.0")] [assembly: AssemblyFileVersion("6.0.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -3,10 +3,17 @@
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System; 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;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Imaging;
#endif
namespace MapControl namespace MapControl
{ {

View file

@ -6,8 +6,13 @@ using System;
using System.Runtime.InteropServices.WindowsRuntime; using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks; using System.Threading.Tasks;
using Windows.Storage; using Windows.Storage;
#if WINUI
using Microsoft.System;
using Microsoft.UI.Xaml.Media;
#else
using Windows.UI.Core; using Windows.UI.Core;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
#endif
namespace MapControl namespace MapControl
{ {
@ -60,7 +65,7 @@ namespace MapControl
{ {
var tcs = new TaskCompletionSource<object>(); var tcs = new TaskCompletionSource<object>();
await tile.Image.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async () => async void callback()
{ {
try try
{ {
@ -71,9 +76,18 @@ namespace MapControl
{ {
tcs.SetException(ex); tcs.SetException(ex);
} }
}); }
#if WINUI
await tcs.Task.ConfigureAwait(false); // wait until image loading in the UI thread is completed 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
} }
} }
} }

View file

@ -4,7 +4,6 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media;
namespace MapControl namespace MapControl
{ {
@ -49,8 +48,12 @@ namespace MapControl
public static readonly DependencyProperty ViewScaleProperty = ViewScalePropertyKey.DependencyProperty; public static readonly DependencyProperty ViewScaleProperty = ViewScalePropertyKey.DependencyProperty;
private static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register( private static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register(
"CenterPoint", typeof(Point), typeof(MapBase), "CenterPoint", typeof(Point), typeof(MapBase), new PropertyMetadata(new Point(),
new PropertyMetadata(new Point(), (o, e) => ((MapBase)o).CenterPointPropertyChanged((Point)e.NewValue))); (o, e) =>
{
var center = (Point)e.NewValue;
((MapBase)o).CenterPointPropertyChanged(new Location(center.Y, center.X));
}));
static MapBase() static MapBase()
{ {
@ -70,10 +73,5 @@ namespace MapControl
{ {
SetValue(ViewScalePropertyKey, scale); SetValue(ViewScalePropertyKey, scale);
} }
private void CenterPointPropertyChanged(Point center)
{
CenterPointPropertyChanged(new Location(center.Y, center.X));
}
} }
} }

View file

@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net5.0-windows;netcoreapp3.1;net48;net462</TargetFrameworks> <TargetFrameworks>net5.0-windows;netcoreapp3.1;net48;net462</TargetFrameworks>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
@ -9,7 +8,7 @@
<AssemblyOriginatorKeyFile>..\..\MapControl.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\..\MapControl.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign> <DelaySign>false</DelaySign>
<Product>XAML Map Control</Product> <Product>XAML Map Control</Product>
<Version>5.6.0</Version> <Version>6.0.0</Version>
<Description>XAML Map Control Library</Description> <Description>XAML Map Control Library</Description>
<Authors>Clemens Fischer</Authors> <Authors>Clemens Fischer</Authors>
<Copyright>Copyright © 2021 Clemens Fischer</Copyright> <Copyright>Copyright © 2021 Clemens Fischer</Copyright>
@ -34,7 +33,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Shared\*" /> <Compile Include="..\Shared\*.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows' or '$(TargetFramework)' == 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows' or '$(TargetFramework)' == 'netcoreapp3.1'">

View file

@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.19041</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>MapControl</RootNamespace>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\MapControl.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Product>XAML Map Control</Product>
<Version>6.0.0</Version>
<Description>XAML Map Control Library</Description>
<Authors>Clemens Fischer</Authors>
<Copyright>Copyright © 2021 Clemens Fischer</Copyright>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageId>XAML.MapControl</PackageId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>WINUI</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>WINUI</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\MapControl.snk" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\*.cs" />
<Compile Include="..\UWP\*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="0.5.7" />
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.5.7" />
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.5.7" />
</ItemGroup>
</Project>

View file

@ -47,7 +47,7 @@ namespace UniversalApp
private void SeamarksChecked(object sender, RoutedEventArgs e) 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) private void SeamarksUnchecked(object sender, RoutedEventArgs e)

View file

@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © 2021 Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2021 Clemens Fischer")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("5.6.0")] [assembly: AssemblyVersion("6.0.0")]
[assembly: AssemblyFileVersion("5.6.0")] [assembly: AssemblyFileVersion("6.0.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFrameworks>net5.0-windows;net48</TargetFrameworks> <TargetFrameworks>net5.0-windows;net48</TargetFrameworks>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<RootNamespace>WpfApplication</RootNamespace> <RootNamespace>WpfApplication</RootNamespace>
<Product>XAML Map Control</Product> <Product>XAML Map Control</Product>
<Version>5.6.0</Version> <Version>6.0.0</Version>
<Description>XAML Map Control WPF Sample Application</Description> <Description>XAML Map Control WPF Sample Application</Description>
<Authors>Clemens Fischer</Authors> <Authors>Clemens Fischer</Authors>
<Copyright>Copyright © 2021 Clemens Fischer</Copyright> <Copyright>Copyright © 2021 Clemens Fischer</Copyright>