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)
using System;
#if !WINDOWS_UWP
#if !WINUI && !WINDOWS_UWP
using System.Windows;
#endif

View file

@ -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

View file

@ -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;

View file

@ -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)
{

View file

@ -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;

View file

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

View file

@ -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

View file

@ -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) =>

View file

@ -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

View file

@ -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;

View file

@ -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); }
}
/// <summary>
@ -731,7 +735,7 @@ namespace MapControl
}
}
ViewScale = ViewTransform.Scale;
SetViewScale(ViewTransform.Scale);
OnViewportChanged(new ViewportChangedEventArgs(projectionChanged, Center.Longitude - centerLongitude));

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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.
/// </summary>
#if !WINDOWS_UWP
[TypeConverter(typeof(LocationCollectionConverter))]
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
#endif
public IEnumerable<Location> Locations
{

View file

@ -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.
/// </summary>
#if !WINDOWS_UWP
[TypeConverter(typeof(LocationCollectionConverter))]
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
#endif
public IEnumerable<Location> Locations
{

View file

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

View file

@ -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;

View file

@ -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;

View file

@ -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
}

View file

@ -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

View file

@ -1,67 +0,0 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Windows;
namespace MapControl
{
/// <summary>
/// An ObservableCollection of IEnumerable of Location. PolygonCollection adds a CollectionChanged
/// listener to each element that implements INotifyCollectionChanged and, when such an element changes,
/// fires its own CollectionChanged event with NotifyCollectionChangedAction.Replace for that element.
/// </summary>
public class PolygonCollection : ObservableCollection<IEnumerable<Location>>, IWeakEventListener
{
public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
{
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, sender, sender));
return true;
}
protected override void InsertItem(int index, IEnumerable<Location> polygon)
{
if (polygon is INotifyCollectionChanged observablePolygon)
{
CollectionChangedEventManager.AddListener(observablePolygon, this);
}
base.InsertItem(index, polygon);
}
protected override void SetItem(int index, IEnumerable<Location> polygon)
{
if (this[index] is INotifyCollectionChanged observablePolygon)
{
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
}
base.SetItem(index, polygon);
}
protected override void RemoveItem(int index)
{
if (this[index] is INotifyCollectionChanged observablePolygon)
{
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
}
base.RemoveItem(index);
}
protected override void ClearItems()
{
foreach (var observablePolygon in this.OfType<INotifyCollectionChanged>())
{
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
}
base.ClearItems();
}
}
}

View file

@ -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

View file

@ -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;

View file

@ -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.
/// </summary>
#if !WINDOWS_UWP
[TypeConverter(typeof(TileSourceConverter))]
[System.ComponentModel.TypeConverter(typeof(TileSourceConverter))]
#endif
public class TileSource
{

View file

@ -0,0 +1,62 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2021 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using System.ComponentModel;
using System.Globalization;
namespace MapControl
{
public class LocationConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return Location.Parse((string)value);
}
}
public class LocationCollectionConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return LocationCollection.Parse((string)value);
}
}
public class BoundingBoxConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return BoundingBox.Parse((string)value);
}
}
public class TileSourceConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return new TileSource { UriFormat = value as string };
}
}
}

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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