ThinkGeo.com    |     Documentation    |     Premium Support

Legend Adornment Exception

Hi,

I get the following exception when I minimize and then maximize a map with a LegendAdornmentLayer on it. I’m using version 10.

System.ArgumentException
HResult=0x80070057
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)
at hyY=.jyY=.CreateDefault(Int32 width, Int32 height)
at ThinkGeo.MapSuite.Layers.LegendAdornmentLayer.DrawCore(GeoCanvas canvas, Collection1 labelsInAllLayers) at ThinkGeo.MapSuite.Layers.Layer.lic=(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.WinForms.AdornmentOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.yFU=(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.WinformsMap.h1U=(Graphics graphics, RectangleShape extent, Overlay overlay)
at ThinkGeo.MapSuite.WinForms.WinformsMap.gFU=(RectangleShape drawingExtent, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.n1U=(RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.iFU=(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
at System.Windows.Forms.Control.UpdateBounds()
at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

This exception was originally thrown at this call stack:
System.Drawing.Bitmap.Bitmap(int, int, System.Drawing.Imaging.PixelFormat)
hyY=.jyY=.CreateDefault(int, int)
ThinkGeo.MapSuite.Layers.LegendAdornmentLayer.DrawCore(ThinkGeo.MapSuite.Drawing.GeoCanvas, System.Collections.ObjectModel.Collection<ThinkGeo.MapSuite.Styles.SimpleCandidate>)
ThinkGeo.MapSuite.Layers.Layer.lic=(ThinkGeo.MapSuite.Drawing.GeoCanvas, System.Collections.ObjectModel.Collection<ThinkGeo.MapSuite.Styles.SimpleCandidate>)
ThinkGeo.MapSuite.Layers.Layer.Draw(ThinkGeo.MapSuite.Drawing.GeoCanvas, System.Collections.ObjectModel.Collection<ThinkGeo.MapSuite.Styles.SimpleCandidate>)
ThinkGeo.MapSuite.WinForms.AdornmentOverlay.DrawCore(ThinkGeo.MapSuite.Drawing.GeoCanvas)
ThinkGeo.MapSuite.WinForms.Overlay.yFU=(ThinkGeo.MapSuite.Drawing.GeoCanvas)
ThinkGeo.MapSuite.WinForms.Overlay.Draw(ThinkGeo.MapSuite.Drawing.GeoCanvas)
ThinkGeo.MapSuite.WinForms.WinformsMap.h1U=(System.Drawing.Graphics, ThinkGeo.MapSuite.Shapes.RectangleShape, ThinkGeo.MapSuite.WinForms.Overlay)
ThinkGeo.MapSuite.WinForms.WinformsMap.gFU=(ThinkGeo.MapSuite.Shapes.RectangleShape, ThinkGeo.MapSuite.Shapes.RectangleShape)

[Call Stack Truncated]

Thanks,
Damian

Thanks Damian,
I still can not re-produce this issue. We have a demo project for the legend adornment. ShowALegendSample-ForWpf-master.zip (312.3 KB)

Could you modify this one to re-produce the issue you mentioned. This will be very helpful for us to dig into the issue.

Thanks

Frank

Hi Frank,

I’ve tried many things to reproduce this in a small test project without success. Are there any hints at all from the stack trace that you could point me to?

I’m attaching my test project so you have a better idea of what I am doing.

LegendMinimizeError.zip (300.1 KB)

Thanks,
Damian

Thanks Damian,
Base on the error. I think we may pass 0 to the bitmap for some reason. If you use

Bitmap test = new Bitmap(0, 0);

You will get the same error.

Thanks

Frank

Hmmm… I would think then that this must be associated with an event of the Legend Adornment Layer.

When I create the legend it is setting the legend items based on the map size. It’s only when we minimize and then maximize the form that the error occurs.

So, is there a redraw event firing for the adornment overlay that takes map size as input? Can you look at the code and see if anything is being done with the bitmaps of the legend items?

Thanks,
Damian

Damian,
Here is the code for the Legend Adornment.
LegendAdornment.zip (5.8 KB)

I think for some reason you set legendLayer.Height = 0;

You have one line:
legendLayer.Height = winformsMap1.Height;

Probably this one will be called after the map minimized.

Thanks

Frank

Hi Frank,

Sorry, I realize this is very obscure.

The test project that I sent over has the same code as my master project and yet when I minimize the map in the test project, it does not produce the error.

DrawCore of the LegendAdornmentLayer has the Bitmap generation in it, but it is surrounded by a Try/Catch, so I wouldn’t expect unhandled exception from there.

Also, I have added the resize event to my map and added the build legend code to that. Even when I minimize the window and the map height is now zero there is no error. Maximizing the form again has the map set back to it’s original size, so even then it is not zero width/height and again no error.

I am willing to escalate this issue as a full support request to see if we can get a resolution (at least I can demonstrate the error on my master project). Can you raise that or do I need to go through the portal?

Thanks,
Damian

Thanks Damian,
Yes. You could create a support ticket and we could schedule a zoom meeting to demonstrate the issue on your screen.

Thanks

Frank