mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Async naming convention
This commit is contained in:
parent
2a4de62c45
commit
8948af0723
7 changed files with 37 additions and 37 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue