mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Async naming convention
This commit is contained in:
parent
2a4de62c45
commit
8948af0723
|
|
@ -48,7 +48,7 @@ namespace MapControl
|
|||
|
||||
public static readonly StyledProperty<Location> TargetCenterProperty =
|
||||
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),
|
||||
true);
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ namespace MapControl
|
|||
|
||||
public static readonly StyledProperty<double> TargetZoomLevelProperty =
|
||||
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),
|
||||
true);
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ namespace MapControl
|
|||
|
||||
public static readonly StyledProperty<double> TargetHeadingProperty =
|
||||
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),
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<Matrix> ReadWorldFileMatrix(string worldFilePath)
|
||||
private static async Task<Matrix> ReadWorldFileMatrixAsync(string worldFilePath)
|
||||
{
|
||||
using (var fileStream = File.OpenRead(worldFilePath))
|
||||
using (var streamReader = new StreamReader(fileStream))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace MapControl
|
|||
{
|
||||
public static readonly DependencyProperty SourcePathsProperty =
|
||||
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
|
||||
{
|
||||
|
|
@ -34,7 +34,7 @@ namespace MapControl
|
|||
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();
|
||||
|
||||
|
|
@ -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<string>());
|
||||
await AddOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast<string>());
|
||||
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<string>());
|
||||
await AddOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast<string>());
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
await ReplaceOverlays(args.NewStartingIndex, args.NewItems.Cast<string>());
|
||||
await ReplaceOverlaysAsync(args.NewStartingIndex, args.NewItems.Cast<string>());
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
Children.Clear();
|
||||
await AddOverlays(0, SourcePaths);
|
||||
await AddOverlaysAsync(0, SourcePaths);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AddOverlays(int index, IEnumerable<string> sourcePaths)
|
||||
private async Task AddOverlaysAsync(int index, IEnumerable<string> 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)
|
||||
{
|
||||
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;
|
||||
var ext = Path.GetExtension(sourcePath).ToLower();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace MapControl
|
|||
{
|
||||
public static readonly DependencyProperty TileSourceProperty =
|
||||
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 =
|
||||
DependencyPropertyHelper.Register<MapTileLayerBase, string>(nameof(SourceName));
|
||||
|
|
@ -70,7 +70,7 @@ namespace MapControl
|
|||
loadingProgress = new Progress<double>(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<Tile> tiles, string cacheName)
|
||||
protected Task LoadTilesAsync(IEnumerable<Tile> 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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<int> CleanFolder(StorageFolder folder)
|
||||
private static async Task<int> 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<int> CleanFile(StorageFile file)
|
||||
private static async Task<int> CleanFileAsync(StorageFile file)
|
||||
{
|
||||
var deletedFileCount = 0;
|
||||
var size = (await file.GetBasicPropertiesAsync()).Size;
|
||||
|
|
|
|||
Loading…
Reference in a new issue