ThinkGeo.com    |     Documentation    |     Premium Support

ThinkGeo V12 Use of GeoCanvas to Create Legend

ThinkGeo Team,

Under MapSuite I have code to create an image for use as a Legend in Wpf as shown in the screen-capture below. That code made use of ThinkGeo.MapSuite.Drawing.PlatformGeoCanvas, but all that has changed under V12.

Attached is a text file that has the code implemented under MapSuite for this purpose.

Would you offer some hints as how to create a PNG image from Area/Line/PointStyle.DrawSample?

Thanks,
Dennis
UseOfPlatformGeoCanvasToCreateLegend.txt (5.7 KB)

Hi Dennis,

I think this code should be helpful for the new version 12:

             private void BuildImageFromStyle()
    {
        GeoImage geoImage;
        GeoCanvas canvas = GeoCanvas.CreateDefaultGeoCanvas();

        PointStyle pointStyle = new PointStyle(PointSymbolType.Circle, 20, new GeoSolidBrush(GeoColors.Black));
        AreaStyle areaStyle = new AreaStyle(new GeoSolidBrush(GeoColors.Red));
        LineStyle lineStyle = new LineStyle(new GeoPen(GeoColors.Green));

        geoImage = new GeoImage(40, 100);

        canvas.BeginDrawing(geoImage, new RectangleShape(0, geoImage.Height, geoImage.Width, 0), GeographyUnit.Feet);

        pointStyle.DrawSample(canvas, new DrawingRectangleF(10, 10, 20, 20));
        areaStyle.DrawSample(canvas, new DrawingRectangleF(10, 40, 20, 20));
        lineStyle.DrawSample(canvas, new DrawingRectangleF(10, 70, 20, 20));

        canvas.EndDrawing();

        geoImage.Save("TempSaved.png", GeoImageFormat.Png);
        geoImage.Dispose();
    }

It render the image like this:

TempSaved

Regards,

Ethan