From 97f5e58dcaf4f511baa7a44006d29833bcbeb76a Mon Sep 17 00:00:00 2001 From: Clemens Date: Wed, 7 Jul 2021 19:30:05 +0200 Subject: [PATCH] Update MainWindow.xaml.cs --- SampleApps/WinUiApp/MainWindow.xaml.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/SampleApps/WinUiApp/MainWindow.xaml.cs b/SampleApps/WinUiApp/MainWindow.xaml.cs index 016bfa96..d0bd3c77 100644 --- a/SampleApps/WinUiApp/MainWindow.xaml.cs +++ b/SampleApps/WinUiApp/MainWindow.xaml.cs @@ -42,16 +42,20 @@ namespace WinUiApp root.DataContext = viewModel; - if (TileImageLoader.Cache is ImageFileCache cache) + if (TileImageLoader.Cache is ImageFileCache) { - Activated += async (s, e) => - { - await Task.Delay(2000); - await cache.Clean(); - }; + Activated += WindowActivated; } } + private async void WindowActivated(object sender, WindowActivatedEventArgs e) + { + Activated -= WindowActivated; + + await Task.Delay(2000); + await ((ImageFileCache)TileImageLoader.Cache).Clean(); + } + private void SeamarksChecked(object sender, RoutedEventArgs e) { map.Children.Insert(map.Children.IndexOf(graticule), viewModel.MapLayers.SeamarksLayer); @@ -61,5 +65,10 @@ namespace WinUiApp { map.Children.Remove(viewModel.MapLayers.SeamarksLayer); } + + private void MapViewportChanged(object sender, ViewportChangedEventArgs e) + { + GC.Collect(); + } } }