public BitmapSource CreateOSMPictureWithOverLoadsViaGeometryInfo(GeometryInfo GeoInfo, List<DrawAbleTrack> TracksToOverlay = null, List<Marker> MarkersToOverlay = null, DrawMarkerEvent DrawMarkerHandler = null) { GeoInfo.RunTileLoadingSynchron = true; DrawingVisual DrawingBoard = new DrawingVisual(); Rect DrawingRect = new Rect(0, 0, GeoInfo.Width, GeoInfo.Height); DrawingContext Context = DrawingBoard.RenderOpen(); FillDrawingBackGound(GeoInfo, Context); if (TracksToOverlay != null) FillDrawingTracks(GeoInfo, Context, TracksToOverlay); if (MarkersToOverlay != null) { MarkersToOverlay = OrderMarkerAccordingToTypeToDraw(MarkersToOverlay); FillDrawingMarker(GeoInfo, Context, MarkersToOverlay, DrawMarkerHandler); } Context.Close(); RenderTargetBitmap DrawingBitmap = new RenderTargetBitmap ((int) (GeoInfo.Width*Basics.XDPIFactor), (int) (GeoInfo.Height*Basics.YDPIFactor), Basics.XDPIFactor*96, Basics.YDPIFactor*96, PixelFormats.Pbgra32); DrawingBitmap.Render(DrawingBoard); //Rect OriginalRect = DrawingBoard.Drawing.Bounds; //ImageBrush IMBrush = new ImageBrush(); return (BitmapSource) BitmapFrame.Create(DrawingBitmap); }
public void FillDrawingMarker(GeometryInfo GeoInfo, DrawingContext Context, List<Marker> mMarkers, DrawMarkerEvent DrawMarkerHandler) { try { // Draw markers... foreach (Marker m in mMarkers) { m.Geometrie = GeoInfo; int mx, my; LatLonToClientPos(GeoInfo, m.Lat, m.Lon, out mx, out my); Point Position = new Point((double) mx, (double) my); if (DrawMarkerHandler != null) DrawMarkerHandler(this, m, Context, Position); else { Pen pen = new Pen(Brushes.Red, 3); Context.DrawEllipse(null, pen, new Point(mx - 3, my - 3), 7, 7); } } } catch (Exception Excp) { MessageBox.Show("Drawing Marker Exception: " + Excp.ToString()); } }
public BitmapSource CreateOSMPictureWithOverLoadsViaKachel(MapKachel RootKachel, List<Marker> MarkersToOverlay, DrawMarkerEvent DrawMarkerHandler, GraphicSize RequestedGraphicSize) { GeometryInfo GeoInfo = new GeometryInfo(); //MapBasics.Instance.DrawMarkerHandler = DrawMarkerHandler; CalcGeometry(GeoInfo, RootKachel.MapBitmapImage.Width, RootKachel.MapBitmapImage.Height, RootKachel.GeographicalTopLeft.X, RootKachel.GeographicalTopLeft.Y, RootKachel.GeographicalBottomRight.X, RootKachel.GeographicalBottomRight.Y, RequestedGraphicSize); List<DrawAbleTrack> Tracks = new List<DrawAbleTrack>(); LoadTracks(MapDataWrapper.Instance.GetAllTracks("OrtsTeil"), "OrtsTeil", Tracks, new Pen(Brushes.Blue, 4)); LoadTracks(MapDataWrapper.Instance.GetAllTracks("Bezirk"), "Bezirk", Tracks, new Pen(Brushes.Red, 7)); MarkersToOverlay.AddRange(GetOrtsTeilDescriptionMarker(RootKachel)); return CreateOSMPictureWithOverLoadsViaGeometryInfo(GeoInfo, Tracks, MarkersToOverlay, DrawMarkerHandler); }