/Main/src/DynamicDataDisplay.Maps/Servers/MemoryServers/MemoryTileServer.cs
C# | 59 lines | 47 code | 12 blank | 0 comment | 1 complexity | fbd8eae46b46edb5a76f3b366c935d26 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Media.Imaging;
- using System.Windows.Media;
- using System.IO;
-
- namespace Microsoft.Research.DynamicDataDisplay.Charts.Maps
- {
- public sealed class MemoryTileServer : TileServerBase, ITileSystem {
- public MemoryTileServer(string name)
- {
- ServerName = name;
- }
-
- private readonly Dictionary<TileIndex, BitmapSource> cache = new Dictionary<TileIndex, BitmapSource>(new TileIndex.TileIndexEqualityComparer());
-
- public override bool Contains(TileIndex id)
- {
- return cache.ContainsKey(id);
- }
-
- public override void BeginLoadImage(TileIndex id)
- {
- if (Contains(id))
- ReportSuccess(cache[id], id);
- else
- ReportFailure(id);
- }
-
- public BitmapSource this[TileIndex id]
- {
- get
- {
- return cache[id];
- }
- }
-
- #region ITileStore Members
-
- public void BeginSaveImage(TileIndex id, BitmapSource image, Stream stream)
- {
- cache[id] = image;
- }
-
- #endregion
-
- #region ITileStore Members
-
-
- public void Clear()
- {
- throw new NotImplementedException();
- }
-
- #endregion
- }
- }