ThinkGeo.com    |     Documentation    |     Premium Support

V12 - DrawCore?

I have a lot of instances where I override DrawCore…how do I do the same in V12?

Se example below:

protected override void DrawCore(GeoCanvas aCanvas)
{
this.CurrentExtent = aCanvas.CurrentWorldExtent;
if (this.Image == null || this.Image.Bitmap == null) return;
using (
Maps.TransformMatrix Matrix = new Maps.TransformMatrix(aCanvas.CurrentWorldExtent,
((System.Drawing.Bitmap)aCanvas.NativeImage).Size))
using (
System.Drawing.Graphics Gr =
System.Drawing.Graphics.FromImage((System.Drawing.Bitmap)aCanvas.NativeImage))
{
Gr.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
Gr.InterpolationMode = this.Smooth
? System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
: System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
Gr.DrawImage(this.Image.Bitmap, System.Drawing.Rectangle.Round(Matrix.Transform(this.Image.Extent)));
}
this.BackgroundImage = Maps.BitmapColors.Copy((System.Drawing.Bitmap)aCanvas.NativeImage);
}

Ok. We have a very complicated implementation of TG on winforms that uses a lot of GDI/GDI+. Going to WPF is going to be a re-write. Sort of figuring that out when going to V12 and .Net Core.

I did change to DrawCore(RectangleShape CurrentExtent, OverlayRefreshType overlayRefreshType) for the above and modified the code but it’s going to be a battle…

Thanks Ernest,
Yes. In order to support the .Net core. we switch to Skia from GDI/GDI+. If there is some class has issue to upgrade to the V12. Go ahead send to us we could look into the detail.

Thanks

Frank

The above class structure in my first post is quite common in my code. I’m struggling with how to do the same in Skia and v12. Can you offer any tips?

Here’s the entire class in V10:

using ThinkGeo.MapSuite.Styles;
using ThinkGeo.MapSuite.Drawing;
using ThinkGeo.MapSuite.Shapes;
using ThinkGeo.MapSuite.Layers;
using ThinkGeo.MapSuite.WinForms;
using ThinkGeo.MapSuite;

namespace Maps
{
public class ImageOverlay : Overlay
{
public virtual LocatedImage Image { get; set; }
public System.Drawing.Image BackgroundImage { get; set; }
public bool Smooth { get; set; }
public RectangleShape CurrentExtent { get; private set; }
public bool Invalidated { get; set; }
public virtual void Invalidate() { this.Invalidated = true; }
protected override void DrawCore(GeoCanvas aCanvas)
{
this.CurrentExtent = aCanvas.CurrentWorldExtent;
if (this.Image == null || this.Image.Bitmap == null) return;
using (
Maps.TransformMatrix Matrix = new Maps.TransformMatrix(aCanvas.CurrentWorldExtent,
((System.Drawing.Bitmap) aCanvas.NativeImage).Size))
using (
System.Drawing.Graphics Gr =
System.Drawing.Graphics.FromImage((System.Drawing.Bitmap) aCanvas.NativeImage))
{
Gr.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
Gr.InterpolationMode = this.Smooth
? System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
: System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
Gr.DrawImage(this.Image.Bitmap, System.Drawing.Rectangle.Round(Matrix.Transform(this.Image.Extent)));
}
this.BackgroundImage = Maps.BitmapColors.Copy((System.Drawing.Bitmap) aCanvas.NativeImage);
}
}
}

Thanks ernest,
Could you try with the geoCanvas. This will call the Skia draw method. I attached you an example. BackgroundOverlay.cs (4.2 KB)

Thanks

Frank

That seems to at least compile and make sense. When I start testing I will let you know.

Next question:

For the following:

this.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.TextSolidBrush.Color = value; /
this.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.Color = GeoColor.StandardColors.Transparent;

What replaced TextSolidBrush and GeoColor.StandardColors.Transparent ?

Sorry for all the questions…

Thanks Ernest,

  1. Use GeoBrush
    .DefaultTextStyle = new TextStyle("NAME", new GeoFont("Segoe UI", 12, DrawingFontStyles.Bold), GeoBrushes.DarkRed);
  2. Use
    GeoColors.Transparent;

Go ahead let us know if you have more question.

Thanks

Frank

So in V10 I was able it get and set the font color.

See below:

public GeoColor ColorText
{
get { return this.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.TextSolidBrush.Color; }
set
{
this.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.TextSolidBrush.Color = value;
this.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.Color = GeoColors.Transparent;
}
}

How can I do this in V12?

Thanks.

Ernest,
You can do it like this

    public GeoColor ColorText
        {
            get {
                return ((GeoSolidBrush)this.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.TextBrush).Color;
            }
            set
            {
                this.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.TextBrush = new GeoSolidBrush(value);
                this.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.Color = GeoColors.Transparent;
            }
        }

Thanks

Frank

Thanks. Here’s another V10 to V12 change:

See class below. I changed the new color options but the scalebaradornmentlayer is no longer there.

public class ScaleBarAdornmentLayer : Layers.ScaleBarAdornmentLayer
{
    public Func<TextStyle, TextStyle> CreateSimpleTextStyle { get; set; }

    public ScaleBarAdornmentLayer()
    {
        this.CreateSimpleTextStyle = (aTextStyle) => aTextStyle;
        this.LoadStyle = true;
        **this.AlternateBarBrush = new GeoSolidBrush(GeoColors.Transparent);**

** this.BarBrush = new GeoSolidBrush(GeoColor.FromArgb(120, GeoColors.White));**
** this.MaxWidth = 320;**
** this.BarPen = new GeoPen(GeoColor.FromArgb(120, GeoColors.Black));**
}
public bool LoadStyle { get; set; }

    protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
    {
        if (this.LoadStyle)
        {
            this.LoadStyle = false;
            this.TextStyle = CreateSimpleTextStyle(this.TextStyle);
        }
        base.DrawCore(canvas, labelsInAllLayers);
    }
}

Is this a winforms to wpf change?

Ernest,
ScaleBarAdornmentLayer is under ThinkGeo.Core now.

Thanks

Frank