private static Image DrawSampleImage(Image image, Style style) { Image newImage = new Bitmap(image.Width, image.Height); image.Dispose(); GdiPlusGeoCanvas canvas = new GdiPlusGeoCanvas(); canvas.BeginDrawing(newImage, new RectangleShape(0, newImage.Width, newImage.Height, 0), GeographyUnit.DecimalDegree); style.DrawSample(canvas); if (canvas.IsDrawing) { canvas.EndDrawing(); } return(newImage); }
protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers) { GeoImage miniImage = new GeoImage(width, height); RectangleShape scaledWorldExtent = MapEngine.GetDrawingExtent(canvas.CurrentWorldExtent, width, height); scaledWorldExtent.ScaleUp(300); GdiPlusGeoCanvas minCanvas = new GdiPlusGeoCanvas(); minCanvas.BeginDrawing(miniImage, scaledWorldExtent, canvas.MapUnit); foreach (Layer layer in layers) { layer.Draw(minCanvas, labelsInAllLayers); } minCanvas.DrawArea(RectangleShape.ScaleDown(minCanvas.CurrentWorldExtent, 1), new GeoPen(GeoColor.StandardColors.Gray, 2), DrawingLevel.LevelOne); minCanvas.DrawArea(canvas.CurrentWorldExtent, new GeoPen(GeoColor.StandardColors.Black, 2), DrawingLevel.LevelOne); minCanvas.EndDrawing(); ScreenPointF drawingLocation = GetDrawingLocation(canvas, width, height); canvas.DrawScreenImageWithoutScaling(miniImage, (drawingLocation.X + width / 2) + 10, (drawingLocation.Y + height / 2) - 10, DrawingLevel.LevelOne, 0, 0, 0); }
protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers) { if (IsVisible) { ScreenPointF screenPointF = GetDrawingLocation(canvas, logoImage.Width, logoImage.Height); // If the canvas happens to be using GDI+ then we can do an optimization and skip // the GeoImage. Otherwise we go the longer route in the else statement if (canvas is GdiPlusGeoCanvas) { GdiPlusGeoCanvas gdiPlusGeoCanvas = canvas as GdiPlusGeoCanvas; gdiPlusGeoCanvas.DrawScreenImageWithoutScaling(logoImage, screenPointF.X + logoImage.Width * 0.5f, screenPointF.Y + logoImage.Height * 0.5f, DrawingLevel.LevelOne, 0, 0, 0); } else { // Here we have to convert the stream to a TIFF to be used in the GeoImage Stream stream = new MemoryStream(); logoImage.Save(stream, ImageFormat.Tiff); GeoImage geoImage = new GeoImage(stream); canvas.DrawScreenImageWithoutScaling(geoImage, screenPointF.X + logoImage.Width * 0.5f, screenPointF.Y + logoImage.Height * 0.5f, DrawingLevel.LevelOne, 0, 0, 0); } } }
private float GetLegendWidth(LegendAdornmentLayer legendAdornmentLayer) { GdiPlusGeoCanvas gdiPlusGeoCanvas = new GdiPlusGeoCanvas(); LegendItem title = legendAdornmentLayer.Title; float width = gdiPlusGeoCanvas.MeasureText(title.TextStyle.TextColumnName, new GeoFont("Segoe UI", 12)).Width + title.ImageWidth + title.ImageRightPadding + title.ImageLeftPadding + title.TextRightPadding + title.TextLeftPadding + title.LeftPadding + title.RightPadding; foreach (LegendItem legendItem in legendAdornmentLayer.LegendItems) { float legendItemWidth = gdiPlusGeoCanvas.MeasureText(legendItem.TextStyle.TextColumnName, new GeoFont("Segoe UI", 10)).Width + legendItem.ImageWidth + legendItem.ImageRightPadding + legendItem.ImageLeftPadding + legendItem.TextRightPadding + legendItem.TextLeftPadding + legendItem.LeftPadding + legendItem.RightPadding; if (width < legendItemWidth) { width = legendItemWidth; } } return width; }
private float GetLegendHeight(LegendAdornmentLayer legendAdornmentLayer) { GdiPlusGeoCanvas gdiPlusGeoCanvas = new GdiPlusGeoCanvas(); LegendItem title = legendAdornmentLayer.Title; float titleMeasuredHeight = gdiPlusGeoCanvas.MeasureText(title.TextStyle.TextColumnName, new GeoFont("Segoe UI", 12)).Height; float legendHeight = new[] { titleMeasuredHeight, title.ImageHeight, title.Height }.Max(); float height = legendHeight + Math.Max(title.ImageTopPadding, title.TextTopPadding) + title.TopPadding + Math.Max(title.ImageBottomPadding, title.TextBottomPadding) + title.BottomPadding; foreach (LegendItem legendItem in legendAdornmentLayer.LegendItems) { float itemLegendHeight = Math.Max(gdiPlusGeoCanvas.MeasureText(legendItem.TextStyle.TextColumnName, new GeoFont("Segoe UI", 10)).Height, legendItem.ImageHeight); float itemHeight = itemLegendHeight + Math.Max(legendItem.ImageTopPadding, legendItem.TextTopPadding) + legendItem.TopPadding + Math.Max(legendItem.ImageBottomPadding, legendItem.TextBottomPadding) + legendItem.BottomPadding; height += itemHeight; } return height; }
public void Draw(Style style) { GdiPlusGeoCanvas geoCanvas = new GdiPlusGeoCanvas(); DrawCore(geoCanvas, style); }
private LayerTile DrawHighlightTile(RectangleShape targetExtent, LayerTile tile) { tile.DrawingLayers.Clear(); if (highlightFeatureLayer.InternalFeatures.Count > 0) { tile.DrawingLayers.Add(highlightFeatureLayer); } GeoCanvas geoCanvas = new GdiPlusGeoCanvas() { CompositingQuality = CompositingQuality.HighSpeed, DrawingQuality = DrawingQuality.HighSpeed, SmoothingMode = SmoothingMode.HighSpeed }; Bitmap bitmap = new Bitmap((int)tile.Width, (int)tile.Height); geoCanvas.BeginDrawing(bitmap, targetExtent, MapArguments.MapUnit); tile.Draw(geoCanvas); geoCanvas.EndDrawing(); tile.CommitDrawing(geoCanvas, MapSuiteSampleHelper.GetImageSourceFromNativeImage(bitmap)); return tile; }