本文整理汇总了C#中TileIndex类的典型用法代码示例。如果您正苦于以下问题:C# TileIndex类的具体用法?C# TileIndex怎么用?C# TileIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TileIndex类属于命名空间,在下文中一共展示了TileIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRequestUriCore
protected override string CreateRequestUriCore(TileIndex index)
{
int z = (int)index.Level;
int shift = MapTileProvider.GetSideTilesCount(z) / 2;
int x = index.X + shift;
int y = MapTileProvider.GetSideTilesCount(z) - 1 - index.Y - shift;
char serverIdx = (char)('a' + CurrentServer);
string uri = "";
switch (renderer)
{
case OpenStreetMapRenderer.Mapnik:
uri = "tile.openstreetmap.org";
break;
case OpenStreetMapRenderer.Osmarenderer:
uri = "tah.openstreetmap.org/Tiles/tile";
break;
case OpenStreetMapRenderer.CycleMap:
uri = "andy.sandbox.cloudmade.com/tiles/cycle";
break;
case OpenStreetMapRenderer.NoName:
uri = "tile.cloudmade.com/fd093e52f0965d46bb1c6c6281022199/3/256";
break;
default:
break;
}
return String.Format(UriFormat, z.ToString(), x.ToString(), y.ToString(), serverIdx.ToString(), uri);
}
示例2:
public BitmapImage this[TileIndex id]
{
get
{
return cache[id];
}
}
示例3:
public BitmapSource this[TileIndex id]
{
get
{
return (BitmapSource)cache[id].Target;
}
}
示例4: BeginLoadImage
public override void BeginLoadImage(TileIndex id)
{
if (Contains(id))
ReportSuccess(cache[id], id);
else
ReportFailure(id);
}
示例5: CreateRequestUriCore
protected sealed override string CreateRequestUriCore(TileIndex index)
{
string indexString = CreateTileIndexString(index);
string res = String.Format(UriFormat, CurrentServer, indexString);
return res;
}
示例6: BeginSaveImage
public void BeginSaveImage(TileIndex id, BitmapImage image)
{
string imagePath = GetImagePath(id);
bool errorWhileDeleting = false;
bool containsOld = Contains(id);
if (containsOld && saveOption == SaveOption.ForceUpdate)
try
{
File.Delete(imagePath);
}
catch (IOException exc)
{
// todo возможно, тут добавить файл в очередь на удаление или перезапись новым содержимым
// когда он перестанет быть блокированным
Debug.WriteLine(String.Format("{0} - error while deleting tile {1}: {2}", Name, id, exc.Message));
errorWhileDeleting = true;
}
bool shouldSave = saveOption == SaveOption.ForceUpdate && !errorWhileDeleting ||
saveOption == SaveOption.PreserveOld && !containsOld;
if (shouldSave)
{
Debug.WriteLine("Began to save id = " + id);
Statistics.IntValues["ImagesSaved"]++;
ImageSaver saver = ScreenshotHelper.SaveBitmapToFile;
saver.BeginInvoke((BitmapImage)image.GetAsFrozen(), imagePath, null, null);
}
}
示例7: BeginLoadImage
public override void BeginLoadImage(TileIndex id)
{
if (CanLoadFast(id))
resourceServer.BeginLoadImage(id);
else
base.BeginLoadImage(id);
}
示例8: BeginLoadBitmapImpl
protected void BeginLoadBitmapImpl(Stream stream, TileIndex id)
{
Dispatcher.BeginInvoke((Action)(() =>
{
BitmapImage bmp = new BitmapImage();
SubscribeBitmapEvents(bmp);
pendingBitmaps.Add(bmp, id);
MemoryStream memStream = new MemoryStream();
stream.CopyTo(memStream);
memStream.Seek(0, SeekOrigin.Begin);
stream.Dispose();
bmp.BeginInit();
bmp.StreamSource = memStream;
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.EndInit();
if (!bmp.IsDownloading)
{
UnsubscribeBitmapEvents(bmp);
ReportSuccess(memStream, bmp, id);
pendingBitmaps.Remove(bmp);
bmp.Freeze();
}
}));
}
示例9: CreateRequestUriCore
protected override string CreateRequestUriCore(TileIndex index)
{
int level = (int)index.Level;
int x = index.X;
int y = index.Y;
return String.Format(UriFormat, level.ToString(), x.ToString(), y.ToString());
}
示例10: BeginSaveImage
public void BeginSaveImage(TileIndex id, BitmapSource image, Stream stream)
{
if (image == null)
throw new ArgumentNullException("image");
cache[id] = new WeakReference(image);
Statistics.IntValues["ImagesSaved"]++;
}
示例11: CreateRequestUriCore
protected override string CreateRequestUriCore(TileIndex index)
{
int level = (int)index.Level;
var y = MapTileProvider.GetSideTilesCount(level) / 2 + index.Y;
var x = MapTileProvider.GetSideTilesCount(level) / 2 + index.X;
string uri = String.Format(UriFormat, CurrentServer, level, x, y);
return uri;
}
示例12: CreateRequestUri
protected override string CreateRequestUri(TileIndex index)
{
int z = index.Level;
int x = index.X;
int y = MapTileProvider.GetSideTilesNum(z) - 1 - index.Y;
return String.Format(UriFormat, z, x, y);
}
示例13: Contains
public override bool Contains(TileIndex id)
{
if (!metadataRequestSent)
{
SendMetadataRequest();
}
return loaded && base.Contains(id);
}
示例14: CreateResourceName
private string CreateResourceName(TileIndex id)
{
StringBuilder builder = new StringBuilder(currentPrefix);
builder = builder.Append(id.Level).Append(".").Append(id.X).Append("x")
.Append(id.Y).Append(fileExtension);
return builder.ToString();
}
示例15: GetTilePath
public override string GetTilePath(TileIndex id)
{
StringBuilder builder = new StringBuilder("z");
builder = builder.Append(id.Level).Append(Path.DirectorySeparatorChar).Append(id.X).Append('x').Append(id.Y);
return builder.ToString();
}