Async naming convention

This commit is contained in:
ClemensFischer 2025-01-26 20:23:42 +01:00
parent 2a4de62c45
commit 8948af0723
7 changed files with 37 additions and 37 deletions

View file

@ -48,7 +48,7 @@ namespace MapControl
public static readonly StyledProperty<Location> TargetCenterProperty = public static readonly StyledProperty<Location> TargetCenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(), DependencyPropertyHelper.Register<MapBase, Location>(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), (map, value) => map.CoerceCenterProperty(value),
true); true);
@ -70,7 +70,7 @@ namespace MapControl
public static readonly StyledProperty<double> TargetZoomLevelProperty = public static readonly StyledProperty<double> TargetZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d,
async (map, oldValue, newValue) => await map.TargetZoomLevelPropertyChanged(newValue), async (map, oldValue, newValue) => await map.TargetZoomLevelPropertyChangedAsync(newValue),
(map, value) => map.CoerceZoomLevelProperty(value), (map, value) => map.CoerceZoomLevelProperty(value),
true); true);
@ -82,7 +82,7 @@ namespace MapControl
public static readonly StyledProperty<double> TargetHeadingProperty = public static readonly StyledProperty<double> TargetHeadingProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d,
async (map, oldValue, newValue) => await map.TargetHeadingPropertyChanged(newValue), async (map, oldValue, newValue) => await map.TargetHeadingPropertyChangedAsync(newValue),
(map, value) => map.CoerceHeadingProperty(value), (map, value) => map.CoerceHeadingProperty(value),
true); true);
@ -153,7 +153,7 @@ namespace MapControl
} }
} }
private async Task TargetCenterPropertyChanged(Location targetCenter) private async Task TargetCenterPropertyChangedAsync(Location targetCenter)
{ {
if (!internalPropertyChange && !targetCenter.Equals(Center)) 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) 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) if (!internalPropertyChange && targetHeading != Heading)
{ {

View file

@ -136,7 +136,7 @@ namespace MapControl
{ {
return new GeoBitmap( return new GeoBitmap(
(BitmapSource)await ImageLoader.LoadImageAsync(sourcePath), (BitmapSource)await ImageLoader.LoadImageAsync(sourcePath),
await ReadWorldFileMatrix(worldFilePath), await ReadWorldFileMatrixAsync(worldFilePath),
null); null);
} }
} }
@ -144,7 +144,7 @@ namespace MapControl
return await LoadGeoTiffAsync(sourcePath); return await LoadGeoTiffAsync(sourcePath);
} }
private static async Task<Matrix> ReadWorldFileMatrix(string worldFilePath) private static async Task<Matrix> ReadWorldFileMatrixAsync(string worldFilePath)
{ {
using (var fileStream = File.OpenRead(worldFilePath)) using (var fileStream = File.OpenRead(worldFilePath))
using (var streamReader = new StreamReader(fileStream)) using (var streamReader = new StreamReader(fileStream))

View file

@ -26,7 +26,7 @@ namespace MapControl
{ {
public static readonly DependencyProperty SourcePathsProperty = public static readonly DependencyProperty SourcePathsProperty =
DependencyPropertyHelper.Register<MapOverlaysPanel, IEnumerable<string>>(nameof(SourcePaths), null, DependencyPropertyHelper.Register<MapOverlaysPanel, IEnumerable<string>>(nameof(SourcePaths), null,
async (control, oldValue, newValue) => await control.SourcePathsPropertyChanged(oldValue, newValue)); async (control, oldValue, newValue) => await control.SourcePathsPropertyChangedAsync(oldValue, newValue));
public IEnumerable<string> SourcePaths public IEnumerable<string> SourcePaths
{ {
@ -34,7 +34,7 @@ namespace MapControl
set => SetValue(SourcePathsProperty, value); set => SetValue(SourcePathsProperty, value);
} }
private async Task SourcePathsPropertyChanged(IEnumerable<string> oldSourcePaths, IEnumerable<string> newSourcePaths) private async Task SourcePathsPropertyChangedAsync(IEnumerable<string> oldSourcePaths, IEnumerable<string> newSourcePaths)
{ {
Children.Clear(); Children.Clear();
@ -50,7 +50,7 @@ namespace MapControl
newCollection.CollectionChanged += SourcePathsCollectionChanged; newCollection.CollectionChanged += SourcePathsCollectionChanged;
} }
await AddOverlays(0, newSourcePaths); await AddOverlaysAsync(0, newSourcePaths);
} }
} }
@ -59,7 +59,7 @@ namespace MapControl
switch (args.Action) switch (args.Action)
{ {
case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Add:
await AddOverlays(args.NewStartingIndex, args.NewItems.Cast<string>()); await AddOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast<string>());
break; break;
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
@ -68,33 +68,33 @@ namespace MapControl
case NotifyCollectionChangedAction.Move: case NotifyCollectionChangedAction.Move:
RemoveOverlays(args.OldStartingIndex, args.OldItems.Count); RemoveOverlays(args.OldStartingIndex, args.OldItems.Count);
await AddOverlays(args.NewStartingIndex, args.NewItems.Cast<string>()); await AddOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast<string>());
break; break;
case NotifyCollectionChangedAction.Replace: case NotifyCollectionChangedAction.Replace:
await ReplaceOverlays(args.NewStartingIndex, args.NewItems.Cast<string>()); await ReplaceOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast<string>());
break; break;
case NotifyCollectionChangedAction.Reset: case NotifyCollectionChangedAction.Reset:
Children.Clear(); Children.Clear();
await AddOverlays(0, SourcePaths); await AddOverlaysAsync(0, SourcePaths);
break; break;
} }
} }
private async Task AddOverlays(int index, IEnumerable<string> sourcePaths) private async Task AddOverlaysAsync(int index, IEnumerable<string> sourcePaths)
{ {
foreach (var sourcePath in 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<string> sourcePaths) private async Task ReplaceOverlaysAsync(int index, IEnumerable<string> sourcePaths)
{ {
foreach (var sourcePath in 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<FrameworkElement> CreateOverlay(string sourcePath) protected virtual async Task<FrameworkElement> CreateOverlayAsync(string sourcePath)
{ {
FrameworkElement overlay; FrameworkElement overlay;
var ext = Path.GetExtension(sourcePath).ToLower(); var ext = Path.GetExtension(sourcePath).ToLower();

View file

@ -113,7 +113,7 @@ namespace MapControl
return finalSize; return finalSize;
} }
protected override async Task UpdateTileLayer(bool tileSourceChanged) protected override async Task UpdateTileLayerAsync(bool tileSourceChanged)
{ {
var updateTiles = false; var updateTiles = false;
@ -142,7 +142,7 @@ namespace MapControl
{ {
UpdateTiles(); UpdateTiles();
await LoadTiles(Tiles, SourceName); await LoadTilesAsync(Tiles, SourceName);
} }
} }

View file

@ -31,7 +31,7 @@ namespace MapControl
{ {
public static readonly DependencyProperty TileSourceProperty = public static readonly DependencyProperty TileSourceProperty =
DependencyPropertyHelper.Register<MapTileLayerBase, TileSource>(nameof(TileSource), null, DependencyPropertyHelper.Register<MapTileLayerBase, TileSource>(nameof(TileSource), null,
async (layer, oldValue, newValue) => await layer.Update(true)); async (layer, oldValue, newValue) => await layer.UpdateAsync(true));
public static readonly DependencyProperty SourceNameProperty = public static readonly DependencyProperty SourceNameProperty =
DependencyPropertyHelper.Register<MapTileLayerBase, string>(nameof(SourceName)); DependencyPropertyHelper.Register<MapTileLayerBase, string>(nameof(SourceName));
@ -70,7 +70,7 @@ namespace MapControl
loadingProgress = new Progress<double>(p => SetValue(LoadingProgressProperty, p)); loadingProgress = new Progress<double>(p => SetValue(LoadingProgressProperty, p));
updateTimer = this.CreateTimer(UpdateInterval); 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()); MapPanel.SetRenderTransform(this, new MatrixTransform());
#if WPF #if WPF
@ -194,25 +194,25 @@ namespace MapControl
protected abstract void SetRenderTransform(); protected abstract void SetRenderTransform();
protected abstract Task UpdateTileLayer(bool tileSourceChanged); protected abstract Task UpdateTileLayerAsync(bool tileSourceChanged);
protected Task LoadTiles(IEnumerable<Tile> tiles, string cacheName) protected Task LoadTilesAsync(IEnumerable<Tile> tiles, string cacheName)
{ {
return TileImageLoader.LoadTilesAsync(tiles, TileSource, cacheName, loadingProgress); return TileImageLoader.LoadTilesAsync(tiles, TileSource, cacheName, loadingProgress);
} }
private Task Update(bool tileSourceChanged) private Task UpdateAsync(bool tileSourceChanged)
{ {
updateTimer.Stop(); updateTimer.Stop();
return UpdateTileLayer(tileSourceChanged); return UpdateTileLayerAsync(tileSourceChanged);
} }
private async void OnViewportChanged(object sender, ViewportChangedEventArgs e) private async void OnViewportChanged(object sender, ViewportChangedEventArgs e)
{ {
if (e.TransformCenterChanged || e.ProjectionChanged || Children.Count == 0) if (e.TransformCenterChanged || e.ProjectionChanged || Children.Count == 0)
{ {
await Update(false); // update immediately await UpdateAsync(false); // update immediately
} }
else else
{ {

View file

@ -93,7 +93,7 @@ namespace MapControl
return finalSize; 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. // tileSourceChanged is ignored here because it is always false.
@ -102,7 +102,7 @@ namespace MapControl
{ {
Children.Clear(); Children.Clear();
await LoadTiles(null, null); // stop TileImageLoader await LoadTilesAsync(null, null); // stop TileImageLoader
} }
else if (UpdateChildLayers(tileMatrixSet)) else if (UpdateChildLayers(tileMatrixSet))
{ {
@ -122,7 +122,7 @@ namespace MapControl
var tiles = ChildLayers.SelectMany(layer => layer.Tiles); var tiles = ChildLayers.SelectMany(layer => layer.Tiles);
await LoadTiles(tiles, cacheName); await LoadTilesAsync(tiles, cacheName);
} }
} }

View file

@ -133,7 +133,7 @@ namespace MapControl.Caching
public async Task CleanAsync() public async Task CleanAsync()
{ {
var deletedFileCount = await CleanFolder(rootFolder); var deletedFileCount = await CleanFolderAsync(rootFolder);
if (deletedFileCount > 0) if (deletedFileCount > 0)
{ {
@ -141,7 +141,7 @@ namespace MapControl.Caching
} }
} }
private static async Task<int> CleanFolder(StorageFolder folder) private static async Task<int> CleanFolderAsync(StorageFolder folder)
{ {
var deletedFileCount = 0; var deletedFileCount = 0;
@ -149,12 +149,12 @@ namespace MapControl.Caching
{ {
foreach (var f in await folder.GetFoldersAsync()) foreach (var f in await folder.GetFoldersAsync())
{ {
deletedFileCount += await CleanFolder(f); deletedFileCount += await CleanFolderAsync(f);
} }
foreach (var f in await folder.GetFilesAsync()) foreach (var f in await folder.GetFilesAsync())
{ {
deletedFileCount += await CleanFile(f); deletedFileCount += await CleanFileAsync(f);
} }
if ((await folder.GetItemsAsync()).Count == 0) if ((await folder.GetItemsAsync()).Count == 0)
@ -170,7 +170,7 @@ namespace MapControl.Caching
return deletedFileCount; return deletedFileCount;
} }
private static async Task<int> CleanFile(StorageFile file) private static async Task<int> CleanFileAsync(StorageFile file)
{ {
var deletedFileCount = 0; var deletedFileCount = 0;
var size = (await file.GetBasicPropertiesAsync()).Size; var size = (await file.GetBasicPropertiesAsync()).Size;