void BeginAnimateZoom(TileVisual target) { //target.TranslateTransform.BeginAnimation(TranslateTransform.XProperty, MoveAnimation, HandoffBehavior.Compose); //target.TranslateTransform.BeginAnimation(TranslateTransform.YProperty, MoveAnimation, HandoffBehavior.Compose); //target.ScaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, ZoomAnimation, HandoffBehavior.Compose); //target.ScaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, ZoomAnimation, HandoffBehavior.Compose); }
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++; } }
void BeginAnimateZoom(TileVisual target) { //target.TranslateTransform.BeginAnimation(TranslateTransform.XProperty, MoveAnimation, HandoffBehavior.Compose); //target.TranslateTransform.BeginAnimation(TranslateTransform.YProperty, MoveAnimation, HandoffBehavior.Compose); //target.ScaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, ZoomAnimation, HandoffBehavior.Compose); //target.ScaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, ZoomAnimation, HandoffBehavior.Compose); }
void BeginAnimateOpacity(TileVisual target) { target.Opacity = 0.4; target.BeginAnimation(TileVisual.OpacityProperty, OpacityAnimation, HandoffBehavior.Compose); }
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 GPoint(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 GRect((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++; } }
void BeginAnimateOpacity(TileVisual target) { target.Opacity = 0.4; target.BeginAnimation(TileVisual.OpacityProperty, OpacityAnimation, HandoffBehavior.Compose); }