Пример #1
0
      public TileVisual(IEnumerable<ImageSource> src, RawTile tile)
      {
         Opacity = 0;
         Tile = tile;

         Source = new ObservableCollection<ImageSource>(src);
         Source.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Source_CollectionChanged);

         this.Loaded += new RoutedEventHandler(ImageVisual_Loaded);
         this.Unloaded += new RoutedEventHandler(ImageVisual_Unloaded);
      }
Пример #2
0
      // ...

      internal byte[] GetTileFromMemoryCache(RawTile tile)
      {
         kiberCacheLock.AcquireReaderLock();
         try
         {
            byte[] ret = null;
            if(TilesInMemory.TryGetValue(tile, out ret))
            {
               return ret;
            }
         }
         finally
         {
            kiberCacheLock.ReleaseReaderLock();
         }
         return null;
      }
Пример #3
0
      internal void AddTileToMemoryCache(RawTile tile, byte[] data)
      {
         if(data != null)
         {
            kiberCacheLock.AcquireWriterLock();
            try
            {
               if(!TilesInMemory.ContainsKey(tile))
               {
                  TilesInMemory.Add(tile, data);
               }
            }
            finally
            {
               kiberCacheLock.ReleaseWriterLock();
            }
         }
#if DEBUG
         else
         {
            //Debug.WriteLine("adding empty data to MemoryCache ;} ");
            if(Debugger.IsAttached)
            {
               Debugger.Break();
            }
         }
#endif
      }
Пример #4
0
        void CompositionTargetEx_FrameUpdating(object sender, RenderingEventArgs e)
        {
            if(update)
             {
            _frameCounterUpdate++;
            update = false;

            #region -- add image --
            for(int x = 0; x < TilesSize.Width; x++)
            {
               for(int y = 0; y < TilesSize.Height; y++)
               {
                  var rawTile = new RawTile(MapType.GoogleHybrid, new GMap.NET.Point(x, y), ZoomStep);
                  var rectTilePx = new Rect(x*Projection.TileSize.Width, y*Projection.TileSize.Height, Projection.TileSize.Width, Projection.TileSize.Height);

                  TileVisual image = null;
                  if(!images.TryGetValue(rawTile, out image))
                  {
                     var layers = GMaps.Instance.GetAllLayersOfType(rawTile.Type);

                     ImageSource[] imgs = new ImageSource[layers.Length];

                     // get tiles
                     for(int i = 0; i < layers.Length; i++)
                     {
                        Exception ex;
                        var res = GMaps.Instance.GetImageFrom(layers[i], rawTile.Pos, rawTile.Zoom, out ex) as WindowsPresentationImage;
                        if(res != null)
                        {
                           imgs[i] = res.Img;
                        }
                     }

                     // combine visual
                     image = new TileVisual(imgs, rawTile);
                     images.Add(rawTile, image);

                     Canvas.SetZIndex(image, -1);
                  }

                  bool ri = (region.IntersectsWith(new GMap.NET.Rectangle((int) (rectTilePx.X + renderOffset.X), (int) (rectTilePx.Y + renderOffset.Y), (int) rectTilePx.Width, (int) rectTilePx.Height)));
                  if(TilesLayer.Children.Contains(image))
                  {
                     if(ri)
                     {
                        image.MoveTo(Math.Round(rectTilePx.X) + 0.6 + renderOffset.X, Math.Round(rectTilePx.Y) + 0.6 + renderOffset.Y);
                     }
                     else
                     {
                        TilesLayer.Children.Remove(image);
                     }
                  }
                  else
                  {
                     if(ri)
                     {
                        image.MoveTo(Math.Round(rectTilePx.X) + 0.6 + renderOffset.X, Math.Round(rectTilePx.Y) + 0.6 + renderOffset.Y);
                        BeginAnimateOpacity(image);
                        {
                           TilesLayer.Children.Add(image);
                        }
                     }
                  }
                  //break;
               }
               //break;
            }

            count = TilesLayer.Children.Count;

            #endregion
             }

             if(_stopwatch.ElapsedMilliseconds >= 1000)
             {
            _stopwatch.Stop();

            perfInfo.Text = "FPS: " + (ushort) (_frameCounter/_stopwatch.Elapsed.TotalSeconds) + " | " + (ushort) (_frameCounterUpdate/_stopwatch.Elapsed.TotalSeconds) + " | " + count + " tiles";

            _frameCounter = 0;
            _frameCounterUpdate = 0;
            _stopwatch.Reset();
            _stopwatch.Start();
             }
             else
             {
            _frameCounter++;
             }
        }
Пример #5
0
 public CacheQueueItem(RawTile tile, byte[] Img, CacheUsage cacheType)
 {
     this.Tile      = tile;
     this.Img       = Img;
     this.CacheType = cacheType;
 }
Пример #6
0
 public CacheQueueItem(RawTile tile, byte[] Img, CacheUsage cacheType)
 {
    this.Tile = tile;
    this.Img = Img;
    this.CacheType = cacheType;
 }