public override void Paint(IGraphics graphics, IMapViewport viewport) { object state = graphics.SaveState(); graphics.ChangeSmoothingMode(SmoothingMode.AntiAlias); MapVisualElementInfo info = this.GetVisualElementInfo(viewport); GraphicsPath path = info.Path.Clone() as GraphicsPath; GraphicsPath dotPath = new GraphicsPath(); long mapSize = MapTileSystemHelper.MapSize(viewport.ZoomLevel); Matrix matrixOffset = new Matrix(); matrixOffset.Translate(viewport.PanOffset.Width + info.Offset.X, viewport.PanOffset.Height + info.Offset.Y); path.Transform(matrixOffset); Matrix matrixWraparound = new Matrix(); matrixWraparound.Translate(mapSize, 0); for (int i = 0; i < viewport.NumberOfWraparounds; i++) { RectangleF bounds = path.GetBounds(); float diameter = bounds.Width / 3F; dotPath.AddEllipse(bounds.X + diameter, bounds.Y + diameter, diameter, diameter); graphics.FillPath(this.BorderColor, dotPath); //draw the image Point imageLocation = new Point((int)bounds.Location.X + (int)bounds.Width / 2 - this.image.Width / 2, (int)bounds.Location.Y); graphics.DrawImage(imageLocation, this.Image, true); path.Transform(matrixWraparound); } graphics.RestoreState(state); }
public override void ViewportChanged(IMapViewport viewport, ViewportChangeAction action) { if (this.Image == null) { base.ViewportChanged(viewport, action); return; } long mapSize = MapTileSystemHelper.MapSize(viewport.ZoomLevel); if ((action & ViewportChangeAction.Zoom) != 0) { this.pixelLocation = MapTileSystemHelper.LatLongToPixelXY(this.Location, viewport.ZoomLevel); } if ((action & ViewportChangeAction.Pan) != 0) { this.drawRect = new RectangleL(pixelLocation.X - this.Image.Size.Width / 2, pixelLocation.Y - this.Image.Size.Height, this.Image.Size.Width, this.Image.Size.Height); } RectangleL wraparoundDrawRect = this.drawRect; for (int i = 0; i <= viewport.NumberOfWraparounds; i++) { if (wraparoundDrawRect.IntersectsWith(viewport.ViewportInPixels)) { this.isImageInViewPort = true; break; } wraparoundDrawRect.Offset(mapSize, 0L); } if (!this.IsInViewport) { return; } }
public override void Paint(IGraphics graphics, IMapViewport viewport) { if (this.Image == null) { base.Paint(graphics, viewport); return; } object state = graphics.SaveState(); graphics.TranslateTransform(drawRect.X, drawRect.Y); Graphics g = graphics.UnderlayGraphics as Graphics; long mapSize = MapTileSystemHelper.MapSize(viewport.ZoomLevel); for (int i = -1; i <= viewport.NumberOfWraparounds; i++) { g.DrawImage(this.Image, new RectangleF(i * mapSize, 0, this.Image.Size.Width, this.Image.Size.Height)); } graphics.RestoreState(state); }