GoShape zooming problem in my GoView

I am seeing a problem with my OnPaint override for our custom background shapes that are derived from GoShape. We have a number of GoTextNode derived classes that override CreateBackground to create one of our custom backgrounds.



One of these background shapes has a solid brush coloured background with some white text in Arial 40pt Bold. The text just consists of a question mark character (?). Usually this shape is drawn correctly by our view. However when I hold down Ctrl and use the mouse wheel to zoom in and out I get a problem.



If I zoom in too close, the white question mark disappears from the shape, so i’m left with just a coloured circle of the shape background. I can still see the question mark character in the overview panel. If I zoom out, then the text re-appears.



I’m puzzled about why this would occur since as far as I can tell the Graphics object that we are drawing to is a memory based image of some sort that is then simple scaled up and down as required by the view to do the zooming in and out. In the debugger I can not see anything obvious changing within the supplied Graphics to my OnPaint method. The only thing that seems to change in the supplied view is view.myHorizScale and view.myVertScale.



The very same problem happens in the overview panel if I also zoom that in too much.



Its got me puzzled?



Ian

Arrgh I need to post my problems here sooner. I’d get much more work done that way!



As is usually the case with these things, you spend a day trying just about everything you can think of to fix the problem and then 10 minutes after publicly posting about it you find the solution.



Turns out the bounding rectangle being passed to DrawString was right on the limit of being able to completely contain the character. I think because I was using StringFormat.GenericTypographic the LineLimit flag was tripping up the drawing of the text.



I suppose something (but i dont know what) must be different in the Graphics object between different zoom levels.



It’s fixed, but i’m still puzzled.

Yes, that sounds like the probable cause of the problem.
That’s why you should use a GoText instead of calling Graphics.DrawString. Let us handle all those boundary conditions, especially when printing or different devices are involved.



I appreciate what you are saying Walter, however can a GoText reproduce this without any custom drawing code?
http://www.highwaycode.gov.uk/sign040.htm

Thats one of the custom backgrounds i'm trying to create. This one doesn't have the scaling problem of the other but they share the same common base class.
  GoGroup stopsign = new GoGroup();<BR>      stopsign.Resizable = false;<BR>      GoOctagon stopoct = new GoOctagon();<BR>      stopoct.Selectable = false;<BR>      stopoct.Brush = Brushes.Red;<BR>      stopoct.Pen = null;<BR>      stopoct.Corner = new SizeF(125, 125);<BR>      stopoct.Size = new SizeF(400, 400);<BR>      stopoct.Position = new PointF(100, 100);<BR>      stopsign.Add(stopoct);<BR>      GoOctagon stopoct2 = new GoOctagon();<BR>      stopoct2.Selectable = false;<BR>      stopoct2.Brush = null;<BR>      stopoct2.Pen = new Pen(Color.White, 10);<BR>      stopoct2.Corner = new SizeF(120, 120);<BR>      stopoct2.Size = new SizeF(386, 386);<BR>      stopoct2.Center = stopoct.Center;<BR>      stopsign.Add(stopoct2);<BR>      GoText stoptxt = new GoText();<BR>      stoptxt.Selectable = false;<BR>      stoptxt.Text = "STOP";<BR>      stoptxt.Bold = true;<BR>      stoptxt.FontSize = 100;<BR>      stoptxt.TextColor = Color.White;<BR>      stoptxt.Center = stopoct.Center;<BR>      stopsign.Add(stoptxt);<BR>