PageRenderTime 40ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Media.Imaging;
  6. using System.Windows.Media;
  7. using System.IO;
  8. namespace Microsoft.Research.DynamicDataDisplay.Charts.Maps
  9. {
  10. public sealed class MemoryTileServer : TileServerBase, ITileSystem {
  11. public MemoryTileServer(string name)
  12. {
  13. ServerName = name;
  14. }
  15. private readonly Dictionary<TileIndex, BitmapSource> cache = new Dictionary<TileIndex, BitmapSource>(new TileIndex.TileIndexEqualityComparer());
  16. public override bool Contains(TileIndex id)
  17. {
  18. return cache.ContainsKey(id);
  19. }
  20. public override void BeginLoadImage(TileIndex id)
  21. {
  22. if (Contains(id))
  23. ReportSuccess(cache[id], id);
  24. else
  25. ReportFailure(id);
  26. }
  27. public BitmapSource this[TileIndex id]
  28. {
  29. get
  30. {
  31. return cache[id];
  32. }
  33. }
  34. #region ITileStore Members
  35. public void BeginSaveImage(TileIndex id, BitmapSource image, Stream stream)
  36. {
  37. cache[id] = image;
  38. }
  39. #endregion
  40. #region ITileStore Members
  41. public void Clear()
  42. {
  43. throw new NotImplementedException();
  44. }
  45. #endregion
  46. }
  47. }