Is Something Wrong with OnDrawBackBuffer?

Mar 7, 2013 at 1:27 PM
Hi, I'm using MapWinGis.ocx 4.8.6 32bit(my OS Win7 64bit) in my c# Winform Project,
I use OnDrawBackBuffer in order to use graphic.Draw(... of .net
in such step, the axMap's behavior is Strange!
  1. Open my form window (shown WindowState= Normal)
  2. Click some points, and in my OnDrawBackBuffer code , i draw a rectangle with c#;
  3. Maximize my form window, switch axMap.CursorMode to cmZoomIn:
    axMap.CursorMode = MapWinGIS.tkCursorMode.cmZoomIn;
  4. zoom in a rectangle, only apart of the axMap is redrawing, the same size with when the form window is in Normal state , the other expanded parts:Nothing drawn....
It happends each time i operate as this 1,2,3,4...

Is it a bug? or what should i do with it ?

thanks!

my code is here:
        private List<DbPoint> ptRailsList = new List<DbPoint>();
        private void axMap_MouseDownEvent(object sender, AxMapWinGIS._DMapEvents_MouseDownEvent e)
        {
            if (axMap.CursorMode == tkCursorMode.cmNone)
            {
                double xProjected = 0, yProjected = 0;
                axMap.PixelToProj(e.x, e.y, ref xProjected, ref yProjected);
                ptRailsList.Add(new DbPoint(xProjected, yProjected));
                
            }
            axMap.Redraw();
        }
        private void axMap_OnDrawBackBuffer(object sender, AxMapWinGIS._DMapEvents_OnDrawBackBufferEvent e)
        {
            Graphics g = Graphics.FromHdc((IntPtr)e.backBuffer);
            if (ptRailsList.Count >= 3)
            {
                PointF[] points = new PointF[ptRailsList.Count];

                for (int i = 0; i < ptRailsList.Count; i++)
                {
                    double pixX1 = 0, pixY1 = 0;
                    axMap.ProjToPixel(ptRailsList[i].x, ptRailsList[i].y, ref pixX1, ref pixY1);
                    points[i] = new PointF((float)pixX1, (float)pixY1);
                }
                Brush brs = new HatchBrush(HatchStyle.LargeGrid, Color.FromArgb(100, Color.Green), Color.Transparent);
                g.FillPolygon(brs, points, FillMode.Alternate);
            }
        }
Coordinator
Mar 15, 2013 at 1:41 PM
I'm not sure why OnDrawBackBuffer is behaving like you mention.
But what do you try to do?
Looking at your code it looks like you want to create a railroad style, am I correct?
You can use the line pattern methods for that as well.

Here's an example: http://www.mapwindow.org/documentation/mapwingis4.8/_line_pattern_8cs-example.html#_a0
Mar 16, 2013 at 1:07 AM
pmeems wrote:
I'm not sure why OnDrawBackBuffer is behaving like you mention.
But what do you try to do?
Looking at your code it looks like you want to create a railroad style, am I correct?
You can use the line pattern methods for that as well.

Here's an example: http://www.mapwindow.org/documentation/mapwingis4.8/_line_pattern_8cs-example.html#_a0
Thank you, pmeems,
I appreciate your helping :)

My code in my OnDrawBackBuffer is just an example,the Graphics Draw code can be something else..., OnDrawBackBuffer behaves like that each time I test my program like that...
Developer
Mar 22, 2013 at 2:55 AM
Try adding a call to Dispose() at the end of your axMap_OnDrawBackBuffer() method:

g.Dispose();

Resolved the issue for me. MSDN recommends this as well (http://msdn.microsoft.com/en-us/library/20tc8e3b.aspx).
Mar 22, 2013 at 5:17 AM
heste015 wrote:
Try adding a call to Dispose() at the end of your axMap_OnDrawBackBuffer() method:

g.Dispose();

Resolved the issue for me. MSDN recommends this as well (http://msdn.microsoft.com/en-us/library/20tc8e3b.aspx).
Yeah!
It works!

Thank you very much!