diff --git a/.gitignore b/.gitignore index 4b82ccd9..d8fe68bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,15 @@ .vs/ bin/ obj/ +packages/ +Maps.* +TestApps/ +Win2D/ +ChartServerLayer.cs +TileLoader.cs +MapControl_TestApps.sln +*.user +*.cache +*.cmd +*.nupkg +*.txt diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index 1eb4fb2b..52b3fc32 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -8,11 +8,11 @@ using System.Linq; using System.Threading.Tasks; #if WINUI using Windows.Foundation; -using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media.Animation; +using DispatcherTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer; #elif UWP using Windows.Foundation; using Windows.UI.Xaml; @@ -54,11 +54,7 @@ namespace MapControl public static readonly DependencyProperty MapForegroundProperty = DependencyProperty.Register( nameof(MapForeground), typeof(Brush), typeof(MapImageLayer), new PropertyMetadata(null)); -#if WINUI - private readonly DispatcherQueueTimer updateTimer; -#else private readonly DispatcherTimer updateTimer; -#endif private bool updateInProgress; public MapImageLayer() diff --git a/MapControl/Shared/MapScale.cs b/MapControl/Shared/MapScale.cs index f709ff19..6e32caae 100644 --- a/MapControl/Shared/MapScale.cs +++ b/MapControl/Shared/MapScale.cs @@ -55,6 +55,7 @@ namespace MapControl line.SetBinding(Shape.StrokeProperty, this.GetOrCreateBinding(StrokeProperty, nameof(Stroke))); line.SetBinding(Shape.StrokeThicknessProperty, this.GetOrCreateBinding(StrokeThicknessProperty, nameof(StrokeThickness))); + #if WINUI || UWP label.SetBinding(TextBlock.ForegroundProperty, this.GetOrCreateBinding(ForegroundProperty, nameof(Foreground))); #endif diff --git a/MapControl/Shared/MapTileLayerBase.cs b/MapControl/Shared/MapTileLayerBase.cs index 6833f916..066f7bbc 100644 --- a/MapControl/Shared/MapTileLayerBase.cs +++ b/MapControl/Shared/MapTileLayerBase.cs @@ -6,10 +6,10 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; #if WINUI -using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; +using DispatcherTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer; #elif UWP using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -58,11 +58,7 @@ namespace MapControl public static readonly DependencyProperty MapForegroundProperty = DependencyProperty.Register( nameof(MapForeground), typeof(Brush), typeof(MapTileLayerBase), new PropertyMetadata(null)); -#if WINUI - private readonly DispatcherQueueTimer updateTimer; -#else private readonly DispatcherTimer updateTimer; -#endif private MapBase parentMap; protected MapTileLayerBase(ITileImageLoader tileImageLoader) diff --git a/MapControl/WinUI/MapPanel.WinUI.cs b/MapControl/WinUI/MapPanel.WinUI.cs index b5d0ebf1..d18bfba7 100644 --- a/MapControl/WinUI/MapPanel.WinUI.cs +++ b/MapControl/WinUI/MapPanel.WinUI.cs @@ -44,8 +44,8 @@ namespace MapControl // Workaround for missing property value inheritance. // Loaded and Unloaded handlers set and clear the ParentMap property value. - element.Loaded += (s, e) => GetParentMap(element); - element.Unloaded += (s, e) => element.ClearValue(ParentMapProperty); + element.Loaded += (s, e) => GetParentMap((FrameworkElement)s); + element.Unloaded += (s, e) => ((FrameworkElement)s).ClearValue(ParentMapProperty); } } @@ -53,21 +53,19 @@ namespace MapControl { var parentMap = (MapBase)element.GetValue(ParentMapProperty); - if (parentMap == null && (parentMap = FindParentMap(element)) != null) + if (parentMap == null && VisualTreeHelper.GetParent(element) is FrameworkElement parentElement) { - element.SetValue(ParentMapProperty, parentMap); + parentMap = (parentElement as MapBase) ?? GetParentMap(parentElement); + + if (parentMap != null) + { + element.SetValue(ParentMapProperty, parentMap); + } } return parentMap; } - private static MapBase FindParentMap(FrameworkElement element) - { - return VisualTreeHelper.GetParent(element) is FrameworkElement parent - ? ((parent as MapBase) ?? (MapBase)element.GetValue(ParentMapProperty) ?? FindParentMap(parent)) - : null; - } - private static void SetViewPosition(FrameworkElement element, Point? viewPosition) { element.SetValue(ViewPositionProperty, viewPosition);