From 8948af07232f599cab55e9dec7b70ffda8d51a3d Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Sun, 26 Jan 2025 20:23:42 +0100 Subject: [PATCH] Async naming convention --- MapControl/Avalonia/MapBase.Avalonia.cs | 12 ++++++------ MapControl/Shared/GeoImage.cs | 4 ++-- MapControl/Shared/MapOverlaysPanel.cs | 24 ++++++++++++------------ MapControl/Shared/MapTileLayer.cs | 4 ++-- MapControl/Shared/MapTileLayerBase.cs | 14 +++++++------- MapControl/Shared/WmtsTileLayer.cs | 6 +++--- MapControl/UWP/ImageFileCache.UWP.cs | 10 +++++----- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/MapControl/Avalonia/MapBase.Avalonia.cs b/MapControl/Avalonia/MapBase.Avalonia.cs index c40af495..bb803f68 100644 --- a/MapControl/Avalonia/MapBase.Avalonia.cs +++ b/MapControl/Avalonia/MapBase.Avalonia.cs @@ -48,7 +48,7 @@ namespace MapControl public static readonly StyledProperty TargetCenterProperty = DependencyPropertyHelper.Register(nameof(TargetCenter), new Location(), - async (map, oldValue, newValue) => await map.TargetCenterPropertyChanged(newValue), + async (map, oldValue, newValue) => await map.TargetCenterPropertyChangedAsync(newValue), (map, value) => map.CoerceCenterProperty(value), true); @@ -70,7 +70,7 @@ namespace MapControl public static readonly StyledProperty TargetZoomLevelProperty = DependencyPropertyHelper.Register(nameof(TargetZoomLevel), 1d, - async (map, oldValue, newValue) => await map.TargetZoomLevelPropertyChanged(newValue), + async (map, oldValue, newValue) => await map.TargetZoomLevelPropertyChangedAsync(newValue), (map, value) => map.CoerceZoomLevelProperty(value), true); @@ -82,7 +82,7 @@ namespace MapControl public static readonly StyledProperty TargetHeadingProperty = DependencyPropertyHelper.Register(nameof(TargetHeading), 0d, - async (map, oldValue, newValue) => await map.TargetHeadingPropertyChanged(newValue), + async (map, oldValue, newValue) => await map.TargetHeadingPropertyChangedAsync(newValue), (map, value) => map.CoerceHeadingProperty(value), true); @@ -153,7 +153,7 @@ namespace MapControl } } - private async Task TargetCenterPropertyChanged(Location targetCenter) + private async Task TargetCenterPropertyChangedAsync(Location targetCenter) { if (!internalPropertyChange && !targetCenter.Equals(Center)) { @@ -206,7 +206,7 @@ namespace MapControl } } - private async Task TargetZoomLevelPropertyChanged(double targetZoomLevel) + private async Task TargetZoomLevelPropertyChangedAsync(double targetZoomLevel) { if (!internalPropertyChange && targetZoomLevel != ZoomLevel) { @@ -241,7 +241,7 @@ namespace MapControl } } - private async Task TargetHeadingPropertyChanged(double targetHeading) + private async Task TargetHeadingPropertyChangedAsync(double targetHeading) { if (!internalPropertyChange && targetHeading != Heading) { diff --git a/MapControl/Shared/GeoImage.cs b/MapControl/Shared/GeoImage.cs index b4c2e08d..fc17cf04 100644 --- a/MapControl/Shared/GeoImage.cs +++ b/MapControl/Shared/GeoImage.cs @@ -136,7 +136,7 @@ namespace MapControl { return new GeoBitmap( (BitmapSource)await ImageLoader.LoadImageAsync(sourcePath), - await ReadWorldFileMatrix(worldFilePath), + await ReadWorldFileMatrixAsync(worldFilePath), null); } } @@ -144,7 +144,7 @@ namespace MapControl return await LoadGeoTiffAsync(sourcePath); } - private static async Task ReadWorldFileMatrix(string worldFilePath) + private static async Task ReadWorldFileMatrixAsync(string worldFilePath) { using (var fileStream = File.OpenRead(worldFilePath)) using (var streamReader = new StreamReader(fileStream)) diff --git a/MapControl/Shared/MapOverlaysPanel.cs b/MapControl/Shared/MapOverlaysPanel.cs index a51adaab..034ad844 100644 --- a/MapControl/Shared/MapOverlaysPanel.cs +++ b/MapControl/Shared/MapOverlaysPanel.cs @@ -26,7 +26,7 @@ namespace MapControl { public static readonly DependencyProperty SourcePathsProperty = DependencyPropertyHelper.Register>(nameof(SourcePaths), null, - async (control, oldValue, newValue) => await control.SourcePathsPropertyChanged(oldValue, newValue)); + async (control, oldValue, newValue) => await control.SourcePathsPropertyChangedAsync(oldValue, newValue)); public IEnumerable SourcePaths { @@ -34,7 +34,7 @@ namespace MapControl set => SetValue(SourcePathsProperty, value); } - private async Task SourcePathsPropertyChanged(IEnumerable oldSourcePaths, IEnumerable newSourcePaths) + private async Task SourcePathsPropertyChangedAsync(IEnumerable oldSourcePaths, IEnumerable newSourcePaths) { Children.Clear(); @@ -50,7 +50,7 @@ namespace MapControl newCollection.CollectionChanged += SourcePathsCollectionChanged; } - await AddOverlays(0, newSourcePaths); + await AddOverlaysAsync(0, newSourcePaths); } } @@ -59,7 +59,7 @@ namespace MapControl switch (args.Action) { case NotifyCollectionChangedAction.Add: - await AddOverlays(args.NewStartingIndex, args.NewItems.Cast()); + await AddOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast()); break; case NotifyCollectionChangedAction.Remove: @@ -68,33 +68,33 @@ namespace MapControl case NotifyCollectionChangedAction.Move: RemoveOverlays(args.OldStartingIndex, args.OldItems.Count); - await AddOverlays(args.NewStartingIndex, args.NewItems.Cast()); + await AddOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast()); break; case NotifyCollectionChangedAction.Replace: - await ReplaceOverlays(args.NewStartingIndex, args.NewItems.Cast()); + await ReplaceOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast()); break; case NotifyCollectionChangedAction.Reset: Children.Clear(); - await AddOverlays(0, SourcePaths); + await AddOverlaysAsync(0, SourcePaths); break; } } - private async Task AddOverlays(int index, IEnumerable sourcePaths) + private async Task AddOverlaysAsync(int index, IEnumerable sourcePaths) { foreach (var sourcePath in sourcePaths) { - Children.Insert(index++, await CreateOverlay(sourcePath)); + Children.Insert(index++, await CreateOverlayAsync(sourcePath)); } } - private async Task ReplaceOverlays(int index, IEnumerable sourcePaths) + private async Task ReplaceOverlaysAsync(int index, IEnumerable sourcePaths) { foreach (var sourcePath in sourcePaths) { - Children[index++] = await CreateOverlay(sourcePath); + Children[index++] = await CreateOverlayAsync(sourcePath); } } @@ -106,7 +106,7 @@ namespace MapControl } } - protected virtual async Task CreateOverlay(string sourcePath) + protected virtual async Task CreateOverlayAsync(string sourcePath) { FrameworkElement overlay; var ext = Path.GetExtension(sourcePath).ToLower(); diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index 985535c8..ee363e20 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -113,7 +113,7 @@ namespace MapControl return finalSize; } - protected override async Task UpdateTileLayer(bool tileSourceChanged) + protected override async Task UpdateTileLayerAsync(bool tileSourceChanged) { var updateTiles = false; @@ -142,7 +142,7 @@ namespace MapControl { UpdateTiles(); - await LoadTiles(Tiles, SourceName); + await LoadTilesAsync(Tiles, SourceName); } } diff --git a/MapControl/Shared/MapTileLayerBase.cs b/MapControl/Shared/MapTileLayerBase.cs index 1714f96c..819e189b 100644 --- a/MapControl/Shared/MapTileLayerBase.cs +++ b/MapControl/Shared/MapTileLayerBase.cs @@ -31,7 +31,7 @@ namespace MapControl { public static readonly DependencyProperty TileSourceProperty = DependencyPropertyHelper.Register(nameof(TileSource), null, - async (layer, oldValue, newValue) => await layer.Update(true)); + async (layer, oldValue, newValue) => await layer.UpdateAsync(true)); public static readonly DependencyProperty SourceNameProperty = DependencyPropertyHelper.Register(nameof(SourceName)); @@ -70,7 +70,7 @@ namespace MapControl loadingProgress = new Progress(p => SetValue(LoadingProgressProperty, p)); updateTimer = this.CreateTimer(UpdateInterval); - updateTimer.Tick += async (s, e) => await Update(false); + updateTimer.Tick += async (s, e) => await UpdateAsync(false); MapPanel.SetRenderTransform(this, new MatrixTransform()); #if WPF @@ -194,25 +194,25 @@ namespace MapControl protected abstract void SetRenderTransform(); - protected abstract Task UpdateTileLayer(bool tileSourceChanged); + protected abstract Task UpdateTileLayerAsync(bool tileSourceChanged); - protected Task LoadTiles(IEnumerable tiles, string cacheName) + protected Task LoadTilesAsync(IEnumerable tiles, string cacheName) { return TileImageLoader.LoadTilesAsync(tiles, TileSource, cacheName, loadingProgress); } - private Task Update(bool tileSourceChanged) + private Task UpdateAsync(bool tileSourceChanged) { updateTimer.Stop(); - return UpdateTileLayer(tileSourceChanged); + return UpdateTileLayerAsync(tileSourceChanged); } private async void OnViewportChanged(object sender, ViewportChangedEventArgs e) { if (e.TransformCenterChanged || e.ProjectionChanged || Children.Count == 0) { - await Update(false); // update immediately + await UpdateAsync(false); // update immediately } else { diff --git a/MapControl/Shared/WmtsTileLayer.cs b/MapControl/Shared/WmtsTileLayer.cs index b44ecb61..bc0a5f46 100644 --- a/MapControl/Shared/WmtsTileLayer.cs +++ b/MapControl/Shared/WmtsTileLayer.cs @@ -93,7 +93,7 @@ namespace MapControl return finalSize; } - protected override async Task UpdateTileLayer(bool tileSourceChanged) + protected override async Task UpdateTileLayerAsync(bool tileSourceChanged) { // tileSourceChanged is ignored here because it is always false. @@ -102,7 +102,7 @@ namespace MapControl { Children.Clear(); - await LoadTiles(null, null); // stop TileImageLoader + await LoadTilesAsync(null, null); // stop TileImageLoader } else if (UpdateChildLayers(tileMatrixSet)) { @@ -122,7 +122,7 @@ namespace MapControl var tiles = ChildLayers.SelectMany(layer => layer.Tiles); - await LoadTiles(tiles, cacheName); + await LoadTilesAsync(tiles, cacheName); } } diff --git a/MapControl/UWP/ImageFileCache.UWP.cs b/MapControl/UWP/ImageFileCache.UWP.cs index e378c663..7c9bfe75 100644 --- a/MapControl/UWP/ImageFileCache.UWP.cs +++ b/MapControl/UWP/ImageFileCache.UWP.cs @@ -133,7 +133,7 @@ namespace MapControl.Caching public async Task CleanAsync() { - var deletedFileCount = await CleanFolder(rootFolder); + var deletedFileCount = await CleanFolderAsync(rootFolder); if (deletedFileCount > 0) { @@ -141,7 +141,7 @@ namespace MapControl.Caching } } - private static async Task CleanFolder(StorageFolder folder) + private static async Task CleanFolderAsync(StorageFolder folder) { var deletedFileCount = 0; @@ -149,12 +149,12 @@ namespace MapControl.Caching { foreach (var f in await folder.GetFoldersAsync()) { - deletedFileCount += await CleanFolder(f); + deletedFileCount += await CleanFolderAsync(f); } foreach (var f in await folder.GetFilesAsync()) { - deletedFileCount += await CleanFile(f); + deletedFileCount += await CleanFileAsync(f); } if ((await folder.GetItemsAsync()).Count == 0) @@ -170,7 +170,7 @@ namespace MapControl.Caching return deletedFileCount; } - private static async Task CleanFile(StorageFile file) + private static async Task CleanFileAsync(StorageFile file) { var deletedFileCount = 0; var size = (await file.GetBasicPropertiesAsync()).Size;