Fixed panning for UWP/WinUI

This commit is contained in:
Clemens 2022-01-12 23:56:05 +01:00
parent 2ac4985c47
commit e2f4fc13b1
6 changed files with 128 additions and 30 deletions

View file

@ -73,16 +73,13 @@ namespace MapControl
#if WINUI
private readonly DispatcherQueueTimer updateTimer;
#else
private readonly DispatcherTimer updateTimer = new DispatcherTimer();
private readonly DispatcherTimer updateTimer;
#endif
private bool updateInProgress;
public MapImageLayer()
{
#if WINUI
updateTimer = DispatcherQueue.CreateTimer();
#endif
updateTimer.Interval = UpdateInterval;
updateTimer = this.CreateTimer(UpdateInterval);
updateTimer.Tick += async (s, e) => await UpdateImageAsync();
}
@ -227,12 +224,7 @@ namespace MapControl
base.OnViewportChanged(e);
if (!UpdateWhileViewportChanging)
{
updateTimer.Stop(); // restart
}
updateTimer.Start();
updateTimer.Run(!UpdateWhileViewportChanging);
}
}
@ -242,7 +234,7 @@ namespace MapControl
if (updateInProgress)
{
updateTimer.Start(); // update image on next timer tick
updateTimer.Run(); // update image on next timer tick
}
else if (ParentMap != null && ParentMap.RenderSize.Width > 0 && ParentMap.RenderSize.Height > 0)
{

View file

@ -61,7 +61,7 @@ namespace MapControl
#if WINUI
private readonly DispatcherQueueTimer updateTimer;
#else
private readonly DispatcherTimer updateTimer = new DispatcherTimer();
private readonly DispatcherTimer updateTimer;
#endif
private MapBase parentMap;
@ -69,10 +69,8 @@ namespace MapControl
{
RenderTransform = new MatrixTransform();
TileImageLoader = tileImageLoader;
#if WINUI
updateTimer = DispatcherQueue.CreateTimer();
#endif
updateTimer.Interval = UpdateInterval;
updateTimer = this.CreateTimer(UpdateInterval);
updateTimer.Tick += async (s, e) => await Update();
#if WINUI || UWP
@ -172,7 +170,7 @@ namespace MapControl
parentMap.ViewportChanged += OnViewportChanged;
}
updateTimer.Start();
updateTimer.Run();
}
}
@ -207,12 +205,7 @@ namespace MapControl
{
SetRenderTransform();
if (!UpdateWhileViewportChanging)
{
updateTimer.Stop(); // restart
}
updateTimer.Start();
updateTimer.Run(!UpdateWhileViewportChanging);
}
}
}