Renamed TileLayer.Name property to TileLayer.SourceName, removed TileLayerCollection.Name property.

This commit is contained in:
ClemensF 2012-11-04 10:16:39 +01:00
parent e52698586b
commit 02b9cb4354
7 changed files with 25 additions and 31 deletions

View file

@ -119,7 +119,7 @@ namespace MapControl
{
BaseTileLayer = new TileLayer
{
Name = "OpenStreetMap",
SourceName = "OpenStreetMap",
Description = "© {y} OpenStreetMap Contributors, CC-BY-SA",
TileSource = new TileSource("http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png")
};

View file

@ -37,9 +37,9 @@ namespace MapControl
foreach (TileLayer tileLayer in tileLayers)
{
if (string.IsNullOrEmpty(tileLayer.Name))
if (string.IsNullOrWhiteSpace(tileLayer.SourceName))
{
throw new ArgumentException("TileLayer.Name property must not be null or empty.");
throw new ArgumentException("TileLayer.SourceName property must not be null or empty or white-space only.");
}
Children.Insert(index++, tileLayer);

View file

@ -91,7 +91,8 @@ namespace MapControl
newTiles.ForEach(tile =>
{
tileLayer.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => tile.Image = imageTileSource.GetImage(tile.XIndex, tile.Y, tile.ZoomLevel)));
tileLayer.Dispatcher.BeginInvoke(DispatcherPriority.Background,
(Action)(() => tile.Image = imageTileSource.GetImage(tile.XIndex, tile.Y, tile.ZoomLevel)));
});
}
else
@ -138,7 +139,6 @@ namespace MapControl
}
}
private void DownloadTiles(object o)
{
Tile tile;
@ -158,7 +158,7 @@ namespace MapControl
private string CacheKey(Tile tile)
{
return string.Format("{0}/{1}/{2}/{3}", tileLayer.Name, tile.ZoomLevel, tile.XIndex, tile.Y);
return string.Format("{0}/{1}/{2}/{3}", tileLayer.SourceName, tile.ZoomLevel, tile.XIndex, tile.Y);
}
private bool CreateTileImage(Tile tile, byte[] buffer)

View file

@ -32,7 +32,7 @@ namespace MapControl
MaxParallelDownloads = 8;
}
public string Name { get; set; }
public string SourceName { get; set; }
public TileSource TileSource { get; set; }
public int MinZoomLevel { get; set; }
public int MaxZoomLevel { get; set; }
@ -118,7 +118,8 @@ namespace MapControl
tiles.Sort((t1, t2) => t1.ZoomLevel - t2.ZoomLevel);
//System.Diagnostics.Trace.TraceInformation("{0} Tiles: {1}", tiles.Count, string.Join(", ", tiles.Select(t => t.ZoomLevel.ToString())));
//System.Diagnostics.Trace.TraceInformation("{0} Tiles: {1}", tiles.Count,
// string.Join(", ", System.Linq.Enumerable.Select(tiles, t => t.ZoomLevel.ToString())));
}
private void RenderTiles()

View file

@ -8,12 +8,5 @@ namespace MapControl
{
public class TileLayerCollection : ObservableCollection<TileLayer>
{
private string name;
public string Name
{
get { return !string.IsNullOrEmpty(name) ? name : (Count > 0 ? this[0].Name : string.Empty); }
set { name = value; }
}
}
}

View file

@ -38,7 +38,7 @@ namespace MapControl
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("The value of the UriFormat proprty must not be null or empty or white-space only.");
throw new ArgumentException("The value of the UriFormat property must not be null or empty or white-space only.");
}
if (value.Contains("{x}") && value.Contains("{y}") && value.Contains("{z}"))